Skip to content

Commit

Permalink
Fix title generation due to message format change
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitri Nasonov committed Jul 2, 2024
1 parent f222084 commit 834a271
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/components/Menu/ChatHistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
};
Expand Down
7 changes: 7 additions & 0 deletions src/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 834a271

Please sign in to comment.