Skip to content

Commit

Permalink
make forms mutually exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale committed Dec 13, 2024
1 parent 79e77e4 commit 037c903
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/desktop/src/components/GooseResponseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ export default function GooseResponseForm({ message: _message, metadata, append
return null;
}

function isForm(f: DynamicForm) {
return f && f.title && f.description && f.fields && Array.isArray(f.fields) && f.fields.length > 0;
}

return (
<div className="space-y-4">
{isQuestion && !isOptions && (
{isQuestion && !isOptions && !isForm(dynamicForm) && (
<div className="flex items-center gap-4 p-4 rounded-lg bg-tool-card dark:bg-tool-card-dark border dark:border-dark-border">
<Button
onClick={handleAccept}
Expand Down Expand Up @@ -184,7 +188,7 @@ export default function GooseResponseForm({ message: _message, metadata, append
</Button>
</div>
)}
{dynamicForm && dynamicForm.fields && !isOptions && (
{isForm(dynamicForm) && !isOptions && (
<form onSubmit={handleFormSubmit} className="space-y-4 p-4 rounded-lg bg-tool-card dark:bg-tool-card-dark border dark:border-dark-border">
<h2 className="text-xl font-bold mb-2 dark:text-gray-100">{dynamicForm.title}</h2>
<p className="text-sm text-gray-600 dark:text-gray-300 mb-4">{dynamicForm.description}</p>
Expand Down
1 change: 1 addition & 0 deletions ui/desktop/src/utils/askAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The response will have:
* a list of fields, each field will have a label, type, name, placeholder, and required (boolean).
(type is either text or textarea only).
If it is not requesting clearly several pieces of information, just return an empty object.
If the task could be confirmed without more information, return an empty object.
### Example Message:
I'll help you scaffold out a Python package. To create a well-structured Python package, I'll need to know a few key pieces of information:
Expand Down

0 comments on commit 037c903

Please sign in to comment.