diff --git a/web/components/core/modals/gpt-assistant-popover.tsx b/web/components/core/modals/gpt-assistant-popover.tsx index a67b13f7e..203855f76 100644 --- a/web/components/core/modals/gpt-assistant-popover.tsx +++ b/web/components/core/modals/gpt-assistant-popover.tsx @@ -17,7 +17,9 @@ type Props = { isOpen: boolean; projectId: string; handleClose: () => void; - onResponse: (response: any) => void; + onResponse: (task: string, response: any) => void; + onGenerateResponse?: (task: string, response: any) => void; + onReGenerateResponse?: (task: string, response: any) => void; onError?: (error: any) => void; placement?: Placement; prompt?: string; @@ -33,7 +35,19 @@ type FormData = { const aiService = new AIService(); export const GptAssistantPopover: React.FC = (props) => { - const { isOpen, projectId, handleClose, onResponse, onError, placement, prompt, button, className = "" } = props; + const { + isOpen, + projectId, + handleClose, + onResponse, + onGenerateResponse, + onReGenerateResponse, + onError, + placement, + prompt, + button, + className = "", + } = props; // states const [response, setResponse] = useState(""); const [invalidResponse, setInvalidResponse] = useState(false); @@ -54,6 +68,7 @@ export const GptAssistantPopover: React.FC = (props) => { control, reset, setFocus, + getValues, formState: { isSubmitting }, } = useForm({ defaultValues: { @@ -118,6 +133,8 @@ export const GptAssistantPopover: React.FC = (props) => { } await callAIService(formData); + if (response !== "" && onReGenerateResponse) onReGenerateResponse(formData.task, response); + else if (response === "" && onGenerateResponse) onGenerateResponse(formData.task, response); }; useEffect(() => { @@ -162,7 +179,7 @@ export const GptAssistantPopover: React.FC = (props) => {