Skip to content

Commit 0f3ea9b

Browse files
committed
feat: change the temperature setting for ollama
1 parent fcfe16a commit 0f3ea9b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/services/ollama.service.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
const API_URL = process.env.REACT_APP_API_URL || "http://localhost:5000/api/v1";
22

3+
const getQwenTemperature = (modelName: string): number => {
4+
if (modelName.includes("next") || modelName.includes("fast")) return 0.4;
5+
if (modelName.includes("careful") || modelName.includes("think")) return 0.15;
6+
return 0.3;
7+
};
8+
39
export const OllamaService = {
410
chat: async (
511
model: string,
612
messages: { role: string; content: string }[]
713
): Promise<any> => {
14+
const temperature = getQwenTemperature(model);
815
const response = await fetch(`${API_URL}/ollama/chat`, {
916
method: "POST",
1017
headers: { "Content-Type": "application/json" },
11-
body: JSON.stringify({ model, messages, stream: false }),
18+
body: JSON.stringify({
19+
model,
20+
messages,
21+
stream: false,
22+
options: {
23+
temperature, // ← pass to Ollama
24+
},
25+
}),
1226
});
1327

1428
const data = await response.json();

0 commit comments

Comments
 (0)