Add question guide config (#3403)

* feat:Prompt task (#3337)

* feat:猜你想问自定义功能

* 修改用户输入框部分,去除冗余代码

* 删除不必要的属性

* 删除多余内容

* 修正了格式问题,并实现获取调试和app最新参数

* 修正了几行代码

* feat:Prompt task (#3337)

* feat:猜你想问自定义功能

* 修改用户输入框部分,去除冗余代码

* 删除不必要的属性

* 删除多余内容

* 修正了格式问题,并实现获取调试和app最新参数

* 修正了几行代码

* perf: question gudide code

* fix: i18n

* hunyuan logo

* fix: cq templates

* perf: create question guide code

* udpate svg

---------

Co-authored-by: Jiangween <145003935+Jiangween@users.noreply.github.com>
This commit is contained in:
Archer
2024-12-16 13:49:31 +08:00
committed by GitHub
parent 76d20b2b76
commit bfac393ab1
50 changed files with 775 additions and 397 deletions

View File

@@ -65,3 +65,13 @@ export const Prompt_CQJson = `请帮我执行一个“问题分类”任务,
问题:"{{question}}"
类型ID=
`;
export const PROMPT_QUESTION_GUIDE = `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.
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 const PROMPT_QUESTION_GUIDE_FOOTER = `Please strictly follow the format rules: \nReturn questions in JSON format: ['Question 1', 'Question 2', 'Question 3']. Your output: `;

View File

@@ -1,8 +1,10 @@
import { PROMPT_QUESTION_GUIDE } from '../ai/prompt/agent';
import {
AppTTSConfigType,
AppFileSelectConfigType,
AppWhisperConfigType,
AppAutoExecuteConfigType
AppAutoExecuteConfigType,
AppQGConfigType
} from './type';
export enum AppTypeEnum {
@@ -28,6 +30,12 @@ export const defaultWhisperConfig: AppWhisperConfigType = {
autoTTSResponse: false
};
export const defaultQGConfig: AppQGConfigType = {
open: false,
model: 'gpt-4o-mini',
customPrompt: PROMPT_QUESTION_GUIDE
};
export const defaultChatInputGuideConfig = {
open: false,
textList: [],

View File

@@ -97,7 +97,7 @@ export type AppChatConfigType = {
welcomeText?: string;
variables?: VariableItemType[];
autoExecute?: AppAutoExecuteConfigType;
questionGuide?: boolean;
questionGuide?: AppQGConfigType;
ttsConfig?: AppTTSConfigType;
whisperConfig?: AppWhisperConfigType;
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
@@ -148,6 +148,14 @@ export type AppWhisperConfigType = {
autoSend: boolean;
autoTTSResponse: boolean;
};
// question guide
export type AppQGConfigType = {
open: boolean;
model?: string;
customPrompt?: string;
};
// question guide text
export type ChatInputGuideConfigType = {
open: boolean;

View File

@@ -26,12 +26,14 @@ import type {
AppScheduledTriggerConfigType,
ChatInputGuideConfigType,
AppChatConfigType,
AppAutoExecuteConfigType
AppAutoExecuteConfigType,
AppQGConfigType
} from '../app/type';
import { EditorVariablePickerType } from '../../../web/components/common/Textarea/PromptEditor/type';
import {
defaultAutoExecuteConfig,
defaultChatInputGuideConfig,
defaultQGConfig,
defaultTTSConfig,
defaultWhisperConfig
} from '../app/constants';
@@ -76,9 +78,14 @@ export const splitGuideModule = (guideModules?: StoreNodeItemType) => {
const variables: VariableItemType[] =
guideModules?.inputs.find((item) => item.key === NodeInputKeyEnum.variables)?.value ?? [];
const questionGuide: boolean =
!!guideModules?.inputs?.find((item) => item.key === NodeInputKeyEnum.questionGuide)?.value ??
false;
// Adapt old version
const questionGuideVal = guideModules?.inputs?.find(
(item) => item.key === NodeInputKeyEnum.questionGuide
)?.value;
const questionGuide: AppQGConfigType =
typeof questionGuideVal === 'boolean'
? { ...defaultQGConfig, open: questionGuideVal }
: questionGuideVal ?? defaultQGConfig;
const ttsConfig: AppTTSConfigType =
guideModules?.inputs?.find((item) => item.key === NodeInputKeyEnum.tts)?.value ??