feat: call gen api

feat/enchance-prompt-and-code-fe
Joel 7 months ago
parent 945a424fa8
commit f14678a0d8

@ -136,8 +136,9 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
},
]
const [instruction, setInstruction] = useState<string>('')
const [ideaOutput, setIdeaOutput] = useState<string>('')
const [instruction, setInstruction] = useState<string>('The travel plan to Anshun of Guizhou Province in China') // TODO: test value
const [ideaOutput, setIdeaOutput] = useState<string>('use json format to output the result. Content in result uses Chinese. Format: {"summary: "summary content", "result": "result content"}')
const [currentPrompt, setCurrentPrompt] = useState<string>('')
const [isFoldIdeaOutput, {
toggle: toggleFoldIdeaOutput,
}] = useBoolean(true)
@ -226,7 +227,11 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
setLoadingTrue()
try {
const { error, ...res } = await generateRule({
flow_id: flowId,
node_id: nodeId,
current: currentPrompt,
instruction,
idea_output: ideaOutput,
model_config: model,
})
setRes(res)

@ -5,6 +5,7 @@ export const useConfigsMap = () => {
const appId = useStore(s => s.appId)
return useMemo(() => {
return {
flowId: appId,
conversationVarsUrl: `apps/${appId}/workflows/draft/conversation-variables`,
systemVarsUrl: `apps/${appId}/workflows/draft/system-variables`,
}

@ -35,7 +35,6 @@ export const useWorkflowRun = () => {
const invalidAllLastRun = useInvalidAllLastRun(appId as string)
const configsMap = useConfigsMap()
const { fetchInspectVars } = useSetWorkflowVarsWithValue({
flowId: appId as string,
...configsMap,
})

@ -49,6 +49,7 @@ type CommonHooksFnMap = {
resetConversationVar: (varId: string) => Promise<void>
invalidateConversationVarValues: () => void
configsMap?: {
flowId: string
conversationVarsUrl: string
systemVarsUrl: string
}

@ -87,6 +87,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase'
containerBackgroundClassName='bg-transparent'
gradientBorder={false}
nodeId={nodeId}
isSupportPromptGenerator={!!def.auto_generate?.type}
titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)}
editorContainerClassName='px-0'

@ -41,6 +41,7 @@ type Props = {
className?: string
headerClassName?: string
instanceId?: string
nodeId?: string
title: string | React.JSX.Element
value: string
onChange: (value: string) => void
@ -83,6 +84,7 @@ const Editor: FC<Props> = ({
className,
headerClassName,
instanceId,
nodeId,
title,
value,
onChange,
@ -160,6 +162,7 @@ const Editor: FC<Props> = ({
<div className='text-xs font-medium leading-[18px] text-text-tertiary'>{value?.length || 0}</div>
{isSupportPromptGenerator && (
<PromptGeneratorBtn
nodeId={nodeId!}
className='ml-[5px]'
onGenerated={onGenerated}
modelConfig={modelConfig}

@ -136,6 +136,7 @@ const ConfigPromptItem: FC<Props> = ({
hasSetBlockStatus={hasSetBlockStatus}
nodesOutputVars={availableVars}
availableNodes={availableNodes}
nodeId={id}
isSupportPromptGenerator={payload.role === PromptRole.system}
onGenerated={handleGenerated}
modelConfig={modelConfig}

@ -10,11 +10,13 @@ import { AppType } from '@/types/app'
import type { AutomaticRes } from '@/service/debug'
import type { ModelConfig, Node, NodeOutPutVar } from '@/app/components/workflow/types'
import { GeneratorType } from '@/app/components/app/configuration/config/automatic/types'
import { useHooksStore } from '../../../hooks-store'
type Props = {
className?: string
onGenerated?: (prompt: string) => void
modelConfig?: ModelConfig
nodeId: string
nodesOutputVars?: NodeOutPutVar[]
availableNodes?: Node[]
}
@ -22,6 +24,7 @@ type Props = {
const PromptGeneratorBtn: FC<Props> = ({
className,
onGenerated,
nodeId,
nodesOutputVars,
availableNodes,
}) => {
@ -30,6 +33,7 @@ const PromptGeneratorBtn: FC<Props> = ({
onGenerated?.(res.prompt)
showAutomaticFalse()
}, [onGenerated, showAutomaticFalse])
const configsMap = useHooksStore(s => s.configsMap)
return (
<div className={cn(className)}>
<ActionButton
@ -46,6 +50,8 @@ const PromptGeneratorBtn: FC<Props> = ({
generatorType={GeneratorType.prompt}
nodesOutputVars={nodesOutputVars}
availableNodes={availableNodes}
flowId={configsMap?.flowId || ''}
nodeId={nodeId}
/>
)}
</div>

@ -72,7 +72,7 @@ export const fetchConversationMessages = (appId: string, conversation_id: string
}
export const generateRule = (body: Record<string, any>) => {
return post<AutomaticRes>('/rule-generate', {
return post<AutomaticRes>('/instruction-generate', {
body,
})
}

Loading…
Cancel
Save