kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: conversation support
rodzic
d2cd6f8162
commit
83855626d9
25
src/utils.ts
25
src/utils.ts
|
@ -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(
|
||||||
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(
|
||||||
error: null,
|
error: null,
|
||||||
response,
|
response,
|
||||||
conversationId,
|
conversationId,
|
||||||
messageId
|
messageId,
|
||||||
|
conversationResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +236,8 @@ export async function browserPostEventStream(
|
||||||
},
|
},
|
||||||
response: null,
|
response: null,
|
||||||
conversationId,
|
conversationId,
|
||||||
messageId
|
messageId,
|
||||||
|
conversationResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue