fix: editor
This commit is contained in:
parent
fe5702784e
commit
4855e87876
@ -16,6 +16,7 @@ import type { ComponentProps } from 'react'
|
|||||||
import { useDefaultModel, useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
import { useDefaultModel, useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
import Editor from './prompt/editor'
|
import Editor from './prompt/editor'
|
||||||
import { strategyParamToCredientialForm } from '../../agent/panel'
|
import { strategyParamToCredientialForm } from '../../agent/panel'
|
||||||
|
import { useWorkflowStore } from '../../../store'
|
||||||
|
|
||||||
export type Strategy = {
|
export type Strategy = {
|
||||||
agent_strategy_provider_name: string
|
agent_strategy_provider_name: string
|
||||||
@ -52,6 +53,10 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration)
|
const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration)
|
||||||
|
const workflowStore = useWorkflowStore()
|
||||||
|
const {
|
||||||
|
setControlPromptEditorRerenderKey,
|
||||||
|
} = workflowStore.getState()
|
||||||
const override: ComponentProps<typeof Form<CustomField>>['override'] = [
|
const override: ComponentProps<typeof Form<CustomField>>['override'] = [
|
||||||
[FormTypeEnum.textNumber],
|
[FormTypeEnum.textNumber],
|
||||||
(schema, props) => {
|
(schema, props) => {
|
||||||
@ -130,9 +135,14 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
|||||||
const onChange = (value: string) => {
|
const onChange = (value: string) => {
|
||||||
props.onChange({ ...props.value, [schema.variable]: value })
|
props.onChange({ ...props.value, [schema.variable]: value })
|
||||||
}
|
}
|
||||||
|
const handleGenerated = (value: string) => {
|
||||||
|
onChange(value)
|
||||||
|
setControlPromptEditorRerenderKey(Math.random())
|
||||||
|
}
|
||||||
return <Editor
|
return <Editor
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onGenerated={handleGenerated}
|
||||||
title={schema.label[language]}
|
title={schema.label[language]}
|
||||||
headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase !text-base'
|
headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase !text-base'
|
||||||
containerClassName='bg-transparent'
|
containerClassName='bg-transparent'
|
||||||
@ -151,7 +161,6 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
|||||||
completion_params: {},
|
completion_params: {},
|
||||||
} : undefined
|
} : undefined
|
||||||
}
|
}
|
||||||
onGenerated={onChange}
|
|
||||||
placeholderClassName='px-2 py-1'
|
placeholderClassName='px-2 py-1'
|
||||||
inputClassName='px-2 py-1 bg-components-input-bg-normal focus:bg-components-input-bg-active focus:border-components-input-border-active focus:border rounded-lg'
|
inputClassName='px-2 py-1 bg-components-input-bg-normal focus:bg-components-input-bg-active focus:border-components-input-border-active focus:border rounded-lg'
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user