-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add System Prompt modal to chatbot debug UI (#1482)
* Add System Prompt modal to chatbot debug UI * Fix issues
- Loading branch information
1 parent
617c179
commit 5f271e6
Showing
8 changed files
with
170 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
ansible_ai_connect_chatbot/src/SystemPromptModal/SystemPromptModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from "react"; | ||
import { | ||
Button, | ||
Form, | ||
FormGroup, | ||
Modal, | ||
ModalBody, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalVariant, | ||
TextArea, | ||
} from "@patternfly/react-core"; | ||
import WrenchIcon from "@patternfly/react-icons/dist/esm/icons/wrench-icon"; | ||
|
||
interface SystemPromptModalProps { | ||
systemPrompt: string; | ||
setSystemPrompt: (s: string) => void; | ||
} | ||
|
||
export const SystemPromptModal: React.FunctionComponent< | ||
SystemPromptModalProps | ||
> = (props) => { | ||
const [isModalOpen, setModalOpen] = React.useState(false); | ||
const { systemPrompt, setSystemPrompt } = props; | ||
|
||
const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { | ||
setModalOpen(!isModalOpen); | ||
}; | ||
|
||
const handleSystemPromptInputChange = (_event: any, value: string) => { | ||
setSystemPrompt(value); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<Button | ||
variant="link" | ||
aria-label="SystemPrompt" | ||
icon={<WrenchIcon />} | ||
onClick={handleModalToggle} | ||
></Button> | ||
<Modal | ||
variant={ModalVariant.small} | ||
isOpen={isModalOpen} | ||
onClose={handleModalToggle} | ||
aria-labelledby="system-prompt-form-title" | ||
aria-describedby="system-prompt-description-form" | ||
> | ||
<ModalHeader | ||
title="System prompt" | ||
description="Enter a system prompt to override the default one." | ||
descriptorId="system-prompt-description-form" | ||
labelId="system-prompt-form-title" | ||
/> | ||
<ModalBody> | ||
<Form id="system-prompt-form"> | ||
<FormGroup label="System Prompt" isRequired fieldId="system-prompt"> | ||
<TextArea | ||
isRequired | ||
id="system-prompt" | ||
name="system-prompt" | ||
value={systemPrompt} | ||
onChange={handleSystemPromptInputChange} | ||
aria-label="system-prompt-form-text-area" | ||
rows={15} | ||
/> | ||
</FormGroup> | ||
</Form> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button | ||
key="create" | ||
variant="primary" | ||
form="system-prompt-form" | ||
onClick={handleModalToggle} | ||
aria-label="system-prompt-form-button" | ||
> | ||
Close | ||
</Button> | ||
</ModalFooter> | ||
</Modal> | ||
</React.Fragment> | ||
); | ||
}; | ||
SystemPromptModal.displayName = "SystemPromptModal"; |
Binary file added
BIN
+86.7 KB
...nect_chatbot/src/__screenshots__/App.test.tsx/Test-system-prompt-override-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters