|
|
@@ -574,10 +574,14 @@ export function ChatActions(props: {
|
|
|
const [showPluginSelector, setShowPluginSelector] = useState(false);
|
|
|
const [showUploadImage, setShowUploadImage] = useState(false);
|
|
|
|
|
|
+ type GuessList = string[]
|
|
|
+ const [guessList, setGuessList] = useState<GuessList>([]);
|
|
|
+
|
|
|
const [showSizeSelector, setShowSizeSelector] = useState(false);
|
|
|
const dalle3Sizes: DalleSize[] = ["1024x1024", "1792x1024", "1024x1792"];
|
|
|
const currentSize =
|
|
|
chatStore.currentSession().mask.modelConfig?.size ?? "1024x1024";
|
|
|
+ const session = chatStore.currentSession();
|
|
|
|
|
|
useEffect(() => {
|
|
|
const show = isVisionModel(currentModel);
|
|
|
@@ -605,8 +609,67 @@ export function ChatActions(props: {
|
|
|
}
|
|
|
}, [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(() => {
|
|
|
+ const messages = session.messages.slice();
|
|
|
+ if (messages.length > 1) {
|
|
|
+ const backList = messages.reverse();
|
|
|
+ const item = backList.find(item => item.content && item.role === 'assistant')
|
|
|
+ if (!item) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fetchGuessList(item)
|
|
|
+ }
|
|
|
+ }, [session.messages]);
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles["chat-input-actions"]}>
|
|
|
+ {guessList.length > 0 && (
|
|
|
+ <div style={{ color: '#8096ca', fontSize: 13 }}>
|
|
|
+ <div>
|
|
|
+ 你还可以尝试提问:
|
|
|
+ </div>
|
|
|
+ <div style={{ display: 'flex', marginTop: 10, flexWrap: 'wrap' }}>
|
|
|
+ {
|
|
|
+ guessList.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ padding: '5px 10px',
|
|
|
+ background: '#f2f4f8',
|
|
|
+ borderRadius: 5,
|
|
|
+ margin: '0 10px 10px 0',
|
|
|
+ cursor: 'pointer',
|
|
|
+ }}
|
|
|
+ onClick={() => {
|
|
|
+ props.setUserInput(item);
|
|
|
+ }}
|
|
|
+ key={index}
|
|
|
+ >
|
|
|
+ {item}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
{/* {couldStop && (
|
|
|
<ChatAction
|
|
|
onClick={stopAll}
|
|
|
@@ -615,13 +678,13 @@ export function ChatActions(props: {
|
|
|
/>
|
|
|
)} */}
|
|
|
|
|
|
- {!props.hitBottom && (
|
|
|
+ {/* {!props.hitBottom && (
|
|
|
<ChatAction
|
|
|
onClick={props.scrollToBottom}
|
|
|
text={Locale.Chat.InputActions.ToBottom}
|
|
|
icon={<BottomIcon />}
|
|
|
/>
|
|
|
- )}
|
|
|
+ )} */}
|
|
|
|
|
|
{/* {props.hitBottom && (
|
|
|
<ChatAction
|
|
|
@@ -631,13 +694,13 @@ export function ChatActions(props: {
|
|
|
/>
|
|
|
)} */}
|
|
|
|
|
|
- {showUploadImage && (
|
|
|
+ {/* {showUploadImage && (
|
|
|
<ChatAction
|
|
|
onClick={props.uploadImage}
|
|
|
text={Locale.Chat.InputActions.UploadImage}
|
|
|
icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}
|
|
|
/>
|
|
|
- )}
|
|
|
+ )} */}
|
|
|
|
|
|
{/* <ChatAction
|
|
|
onClick={nextTheme}
|
|
|
@@ -911,7 +974,11 @@ function _Chat() {
|
|
|
const [appList, setAppList] = useState<AppList>([]);
|
|
|
const [appValue, setAppValue] = useState<string>();
|
|
|
const globalStore = useGlobalStore();
|
|
|
- type QuestionList = any[];
|
|
|
+ type QuestionList = {
|
|
|
+ key: string,
|
|
|
+ title: string,
|
|
|
+ content: string,
|
|
|
+ }[];
|
|
|
const [questionList, setQuestionList] = useState<QuestionList>([]);
|
|
|
const location = useLocation();
|
|
|
|
|
|
@@ -1845,12 +1912,12 @@ function _Chat() {
|
|
|
cursor: 'pointer'
|
|
|
}}
|
|
|
onClick={() => {
|
|
|
- setUserInput(item)
|
|
|
+ setUserInput(item.content)
|
|
|
}}
|
|
|
key={index}
|
|
|
>
|
|
|
<div>
|
|
|
- {item}
|
|
|
+ {item.title}
|
|
|
</div>
|
|
|
<RightOutlined />
|
|
|
</div>
|