mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat(workflow): add multi-turn context code generator modal
This commit is contained in:
@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user