Commit 8d6ec9aa authored by Joel's avatar Joel

feat: support clear

parent 60f6ab03
...@@ -58,6 +58,14 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({ ...@@ -58,6 +58,14 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
setInputs(newInputs) setInputs(newInputs)
} }
const onClear = () => {
const newInputs: Record<string, any> = {}
promptVariables.forEach((item) => {
newInputs[item.key] = ''
})
setInputs(newInputs)
}
const promptPreview = ( const promptPreview = (
<div className='pt-3 pb-4 rounded-t-xl bg-indigo-25'> <div className='pt-3 pb-4 rounded-t-xl bg-indigo-25'>
<div className="px-4"> <div className="px-4">
...@@ -154,7 +162,14 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({ ...@@ -154,7 +162,14 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
appType === AppType.completion && ( appType === AppType.completion && (
<div> <div>
<div className="mt-5 border-b border-gray-100"></div> <div className="mt-5 border-b border-gray-100"></div>
<div className="flex justify-end mt-4 px-4"> <div className="flex justify-between mt-4 px-4">
<Button
className='w-[58px] !h-8 !p-3'
onClick={onClear}
disabled={false}
>
<span className='text-[13px]'>{t('common.operation.clear')}</span>
</Button>
<Button <Button
type="primary" type="primary"
onClick={() => onSend && onSend()} onClick={() => onSend && onSend()}
......
...@@ -25,6 +25,14 @@ const ConfigSence: FC<IConfigSenceProps> = ({ ...@@ -25,6 +25,14 @@ const ConfigSence: FC<IConfigSenceProps> = ({
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const onClear = () => {
const newInputs: Record<string, any> = {}
promptConfig.prompt_variables.forEach((item) => {
newInputs[item.key] = ''
})
onInputsChange(newInputs)
}
return ( return (
<div className=""> <div className="">
<section> <section>
...@@ -73,7 +81,7 @@ const ConfigSence: FC<IConfigSenceProps> = ({ ...@@ -73,7 +81,7 @@ const ConfigSence: FC<IConfigSenceProps> = ({
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<Button <Button
className='w-[58px] !h-8 !p-3' className='w-[58px] !h-8 !p-3'
onClick={onSend} onClick={onClear}
disabled={false} disabled={false}
> >
<span className='text-[13px]'>{t('common.operation.clear')}</span> <span className='text-[13px]'>{t('common.operation.clear')}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment