From d2da2a3b7c324dcc59f23a79f1500a1a92fe2bec Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 1 Apr 2023 12:01:30 +0800 Subject: [PATCH] generate title in user's language fixes #178 --- src/hooks/useSubmit.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useSubmit.ts b/src/hooks/useSubmit.ts index 2701fd9..e80c43f 100644 --- a/src/hooks/useSubmit.ts +++ b/src/hooks/useSubmit.ts @@ -9,7 +9,7 @@ import { _defaultChatConfig } from '@constants/chat'; import { officialAPIEndpoint } from '@constants/auth'; const useSubmit = () => { - const { t } = useTranslation('api'); + const { t, i18n } = useTranslation('api'); const error = useStore((state) => state.error); const setError = useStore((state) => state.setError); const apiEndpoint = useStore((state) => state.apiEndpoint); @@ -156,7 +156,7 @@ const useSubmit = () => { const message: MessageInterface = { role: 'user', - content: `Generate a title in less than 6 words for the following message:\nUser: ${user_message}\nAssistant: ${assistant_message}`, + content: `Generate a title in less than 6 words for the following message (language: ${i18n.language}):\n"""\nUser: ${user_message}\nAssistant: ${assistant_message}\n"""`, }; let title = (await generateTitle([message])).trim();