symposium 1.4.0 → 1.4.2

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/Agent.js CHANGED
@@ -65,12 +65,13 @@ export default class Agent {
65
65
  return {};
66
66
  }
67
67
 
68
- addTool(tool) {
68
+ async addTool(tool) {
69
69
  if (!(tool instanceof Tool) || !tool.name)
70
70
  throw new Error('Tool must be an instance of Tool class');
71
71
  if (this.tools.has(tool.name))
72
72
  throw new Error('Tool with name ' + tool.name + ' already exists in agent');
73
73
 
74
+ await tool.init(this);
74
75
  this.tools.set(tool.name, tool);
75
76
  }
76
77
 
package/Tool.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export default class Tool {
2
2
  name = '';
3
3
 
4
+ async init(agent) {
5
+ }
6
+
4
7
  async getFunctions() {
5
8
  return [];
6
9
  }
@@ -52,8 +52,11 @@ export default class OllamaModel extends Model {
52
52
  };
53
53
  }
54
54
 
55
- if (options.response_format)
56
- completion_payload.response_format = options.response_format;
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 ? JSON.parse(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
- name: message.name,
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
- name: message.name,
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 ? JSON.stringify(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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",