backend: implement agents and connect them with chats
This commit is contained in:
1 parent
e57e5ba16a
commit
49df72f2a1
9 files changed
+313
-40
No files matched your search
+32
-14
@@ -1,10 +1,10 @@
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const ws = new WebSocket('ws://localhost:5000/ws');
|
||||
const USE_LLM = false;
|
||||
|
||||
const ws = new WebSocket('ws://localhost:5000/ws');
|
||||
var nonceCounter = 1;
|
||||
var nonceCallbacks = {};
|
||||
|
||||
var messageQueue = [];
|
||||
var messageResolverQueue = [];
|
||||
|
||||
@@ -73,9 +73,18 @@ async function runTest() {
|
||||
}})
|
||||
);
|
||||
|
||||
console.log("Get Agents",
|
||||
await send('get-agents')
|
||||
);
|
||||
let agents = (await send('get-agents')).agents;
|
||||
console.log("Get Agents", agents);
|
||||
|
||||
if (USE_LLM) {
|
||||
let promptResponse = await send('send-agent-prompt', {
|
||||
body: {
|
||||
agentId: agents[0].id,
|
||||
content: "Hello World!",
|
||||
}
|
||||
});
|
||||
console.log("Prompt Response", promptResponse);
|
||||
}
|
||||
|
||||
await testChats();
|
||||
|
||||
@@ -86,14 +95,23 @@ async function testChats () {
|
||||
let response = await send('get-chats')
|
||||
let chat = response.chats[0];
|
||||
|
||||
let msgRes = await send('send-chat-message', {
|
||||
body: {
|
||||
chatId: chat.id,
|
||||
content: "Hello World!",
|
||||
}
|
||||
});
|
||||
console.log('message sent', msgRes);
|
||||
if (USE_LLM) {
|
||||
let msgRes = await send('send-chat-message', {
|
||||
body: {
|
||||
chatId: chat.id,
|
||||
content: "Whats up!",
|
||||
}
|
||||
});
|
||||
console.log('message sent', msgRes);
|
||||
console.log('Incoming:', await waitMessage());
|
||||
|
||||
let nextMessage = await waitMessage();
|
||||
console.log('next incoming message', nextMessage);
|
||||
// Multi turn conversation
|
||||
await send('send-chat-message', {
|
||||
body: {
|
||||
chatId: chat.id,
|
||||
content: "Spell the initials of my first message.",
|
||||
}
|
||||
});
|
||||
console.log('Incoming:', await waitMessage());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user