From 834a2714610602728bf77823797d92646c153191 Mon Sep 17 00:00:00 2001 From: Dmitri Nasonov Date: Wed, 3 Jul 2024 00:45:51 +0100 Subject: [PATCH] Fix title generation due to message format change --- src/components/Menu/ChatHistoryList.tsx | 11 ++--------- src/hooks/useSubmit.ts | 4 +++- src/types/chat.ts | 7 +++++++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/Menu/ChatHistoryList.tsx b/src/components/Menu/ChatHistoryList.tsx index 232a325da..04fe2b432 100644 --- a/src/components/Menu/ChatHistoryList.tsx +++ b/src/components/Menu/ChatHistoryList.tsx @@ -11,17 +11,10 @@ import { ChatHistoryFolderInterface, ChatInterface, FolderCollection, - ImageContentInterface, - TextContentInterface, - ContentInterface, + isImageContent, + isTextContent, } from '@type/chat'; -function isTextContent(ob: ContentInterface): ob is TextContentInterface { - return (ob as TextContentInterface).text !== undefined; -} -function isImageContent(ob: ContentInterface): ob is ImageContentInterface { - return (ob as ImageContentInterface).image_url !== undefined; -} const ChatHistoryList = () => { const currentChatIndex = useStore((state) => state.currentChatIndex); const displayChatSize = useStore((state) => state.displayChatSize); diff --git a/src/hooks/useSubmit.ts b/src/hooks/useSubmit.ts index a8c6a7d05..3eb37696a 100644 --- a/src/hooks/useSubmit.ts +++ b/src/hooks/useSubmit.ts @@ -197,9 +197,11 @@ const useSubmit = () => { const message: MessageInterface = { role: 'user', content: [ + ...user_message, + ...assistant_message, { type: 'text', - text: `Generate a title in less than 6 words for the following message (language: ${i18n.language}):\n"""\nUser: ${user_message}\nAssistant: ${assistant_message}\n"""`, + text: `Generate a title in less than 6 words for the conversation so far (language: ${i18n.language})`, } as TextContentInterface, ], }; diff --git a/src/types/chat.ts b/src/types/chat.ts index e6b975a3b..b5d6da766 100644 --- a/src/types/chat.ts +++ b/src/types/chat.ts @@ -22,6 +22,13 @@ export interface TextContentInterface extends ContentInterface { text: string; } +export function isTextContent(ob: ContentInterface): ob is TextContentInterface { + return (ob as TextContentInterface).text !== undefined; +} +export function isImageContent(ob: ContentInterface): ob is ImageContentInterface { + return (ob as ImageContentInterface).image_url !== undefined; +} + export interface ContentInterface { [x: string]: any; type: Content;