symposium 2.2.3 → 2.3.0

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
@@ -256,7 +256,8 @@ export default class Agent {
256
256
  for (let message of completion) {
257
257
  if (message.role === 'assistant' && message.content.some(c => c.type === 'reasoning')) {
258
258
  const reasoning = message.content.find(c => c.type === 'reasoning').content;
259
- emitter.emit('reasoning', reasoning);
259
+ if (reasoning)
260
+ emitter.emit('reasoning', reasoning);
260
261
  }
261
262
  }
262
263
 
@@ -21,4 +21,48 @@ export default class GrokModel extends LegacyOpenAIModel {
21
21
 
22
22
  return this.openai;
23
23
  }
24
+
25
+ async generate(model, thread, functions = [], options = {}) {
26
+ if (options.image_generation) {
27
+ functions.push({
28
+ name: 'generate_image',
29
+ description: 'Generate an image based on a detailed prompt that you provide',
30
+ parameters: {
31
+ type: 'object',
32
+ properties: {
33
+ prompt: {
34
+ type: 'string',
35
+ description: 'A detailed description of the image to generate',
36
+ },
37
+ },
38
+ required: ['prompt'],
39
+ },
40
+ });
41
+ }
42
+
43
+ const response = await super.generate(model, thread, functions, options);
44
+
45
+ // Check for image generation response
46
+ if (options.image_generation) {
47
+ const function_call = response[0].content.find(c => c.type === 'function');
48
+ if (function_call) {
49
+ const generation_call = function_call.content.find(f => f.name === 'generate_image');
50
+ if (generation_call) {
51
+ const response = await this.getOpenAi().images.generate({
52
+ model: 'grok-2-image',
53
+ prompt: generation_call.arguments.prompt,
54
+ });
55
+
56
+ function_call.type = 'image';
57
+ function_call.content = {
58
+ type: 'url',
59
+ mime: 'image/jpeg',
60
+ data: response.data[0].url,
61
+ };
62
+ }
63
+ }
64
+ }
65
+
66
+ return response;
67
+ }
24
68
  }
package/README.md CHANGED
@@ -129,15 +129,23 @@ async function main() {
129
129
 
130
130
  const emitter = await agent.message('Hello, who are you?');
131
131
 
132
- emitter.on('output', (content) => {
133
- process.stdout.write(content);
132
+ emitter.on('output', message => {
133
+ switch (message.type) {
134
+ case 'text':
135
+ process.stdout.write(message.content);
136
+ break;
137
+
138
+ case 'image':
139
+ // Process image
140
+ break;
141
+ }
134
142
  });
135
143
 
136
- emitter.on('error', (error) => {
144
+ emitter.on('error', error => {
137
145
  console.error(`\nAn error occurred: ${error.message}`);
138
146
  });
139
147
 
140
- emitter.on('tool', (tool) => {
148
+ emitter.on('tool', tool => {
141
149
  console.log(`\n> Using tool: ${tool.name} with arguments ${JSON.stringify(tool.arguments)}\n`);
142
150
  });
143
151
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "2.2.3",
4
+ "version": "2.3.0",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",