symposium 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/OllamaModel.js +19 -9
- package/package.json +1 -1
package/models/OllamaModel.js
CHANGED
|
@@ -52,8 +52,11 @@ export default class OllamaModel extends Model {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (options.response_format)
|
|
56
|
-
|
|
55
|
+
if (options.response_format) {
|
|
56
|
+
if (!options.response_format.json_schema)
|
|
57
|
+
throw new Error('OllamaModel only supports response_format with json_schema');
|
|
58
|
+
completion_payload.format = options.response_format.json_schema.schema;
|
|
59
|
+
}
|
|
57
60
|
|
|
58
61
|
if (!completion_payload.tools.length)
|
|
59
62
|
delete completion_payload.tools;
|
|
@@ -62,6 +65,9 @@ export default class OllamaModel extends Model {
|
|
|
62
65
|
const completion = chatCompletion.message;
|
|
63
66
|
|
|
64
67
|
const message_content = [];
|
|
68
|
+
if (completion.thinking)
|
|
69
|
+
message_content.push({type: 'reasoning', content: completion.thinking});
|
|
70
|
+
|
|
65
71
|
if (completion.content)
|
|
66
72
|
message_content.push({type: 'text', content: completion.content});
|
|
67
73
|
|
|
@@ -69,12 +75,12 @@ export default class OllamaModel extends Model {
|
|
|
69
75
|
message_content.push({
|
|
70
76
|
type: 'function',
|
|
71
77
|
content: completion.tool_calls.map(tool_call => {
|
|
72
|
-
if (tool_call.function)
|
|
78
|
+
if (!tool_call.function)
|
|
73
79
|
throw new Error('Unsupported tool type');
|
|
74
80
|
|
|
75
81
|
return {
|
|
76
82
|
name: tool_call.function.name,
|
|
77
|
-
arguments: tool_call.function.arguments
|
|
83
|
+
arguments: tool_call.function.arguments || {},
|
|
78
84
|
};
|
|
79
85
|
}),
|
|
80
86
|
});
|
|
@@ -89,13 +95,18 @@ export default class OllamaModel extends Model {
|
|
|
89
95
|
const messages = [],
|
|
90
96
|
role = message.role === 'system' ? this.system_role_name : message.role;
|
|
91
97
|
|
|
98
|
+
let reasoning = null;
|
|
92
99
|
for (let c of message.content) {
|
|
93
100
|
switch (c.type) {
|
|
101
|
+
case 'reasoning':
|
|
102
|
+
reasoning = c.content;
|
|
103
|
+
break;
|
|
104
|
+
|
|
94
105
|
case 'text':
|
|
95
106
|
messages.push({
|
|
96
107
|
role,
|
|
97
108
|
content: c.content,
|
|
98
|
-
|
|
109
|
+
thinking: reasoning || undefined,
|
|
99
110
|
});
|
|
100
111
|
break;
|
|
101
112
|
|
|
@@ -103,21 +114,21 @@ export default class OllamaModel extends Model {
|
|
|
103
114
|
if (this.supports_functions) {
|
|
104
115
|
messages.push({
|
|
105
116
|
role,
|
|
106
|
-
|
|
117
|
+
thinking: reasoning || undefined,
|
|
107
118
|
tool_calls: c.content.map(tool_call => ({
|
|
108
119
|
id: tool_call.id,
|
|
109
120
|
type: 'function',
|
|
110
121
|
function: {
|
|
111
122
|
name: tool_call.name,
|
|
112
|
-
arguments: tool_call.arguments
|
|
123
|
+
arguments: tool_call.arguments || {},
|
|
113
124
|
},
|
|
114
125
|
})),
|
|
115
126
|
});
|
|
116
127
|
} else {
|
|
117
128
|
messages.push({
|
|
118
129
|
role,
|
|
130
|
+
thinking: reasoning || undefined,
|
|
119
131
|
content: c.content.map(f => '```CALL \n' + f.name + '\n' + JSON.stringify(f.arguments || {}) + '\n```').join("\n\n"),
|
|
120
|
-
name: message.name,
|
|
121
132
|
});
|
|
122
133
|
}
|
|
123
134
|
break;
|
|
@@ -133,7 +144,6 @@ export default class OllamaModel extends Model {
|
|
|
133
144
|
messages.push({
|
|
134
145
|
role: 'user',
|
|
135
146
|
content: 'FUNCTION RESPONSE:\n' + JSON.stringify(c.content.response),
|
|
136
|
-
name: message.name,
|
|
137
147
|
});
|
|
138
148
|
}
|
|
139
149
|
break;
|