From 00c45d305024301ffb4ec13e17ab5efadc6fe8e5 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 2 May 2023 14:49:40 +0800 Subject: [PATCH] feat(ai): add output apply --- .../com.msgbyte.ai-assistant/src/popover.tsx | 54 +++++++++++++------ .../com.msgbyte.ai-assistant/src/translate.ts | 4 ++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/client/web/plugins/com.msgbyte.ai-assistant/src/popover.tsx b/client/web/plugins/com.msgbyte.ai-assistant/src/popover.tsx index eab5ca86..509759af 100644 --- a/client/web/plugins/com.msgbyte.ai-assistant/src/popover.tsx +++ b/client/web/plugins/com.msgbyte.ai-assistant/src/popover.tsx @@ -5,6 +5,8 @@ import { LoadingSpinner, useChatInputActionContext, Tag, + Button, + Divider, } from '@capital/component'; import axios from 'axios'; import styled from 'styled-components'; @@ -40,7 +42,7 @@ const ActionButton = styled.div` export const AssistantPopover: React.FC<{ onCompleted: () => void; }> = React.memo((props) => { - const { message } = useChatInputActionContext(); + const { message, setMessage } = useChatInputActionContext(); const [{ loading, value }, handleCallAI] = useAsyncRequest( async (question: string) => { // TODO: wait for replace @@ -63,25 +65,43 @@ export const AssistantPopover: React.FC<{ return ( - {Translate.helpMeTo} -
- {typeof value === 'object' && - (value.result ? ( -
-
{value.answer}
- - {Translate.usage}: {value.usage}ms - -
- ) : ( -
-
{Translate.serviceBusy}
- {Translate.callError} -
- ))} + {typeof value === 'object' && ( + <> + {value.result ? ( +
+
{value.answer}
+
+ + {Translate.usage}: {value.usage}ms + + + +
+
+ ) : ( +
+
{Translate.serviceBusy}
+ {Translate.callError} +
+ )} + + + + )}
+ {Translate.helpMeTo} + {typeof message === 'string' && message.length > 0 && ( <>