|
@@ -589,75 +589,8 @@ export function ChatActions(props: {
|
|
|
}
|
|
}
|
|
|
}, [chatStore, currentModel, models]);
|
|
}, [chatStore, currentModel, models]);
|
|
|
|
|
|
|
|
- const fetchGuessList = async (record: ChatMessage) => {
|
|
|
|
|
- try {
|
|
|
|
|
- const data = {
|
|
|
|
|
- messages: [
|
|
|
|
|
- {
|
|
|
|
|
- content: record.content,
|
|
|
|
|
- role: record.role,
|
|
|
|
|
- }
|
|
|
|
|
- ]
|
|
|
|
|
- }
|
|
|
|
|
- const res = await api.post('/bigmodel/api/async/completions', data);
|
|
|
|
|
- setGuessList(res.data);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error(error);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- setGuessList([]);
|
|
|
|
|
- const messages = session.messages.slice();
|
|
|
|
|
- const backList = messages.reverse();
|
|
|
|
|
- const item = backList.find(item => item.content && item.role === 'assistant')
|
|
|
|
|
- if (item) {
|
|
|
|
|
- fetchGuessList(item)
|
|
|
|
|
- }
|
|
|
|
|
- }, [session.messages.length]);
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles["chat-input-actions"]}>
|
|
<div className={styles["chat-input-actions"]}>
|
|
|
- {/* <CallWord */}
|
|
|
|
|
- {/* setUserInput={props.setUserInput} */}
|
|
|
|
|
- {/* doSubmit={props.doSubmit} */}
|
|
|
|
|
- {/* /> */}
|
|
|
|
|
-
|
|
|
|
|
- {/* <ChatAction
|
|
|
|
|
- onClick={props.showPromptHints}
|
|
|
|
|
- text={Locale.Chat.InputActions.Prompt}
|
|
|
|
|
- icon={<PromptIcon />}
|
|
|
|
|
- /> */}
|
|
|
|
|
-
|
|
|
|
|
- {/* <ChatAction
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- navigate(Path.Masks);
|
|
|
|
|
- }}
|
|
|
|
|
- text={Locale.Chat.InputActions.Masks}
|
|
|
|
|
- icon={<MaskIcon />}
|
|
|
|
|
- /> */}
|
|
|
|
|
-
|
|
|
|
|
- {/* <ChatAction
|
|
|
|
|
- text={Locale.Chat.InputActions.Clear}
|
|
|
|
|
- icon={<BreakIcon />}
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- chatStore.updateCurrentSession((session) => {
|
|
|
|
|
- if (session.clearContextIndex === session.messages.length) {
|
|
|
|
|
- session.clearContextIndex = undefined;
|
|
|
|
|
- } else {
|
|
|
|
|
- session.clearContextIndex = session.messages.length;
|
|
|
|
|
- session.memoryPrompt = ""; // will clear memory
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }}
|
|
|
|
|
- /> */}
|
|
|
|
|
-
|
|
|
|
|
- {/* <ChatAction
|
|
|
|
|
- onClick={() => setShowModelSelector(true)}
|
|
|
|
|
- text={currentModelName}
|
|
|
|
|
- icon={<RobotIcon />}
|
|
|
|
|
- /> */}
|
|
|
|
|
-
|
|
|
|
|
{showModelSelector && (
|
|
{showModelSelector && (
|
|
|
<Selector
|
|
<Selector
|
|
|
defaultSelectedValue={`${currentModel}@${currentProviderName}`}
|
|
defaultSelectedValue={`${currentModel}@${currentProviderName}`}
|
|
@@ -718,12 +651,6 @@ export function ChatActions(props: {
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
- {/* <ChatAction
|
|
|
|
|
- onClick={() => setShowPluginSelector(true)}
|
|
|
|
|
- text={Locale.Plugin.Name}
|
|
|
|
|
- icon={<PluginIcon />}
|
|
|
|
|
- /> */}
|
|
|
|
|
-
|
|
|
|
|
{showPluginSelector && (
|
|
{showPluginSelector && (
|
|
|
<Selector
|
|
<Selector
|
|
|
multiple
|
|
multiple
|
|
@@ -878,67 +805,6 @@ function _Chat() {
|
|
|
const [questionList, setQuestionList] = useState<QuestionList>([]);
|
|
const [questionList, setQuestionList] = useState<QuestionList>([]);
|
|
|
const location = useLocation();
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
- // 获取应用列表
|
|
|
|
|
- const fetchApplicationList = async () => {
|
|
|
|
|
- setLoading(true);
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await api.get('/bigmodel/api/application/list');
|
|
|
|
|
- const list = res.data.filter((item: any) => item.appId !== '1234567890123456789').map((item: any) => {
|
|
|
|
|
- return {
|
|
|
|
|
- label: item.name,
|
|
|
|
|
- value: item.appId,
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- setAppList(list);
|
|
|
|
|
- let appValue = '';
|
|
|
|
|
- const search = location.search;
|
|
|
|
|
- if (search.startsWith('?appId=')) {
|
|
|
|
|
- const value = search.slice(7);
|
|
|
|
|
- if (list.find((item: any) => item.value === value)) {
|
|
|
|
|
- appValue = value;
|
|
|
|
|
- } else {
|
|
|
|
|
- appValue = list[0]?.value;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- appValue = list[0]?.value;
|
|
|
|
|
- }
|
|
|
|
|
- setAppValue(appValue);
|
|
|
|
|
- globalStore.setSelectedAppId(appValue);
|
|
|
|
|
- chatStore.updateCurrentSession((session) => {
|
|
|
|
|
- session.appId = appValue;
|
|
|
|
|
- });
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error(error);
|
|
|
|
|
- } finally {
|
|
|
|
|
- setLoading(false);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取预设问题列表
|
|
|
|
|
- const fetchDefaultQuestion = async (appId: string) => {
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await api.get(`/bigmodel/api/presets/${appId}`);
|
|
|
|
|
- setQuestionList(res.data);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error(error);
|
|
|
|
|
- } finally {
|
|
|
|
|
- setLoading(false);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const init = async () => {
|
|
|
|
|
- await fetchApplicationList();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- init();
|
|
|
|
|
- }, [])
|
|
|
|
|
-
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- if (appValue) {
|
|
|
|
|
- fetchDefaultQuestion(appValue);
|
|
|
|
|
- }
|
|
|
|
|
- }, [appValue])
|
|
|
|
|
|
|
|
|
|
const [inputRows, setInputRows] = useState(2);
|
|
const [inputRows, setInputRows] = useState(2);
|
|
|
const measure = useDebouncedCallback(
|
|
const measure = useDebouncedCallback(
|
|
@@ -1566,7 +1432,7 @@ function _Chat() {
|
|
|
<textarea
|
|
<textarea
|
|
|
id="chat-input"
|
|
id="chat-input"
|
|
|
ref={inputRef}
|
|
ref={inputRef}
|
|
|
- className={styles["chat-input"]}
|
|
|
|
|
|
|
+ className={styles["chat-input2"]}
|
|
|
placeholder={Locale.Chat.Input(submitKey)}
|
|
placeholder={Locale.Chat.Input(submitKey)}
|
|
|
onInput={(e) => onInput(e.currentTarget.value)}
|
|
onInput={(e) => onInput(e.currentTarget.value)}
|
|
|
value={userInput}
|
|
value={userInput}
|