Skip to content

Commit

Permalink
fix: ask widget use default engine
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Apr 17, 2024
1 parent 9d522eb commit bca050e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/api/v1/chats/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const POST = defineHandler({
messages
} = body;

const [engine, engineOptions] = await getChatEngineConfig(body.engine);

// TODO: need refactor, it is too complex now
// For chat page, create a chat and return the session ID (url_key) first.
const creatingChat = messages.length === 0;
Expand All @@ -54,9 +56,8 @@ export const POST = defineHandler({
return CHAT_CAN_NOT_ASSIGN_SESSION_ID_ERROR;
}

const [engine, engineOptions] = await getChatEngineConfig(body.engine);
return await createChat({
engine: engine,
engine,
engine_options: JSON.stringify(engineOptions),
created_at: new Date(),
created_by: userId,
Expand All @@ -68,8 +69,8 @@ export const POST = defineHandler({
let sessionId = body.sessionId;
if (!sessionId) {
const chat = await createChat({
engine: 'condense-question',
engine_options: JSON.stringify({}),
engine,
engine_options: JSON.stringify(engineOptions),
created_at: new Date(),
created_by: userId,
title: body.name ?? body.messages.findLast(message => message.role === 'user')?.content ?? DEFAULT_CHAT_TITLE,
Expand Down

0 comments on commit bca050e

Please sign in to comment.