mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-03 01:54:44 +00:00
feat: UI component rendering in agent dialog mode (#1083)
Co-authored-by: csunny <cfqsunny@163.com>
This commit is contained in:
@@ -16,10 +16,10 @@ interface IChatContext {
|
||||
model: string;
|
||||
dbParam?: string;
|
||||
modelList: Array<string>;
|
||||
agentList: string[];
|
||||
agent: string;
|
||||
dialogueList?: DialogueListResponse;
|
||||
setAgent?: (val: string) => void;
|
||||
setMode: (mode: ThemeMode) => void;
|
||||
setAgentList?: (val: string[]) => void;
|
||||
setModel: (val: string) => void;
|
||||
setIsContract: (val: boolean) => void;
|
||||
setIsMenuExpand: (val: boolean) => void;
|
||||
@@ -47,8 +47,8 @@ const ChatContext = createContext<IChatContext>({
|
||||
model: '',
|
||||
dbParam: undefined,
|
||||
dialogueList: [],
|
||||
agentList: [],
|
||||
setAgentList: () => {},
|
||||
agent: '',
|
||||
setAgent: () => {},
|
||||
setModel: () => {},
|
||||
setIsContract: () => {},
|
||||
setIsMenuExpand: () => {},
|
||||
@@ -72,7 +72,7 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
|
||||
const [model, setModel] = useState<string>('');
|
||||
const [isMenuExpand, setIsMenuExpand] = useState<boolean>(scene !== 'chat_dashboard');
|
||||
const [dbParam, setDbParam] = useState<string>(db_param);
|
||||
const [agentList, setAgentList] = useState<string[]>([]);
|
||||
const [agent, setAgent] = useState<string>('');
|
||||
const [history, setHistory] = useState<ChatHistoryResponse>([]);
|
||||
const [docId, setDocId] = useState<number>();
|
||||
const [mode, setMode] = useState<ThemeMode>('light');
|
||||
@@ -91,6 +91,13 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (dialogueList.length && scene === 'chat_agent') {
|
||||
const agent = dialogueList.find((item) => item.conv_uid === chatId)?.select_param;
|
||||
agent && setAgent(agent);
|
||||
}
|
||||
}, [dialogueList, scene, chatId]);
|
||||
|
||||
const { data: modelList = [] } = useRequest(async () => {
|
||||
const [, res] = await apiInterceptors(getUsableModels());
|
||||
return res ?? [];
|
||||
@@ -114,10 +121,10 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
|
||||
model,
|
||||
dbParam: dbParam || db_param,
|
||||
dialogueList,
|
||||
agentList,
|
||||
agent,
|
||||
setAgent,
|
||||
mode,
|
||||
setMode,
|
||||
setAgentList,
|
||||
setModel,
|
||||
setIsContract,
|
||||
setIsMenuExpand,
|
||||
|
@@ -179,12 +179,15 @@ const en = {
|
||||
Retry: 'Retry',
|
||||
Load_more: 'load more',
|
||||
new_chat: 'New Chat',
|
||||
choice_agent_tip: 'Please choose an agent',
|
||||
no_context_tip: 'Please enter your question',
|
||||
Terminal: 'Terminal',
|
||||
} as const;
|
||||
|
||||
type I18nKeys = keyof typeof en;
|
||||
export type I18nKeys = keyof typeof en;
|
||||
|
||||
export interface Resources {
|
||||
translation: Record<I18nKeys, string> & { [key: string]: string };
|
||||
translation: Record<I18nKeys, string>;
|
||||
}
|
||||
|
||||
const zh: Resources['translation'] = {
|
||||
@@ -364,6 +367,9 @@ const zh: Resources['translation'] = {
|
||||
Retry: '重试',
|
||||
Load_more: '加载更多',
|
||||
new_chat: '创建会话',
|
||||
choice_agent_tip: '请选择代理',
|
||||
no_context_tip: '请输入你的问题',
|
||||
Terminal: '终端',
|
||||
} as const;
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
|
Reference in New Issue
Block a user