Skip to content

Commit

Permalink
fix: resolve issue with the opening statement generated by the `Autom…
Browse files Browse the repository at this point in the history
…aticRes` component failing to sync between states. (#12349)
  • Loading branch information
Woo0ood authored Jan 4, 2025
1 parent 682ebc5 commit b680a85
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ADD_EXTERNAL_DATA_TOOL } from '@/app/components/app/configuration/confi
import { INSERT_VARIABLE_VALUE_BLOCK_COMMAND } from '@/app/components/base/prompt-editor/plugins/variable-block'
import { PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER } from '@/app/components/base/prompt-editor/plugins/update-block'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { useFeaturesStore } from '@/app/components/base/features/hooks'

export type ISimplePromptInput = {
mode: AppType
Expand Down Expand Up @@ -54,6 +55,11 @@ const Prompt: FC<ISimplePromptInput> = ({
const { t } = useTranslation()
const media = useBreakpoints()
const isMobile = media === MediaType.mobile
const featuresStore = useFeaturesStore()
const {
features,
setFeatures,
} = featuresStore!.getState()

const { eventEmitter } = useEventEmitterContextContext()
const {
Expand Down Expand Up @@ -137,8 +143,18 @@ const Prompt: FC<ISimplePromptInput> = ({
})
setModelConfig(newModelConfig)
setPrevPromptConfig(modelConfig.configs)
if (mode !== AppType.completion)

if (mode !== AppType.completion) {
setIntroduction(res.opening_statement)
const newFeatures = produce(features, (draft) => {
draft.opening = {
...draft.opening,
enabled: !!res.opening_statement,
opening_statement: res.opening_statement,
}
})
setFeatures(newFeatures)
}
showAutomaticFalse()
}
const minHeight = initEditorHeight || 228
Expand Down

0 comments on commit b680a85

Please sign in to comment.