feat(workflow): add multi-turn context code generator modal

This commit is contained in:
zhsama
2026-01-20 18:04:48 +08:00
parent 18a589003e
commit 0ed5ed20b5
8 changed files with 719 additions and 11 deletions

View File

@ -25,6 +25,38 @@ export type CodeGenRes = {
error?: string
}
export type ContextGenerateMessage = {
role: 'user' | 'assistant' | 'system'
content: string
}
export type ContextGenerateRequest = {
workflow_id: string
node_id: string
parameter_name: string
language?: 'python3' | 'javascript'
prompt_messages: ContextGenerateMessage[]
model_config: {
provider: string
name: string
completion_params?: Record<string, any>
}
}
export type ContextGenerateVariable = {
variable: string
value_selector: string[]
}
export type ContextGenerateResponse = {
variables: ContextGenerateVariable[]
code_language: string
code: string
outputs: Record<string, { type: string }>
message: string
error: string
}
export const sendChatMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onThought, onFile, onError, getAbortController, onMessageEnd, onMessageReplace }: {
onData: IOnData
onCompleted: IOnCompleted
@ -93,6 +125,12 @@ export const generateRule = (body: Record<string, any>) => {
})
}
export const generateContext = (body: ContextGenerateRequest) => {
return post<ContextGenerateResponse>('/context-generate', {
body,
})
}
export const fetchModelParams = (providerName: string, modelId: string) => {
return get(`workspaces/current/model-providers/${providerName}/models/parameter-rules`, {
params: {