Commit 83855626 authored by Travis Fischer's avatar Travis Fischer

fix: conversation support

parent d2cd6f81
...@@ -102,6 +102,7 @@ export async function browserPostEventStream( ...@@ -102,6 +102,7 @@ export async function browserPostEventStream(
const BOM = [239, 187, 191] const BOM = [239, 187, 191]
let conversationResponse: types.ConversationResponseEvent
let conversationId: string = body?.conversation_id let conversationId: string = body?.conversation_id
let messageId: string = body?.messages?.[0]?.id let messageId: string = body?.messages?.[0]?.id
let response = '' let response = ''
...@@ -149,21 +150,25 @@ export async function browserPostEventStream( ...@@ -149,21 +150,25 @@ export async function browserPostEventStream(
error: null, error: null,
response, response,
conversationId, conversationId,
messageId messageId,
conversationResponse
}) })
} }
try { try {
const parsedData: types.ConversationResponseEvent = JSON.parse(data) const convoResponseEvent: types.ConversationResponseEvent =
if (parsedData.conversation_id) { JSON.parse(data)
conversationId = parsedData.conversation_id conversationResponse = convoResponseEvent
if (convoResponseEvent.conversation_id) {
conversationId = convoResponseEvent.conversation_id
} }
if (parsedData.message?.id) { if (convoResponseEvent.message?.id) {
messageId = parsedData.message.id messageId = convoResponseEvent.message.id
} }
const partialResponse = parsedData.message?.content?.parts?.[0] const partialResponse =
convoResponseEvent.message?.content?.parts?.[0]
if (partialResponse) { if (partialResponse) {
response = partialResponse response = partialResponse
} }
...@@ -218,7 +223,8 @@ export async function browserPostEventStream( ...@@ -218,7 +223,8 @@ export async function browserPostEventStream(
error: null, error: null,
response, response,
conversationId, conversationId,
messageId messageId,
conversationResponse
} }
} }
...@@ -230,7 +236,8 @@ export async function browserPostEventStream( ...@@ -230,7 +236,8 @@ export async function browserPostEventStream(
}, },
response: null, response: null,
conversationId, conversationId,
messageId messageId,
conversationResponse
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment