From 5f66aff967888ced92e9ef1c97bf8bdbaf4f9537 Mon Sep 17 00:00:00 2001 From: kgrofelnik Date: Tue, 2 Jul 2024 14:55:27 +0200 Subject: [PATCH] Updates example scripts --- examples/agent.ts | 13 +++++++------ examples/chat.ts | 13 +++++++------ examples/chat_anthropic.ts | 4 ++-- examples/chat_vision.ts | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/agent.ts b/examples/agent.ts index 8b18f54..f05bc2c 100644 --- a/examples/agent.ts +++ b/examples/agent.ts @@ -112,16 +112,17 @@ async function getNewMessages( agentRunID: number, currentMessagesCount: number ): Promise { - const messages = await contract.getMessageHistoryContents(agentRunID) - const roles = await contract.getMessageHistoryRoles(agentRunID) + const messages = await contract.getMessageHistory(agentRunID) const newMessages: Message[] = [] messages.forEach((message: any, i: number) => { if (i >= currentMessagesCount) { - newMessages.push({ - role: roles[i], - content: messages[i] - }) + newMessages.push( + { + role: message.role, + content: message.content[0].value, + } + ); } }) return newMessages; diff --git a/examples/chat.ts b/examples/chat.ts index 592dd28..78a3eba 100644 --- a/examples/chat.ts +++ b/examples/chat.ts @@ -107,16 +107,17 @@ async function getNewMessages( chatId: number, currentMessagesCount: number ): Promise { - const messages = await contract.getMessageHistoryContents(chatId) - const roles = await contract.getMessageHistoryRoles(chatId) + const messages = await contract.getMessageHistory(chatId) const newMessages: Message[] = [] messages.forEach((message: any, i: number) => { if (i >= currentMessagesCount) { - newMessages.push({ - role: roles[i], - content: messages[i] - }) + newMessages.push( + { + role: message[0], + content: message.content[0].value, + } + ); } }) return newMessages; diff --git a/examples/chat_anthropic.ts b/examples/chat_anthropic.ts index 3a3aa1b..2587b7e 100644 --- a/examples/chat_anthropic.ts +++ b/examples/chat_anthropic.ts @@ -121,8 +121,8 @@ async function getNewMessages( if (i >= currentMessagesCount) { newMessages.push( { - role: message[0], - content: message[1][0][1], + role: message.role, + content: message.content[0].value, } ); } diff --git a/examples/chat_vision.ts b/examples/chat_vision.ts index 2ea21f4..08bd042 100644 --- a/examples/chat_vision.ts +++ b/examples/chat_vision.ts @@ -122,8 +122,8 @@ async function getNewMessages( if (i >= currentMessagesCount) { newMessages.push( { - role: message[0], - content: message[1][0][1], + role: message.role, + content: message.content[0].value, } ); }