fix: variable label i18n & create question guide language (#2933)

This commit is contained in:
heheer 2024-10-16 14:21:53 +08:00 committed by GitHub
parent 8bdb35ff51
commit d45d18cc3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -4,11 +4,15 @@ import { countGptMessagesTokens } from '../../../common/string/tiktoken/index';
import { loadRequestMessages } from '../../chat/utils';
import { llmCompletionsBodyFormat } from '../utils';
export const Prompt_QuestionGuide = `你是一个AI智能助手你的任务是结合对话记录推测我下一步的问题。
3
1.
2. 20
3. JSON : ["question1", "question2", "question3"]`;
export const Prompt_QuestionGuide = `You are an AI assistant tasked with predicting the user's next question based on the conversation history. Your goal is to generate 3 potential questions that will guide the user to continue the conversation. When generating these questions, adhere to the following rules:
1. Use the same language as the user's last question in the conversation history.
2. Keep each question under 20 characters in length.
3. Return the questions in JSON format: ["question1", "question2", "question3"].
Analyze the conversation history provided to you and use it as context to generate relevant and engaging follow-up questions. Your predictions should be logical extensions of the current topic or related areas that the user might be interested in exploring further.
Remember to maintain consistency in tone and style with the existing conversation while providing diverse options for the user to choose from. Your goal is to keep the conversation flowing naturally and help the user delve deeper into the subject matter or explore related topics.`;
export async function createQuestionGuide({
messages,

View File

@ -6,6 +6,7 @@ import { TextNode } from 'lexical';
import { getHashtagRegexString } from './utils';
import { mergeRegister } from '@lexical/utils';
import { registerLexicalTextEntity } from '../../utils';
import { useTranslation } from 'react-i18next';
const REGEX = new RegExp(getHashtagRegexString(), 'i');
@ -14,6 +15,7 @@ export default function VariableLabelPlugin({
}: {
variables: EditorVariableLabelPickerType[];
}) {
const { t } = useTranslation();
const [editor] = useLexicalComposerContext();
useEffect(() => {
if (!editor.hasNodes([VariableLabelNode]))
@ -25,7 +27,7 @@ export default function VariableLabelPlugin({
const currentVariable = variables.find(
(item) => item.parent.id === parentKey && item.key === childrenKey
);
const variableLabel = `${currentVariable && currentVariable.parent?.label}.${currentVariable?.label}`;
const variableLabel = `${currentVariable && t(currentVariable.parent?.label as any)}.${currentVariable?.label}`;
const nodeAvatar = currentVariable?.parent?.avatar || '';
return $createVariableLabelNode(textNode.getTextContent(), variableLabel, nodeAvatar);
}, []);