symposium 2.4.2 → 3.0.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 +509 -219
- package/CLAUDE.md +101 -0
- package/Contexts/MCPResource.js +19 -0
- package/{GetContextTool.js → GetContextToolkit.js} +5 -5
- package/InputChannel.js +42 -0
- package/MCPServer.js +160 -0
- package/MIGRATION.md +369 -0
- package/Model.js +32 -25
- package/Models/AnthropicModel.js +66 -20
- package/Models/GrokModel.js +8 -8
- package/Models/GroqModel.js +61 -35
- package/Models/LegacyOpenAIModel.js +61 -35
- package/Models/OllamaModel.js +57 -31
- package/Models/OpenAIModel.js +74 -20
- package/README.md +458 -396
- package/Summarizer.js +5 -5
- package/Symposium.js +12 -12
- package/{Tool.js → Toolkit.js} +4 -4
- package/index.js +10 -2
- package/package.json +7 -3
- package/test/agent.test.js +698 -0
- package/test/helpers/mockSdk.js +52 -0
- package/test/mcp.test.js +216 -0
- package/test/models/anthropic.test.js +135 -0
- package/test/models/groq.test.js +71 -0
- package/test/models/legacyOpenai.test.js +87 -0
- package/test/models/ollama.test.js +90 -0
- package/test/models/openai.test.js +168 -0
- package/BufferedEventEmitter.js +0 -28
package/Summarizer.js
CHANGED
|
@@ -57,7 +57,7 @@ export default class Summarizer extends ContextHandler {
|
|
|
57
57
|
async doSummarize(thread, maxLength) {
|
|
58
58
|
thread.addMessage('system', 'Summarize the conversation up to this moment.');
|
|
59
59
|
const summary = await this.agent.generateCompletion(thread, {
|
|
60
|
-
|
|
60
|
+
tools: [
|
|
61
61
|
{
|
|
62
62
|
name: 'summarize',
|
|
63
63
|
description: 'Generate a summary of the conversation in ' + Math.round(maxLength / 2) + ' words at most, in a way that it is easy for you to keep track of the important info. Do not omit relevant information you need to remember in order to continue the conversation.',
|
|
@@ -72,7 +72,7 @@ export default class Summarizer extends ContextHandler {
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
],
|
|
75
|
-
|
|
75
|
+
force_tool: 'summarize',
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
if (!summary)
|
|
@@ -83,11 +83,11 @@ export default class Summarizer extends ContextHandler {
|
|
|
83
83
|
if (message.role === 'system' && !message.tags.includes('summary')) {
|
|
84
84
|
summarizedThread.messages.push(message);
|
|
85
85
|
} else {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
86
|
+
const toolCallsResponse = Symposium.extractToolCallsFromResponse(summary);
|
|
87
|
+
if (toolCallsResponse.length)
|
|
88
88
|
throw new Error('Errore durante la generazione di un riassunto interno');
|
|
89
89
|
|
|
90
|
-
summarizedThread.addMessage('system', "This is what happened until now:\n" +
|
|
90
|
+
summarizedThread.addMessage('system', "This is what happened until now:\n" + toolCallsResponse[0].summary, undefined, ['summary']);
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
93
|
}
|
package/Symposium.js
CHANGED
|
@@ -56,19 +56,19 @@ export default class Symposium {
|
|
|
56
56
|
return this.models.get(name);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
static
|
|
60
|
-
const
|
|
59
|
+
static extractToolCallsFromResponse(messages) {
|
|
60
|
+
const tool_calls = [];
|
|
61
61
|
for (let message of messages) {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
for (let
|
|
65
|
-
for (let r of
|
|
66
|
-
|
|
62
|
+
const toolBlocks = message.content.filter(c => c.type === 'tool_call');
|
|
63
|
+
if (toolBlocks.length) {
|
|
64
|
+
for (let t of toolBlocks) {
|
|
65
|
+
for (let r of t.content)
|
|
66
|
+
tool_calls.push(r.arguments);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
return
|
|
71
|
+
return tool_calls;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
static async transcribe(audio, prompt = null, model = null) {
|
|
@@ -138,9 +138,8 @@ export default class Symposium {
|
|
|
138
138
|
static async prompt(system, prompt, options = {}) {
|
|
139
139
|
const agent = new Agent(options.agent || {});
|
|
140
140
|
agent.type = 'utility';
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
141
|
+
if (options.response_schema)
|
|
142
|
+
agent.response_schema = options.response_schema;
|
|
144
143
|
|
|
145
144
|
agent.doInitThread = async thread => {
|
|
146
145
|
if (options.model)
|
|
@@ -150,6 +149,7 @@ export default class Symposium {
|
|
|
150
149
|
|
|
151
150
|
await agent.init();
|
|
152
151
|
const thread = await agent.getThread();
|
|
153
|
-
|
|
152
|
+
|
|
153
|
+
return await agent.message(prompt, thread);
|
|
154
154
|
}
|
|
155
155
|
}
|
package/{Tool.js → Toolkit.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Toolkit {
|
|
2
2
|
name = '';
|
|
3
3
|
|
|
4
4
|
async init(agent) {
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
async
|
|
7
|
+
async getTools() {
|
|
8
8
|
return [];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
async
|
|
12
|
-
return {error: '
|
|
11
|
+
async callTool(thread, name, payload) {
|
|
12
|
+
return {error: 'callTool is yet to be implemented'};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async authorize(thread, name, payload) {
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Symposium from "./Symposium.js";
|
|
4
4
|
import Agent from "./Agent.js";
|
|
5
5
|
import Thread from "./Thread.js";
|
|
6
|
-
import
|
|
6
|
+
import Toolkit from "./Toolkit.js";
|
|
7
7
|
import Logger from "./Logger.js";
|
|
8
8
|
|
|
9
9
|
import ContextHandler from "./ContextHandler.js";
|
|
@@ -12,16 +12,24 @@ import Summarizer from "./Summarizer.js";
|
|
|
12
12
|
import Context from "./Context.js";
|
|
13
13
|
import File from "./Contexts/File.js";
|
|
14
14
|
import Text from "./Contexts/Text.js";
|
|
15
|
+
import MCPResource from "./Contexts/MCPResource.js";
|
|
16
|
+
|
|
17
|
+
import MCPServer from "./MCPServer.js";
|
|
18
|
+
|
|
19
|
+
import {createInputChannel} from "./InputChannel.js";
|
|
15
20
|
|
|
16
21
|
export {
|
|
17
22
|
Symposium,
|
|
18
23
|
Agent,
|
|
19
24
|
Thread,
|
|
20
|
-
|
|
25
|
+
Toolkit,
|
|
21
26
|
Logger,
|
|
22
27
|
ContextHandler,
|
|
23
28
|
Summarizer,
|
|
24
29
|
Context,
|
|
25
30
|
File,
|
|
26
31
|
Text,
|
|
32
|
+
MCPServer,
|
|
33
|
+
MCPResource,
|
|
34
|
+
createInputChannel,
|
|
27
35
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "symposium",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"description": "Agents",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "Domenico Giambra",
|
|
8
8
|
"license": "ISC",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --test \"test/**/*.test.js\""
|
|
11
|
+
},
|
|
9
12
|
"dependencies": {
|
|
10
|
-
"@anthropic-ai/sdk": "^0.
|
|
13
|
+
"@anthropic-ai/sdk": "^0.98.0",
|
|
14
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
11
15
|
"groq-sdk": "^1.0.0",
|
|
12
16
|
"ollama": "^0.6.0",
|
|
13
17
|
"openai": "^6.0.0",
|
|
14
18
|
"tiktoken": "^1.0.10",
|
|
15
|
-
"uuid": "^
|
|
19
|
+
"uuid": "^14.0.0"
|
|
16
20
|
}
|
|
17
21
|
}
|