🚸 (openai) Display OpenAI initial response error
This commit is contained in:
@@ -52,5 +52,7 @@ export const getChatCompletionStream =
|
|||||||
messages,
|
messages,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!response.ok) return response
|
||||||
|
|
||||||
return OpenAIStream(response)
|
return OpenAIStream(response)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,15 +60,24 @@ const handler = async (req: Request) => {
|
|||||||
)
|
)
|
||||||
return new Response('Current block is not an OpenAI block', { status: 400 })
|
return new Response('Current block is not an OpenAI block', { status: 400 })
|
||||||
|
|
||||||
const stream = await getChatCompletionStream(conn)(
|
const streamOrResponse = await getChatCompletionStream(conn)(
|
||||||
state,
|
state,
|
||||||
block.options,
|
block.options,
|
||||||
messages
|
messages
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!stream) return new Response('Could not create stream', { status: 400 })
|
if (!streamOrResponse)
|
||||||
|
return new Response('Could not create stream', { status: 400 })
|
||||||
|
|
||||||
return new StreamingTextResponse(stream, {
|
if ('ok' in streamOrResponse)
|
||||||
|
return new Response(streamOrResponse.body, {
|
||||||
|
status: streamOrResponse.status,
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return new StreamingTextResponse(streamOrResponse, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ export const ConversationContainer = (props: Props) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const streamMessage = (content: string) => {
|
const streamMessage = (content: string) => {
|
||||||
|
console.log('STREAM', content)
|
||||||
setIsSending(false)
|
setIsSending(false)
|
||||||
const lastChunk = [...chatChunks()].pop()
|
const lastChunk = [...chatChunks()].pop()
|
||||||
if (!lastChunk) return
|
if (!lastChunk) return
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ export const streamChat =
|
|||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return {
|
return {
|
||||||
error: {
|
error: (await res.json()) || 'Failed to fetch the chat response.',
|
||||||
message: (await res.text()) || 'Failed to fetch the chat response.',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user