Skip to content

Commit

Permalink
Updates example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrofelnik committed Jul 2, 2024
1 parent 40badf1 commit 5f66aff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
13 changes: 7 additions & 6 deletions examples/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ async function getNewMessages(
agentRunID: number,
currentMessagesCount: number
): Promise<Message[]> {
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;
Expand Down
13 changes: 7 additions & 6 deletions examples/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,17 @@ async function getNewMessages(
chatId: number,
currentMessagesCount: number
): Promise<Message[]> {
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;
Expand Down
4 changes: 2 additions & 2 deletions examples/chat_anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/chat_vision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);
}
Expand Down

0 comments on commit 5f66aff

Please sign in to comment.