Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: Add response format support for openai compat models (#12240)
Giovanny Gutiérrezd7c0bc8c2399
diff --git a/api/core/model_runtime/model_providers/groq/llm/gemma-7b-it.yaml b/api/core/model_runtime/model_providers/groq/llm/gemma-7b-it.yamlindex 02f84e95f6e..157baaf3155 100644--- a/api/core/model_runtime/model_providers/groq/llm/gemma-7b-it.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/gemma-7b-it.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/gemma2-9b-it.yaml b/api/core/model_runtime/model_providers/groq/llm/gemma2-9b-it.yamlindex dad496f668a..d0294ac6aaa 100644--- a/api/core/model_runtime/model_providers/groq/llm/gemma2-9b-it.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/gemma2-9b-it.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-405b-reasoning.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-405b-reasoning.yamlindex 217785cea2d..3cbce0c0536 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-405b-reasoning.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-405b-reasoning.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-70b-versatile.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-70b-versatile.yamlindex 01323a1b8a7..07a0187e477 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-70b-versatile.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-70b-versatile.yaml@@ -6,6 +6,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 131072@@ -19,6 +20,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-8b-instant.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-8b-instant.yamlindex a82e64532ee..04eae49b96f 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.1-8b-instant.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.1-8b-instant.yaml@@ -5,6 +5,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 131072@@ -18,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-text-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-text-preview.yamlindex 3f30d81ae4e..e6eadeb0724 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-text-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-text-preview.yaml@@ -19,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-vision-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-vision-preview.yamlindex 56322187973..241a7bed108 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-vision-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-11b-vision-preview.yaml@@ -19,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-1b-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-1b-preview.yamlindex a44e4ff508e..a6087d34432 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-1b-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-1b-preview.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-3b-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-3b-preview.yamlindex f2fdd0a05e0..93a8127ec6c 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-3b-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-3b-preview.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-text-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-text-preview.yamlindex 0391a7c890c..f9361bff627 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-text-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-text-preview.yaml@@ -19,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-vision-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-vision-preview.yamlindex e7b93101e86..145b4579249 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-vision-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.2-90b-vision-preview.yaml@@ -19,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.1'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-specdec.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-specdec.yamlindex bda9ec530a6..916dfee391d 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-specdec.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-specdec.yaml@@ -5,6 +5,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 131072@@ -18,6 +19,18 @@ parameter_rules:default: 1024min: 1max: 32768+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: "0.05"output: "0.1"diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-versatile.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-versatile.yamlindex eb609f4db79..a5de4e752fd 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-versatile.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-3.3-70b-versatile.yaml@@ -5,6 +5,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 131072@@ -18,6 +19,18 @@ parameter_rules:default: 1024min: 1max: 32768+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: "0.05"output: "0.1"diff --git a/api/core/model_runtime/model_providers/groq/llm/llama-guard-3-8b.yaml b/api/core/model_runtime/model_providers/groq/llm/llama-guard-3-8b.yamlindex 03779ccc66f..bd8e5d2a3a7 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama-guard-3-8b.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama-guard-3-8b.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.20'output: '0.20'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama2-70b-4096.yaml b/api/core/model_runtime/model_providers/groq/llm/llama2-70b-4096.yamlindex 384912b0dd2..6e7ffd7a947 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama2-70b-4096.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama2-70b-4096.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 4096+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.7'output: '0.8'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama3-70b-8192.yaml b/api/core/model_runtime/model_providers/groq/llm/llama3-70b-8192.yamlindex 91d0e307657..2c25bb74336 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama3-70b-8192.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama3-70b-8192.yaml@@ -18,6 +18,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.59'output: '0.79'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama3-8b-8192.yaml b/api/core/model_runtime/model_providers/groq/llm/llama3-8b-8192.yamlindex b6154f761f4..d8a708eaf4c 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama3-8b-8192.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama3-8b-8192.yaml@@ -5,6 +5,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 8192@@ -18,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.08'diff --git a/api/core/model_runtime/model_providers/groq/llm/llama3-groq-70b-8192-tool-use-preview.yaml b/api/core/model_runtime/model_providers/groq/llm/llama3-groq-70b-8192-tool-use-preview.yamlindex 32ccbf1f4db..61c83c980c1 100644--- a/api/core/model_runtime/model_providers/groq/llm/llama3-groq-70b-8192-tool-use-preview.yaml+++ b/api/core/model_runtime/model_providers/groq/llm/llama3-groq-70b-8192-tool-use-preview.yaml@@ -5,6 +5,7 @@ label:model_type: llmfeatures:- agent-thought+ - multi-tool-callmodel_properties:mode: chatcontext_size: 8192@@ -18,6 +19,18 @@ parameter_rules:default: 512min: 1max: 8192+ - name: response_format+ label:+ zh_Hans: 回复格式+ en_US: Response Format+ type: string+ help:+ zh_Hans: 指定模型必须输出的格式+ en_US: specifying the format that the model must output+ required: false+ options:+ - text+ - json_objectpricing:input: '0.05'output: '0.08'diff --git a/api/core/model_runtime/model_providers/openai/llm/gpt-4o.yaml b/api/core/model_runtime/model_providers/openai/llm/gpt-4o.yamlindex a4681fe18d2..d6be36ad741 100644--- a/api/core/model_runtime/model_providers/openai/llm/gpt-4o.yaml+++ b/api/core/model_runtime/model_providers/openai/llm/gpt-4o.yaml@@ -37,6 +37,9 @@ parameter_rules:options:- text- json_object+ - json_schema+ - name: json_schema+ use_template: json_schemapricing:input: '2.50'output: '10.00'diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.pyindex 8e07d56f459..5b0ee7aae37 100644--- a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py+++ b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py@@ -332,6 +332,23 @@ class OAIAPICompatLargeLanguageModel(_CommonOaiApiCompat, LargeLanguageModel):if not endpoint_url.endswith("/"):endpoint_url += "/"+ response_format = model_parameters.get("response_format")+ if response_format:+ if response_format == "json_schema":+ json_schema = model_parameters.get("json_schema")+ if not json_schema:+ raise ValueError("Must define JSON Schema when the response format is json_schema")+ try:+ schema = json.loads(json_schema)+ except:+ raise ValueError(f"not correct json_schema format: {json_schema}")+ model_parameters.pop("json_schema")+ model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}+ else:+ model_parameters["response_format"] = {"type": response_format}+ elif "json_schema" in model_parameters:+ del model_parameters["json_schema"]+data = {"model": model, "stream": stream, **model_parameters}completion_type = LLMMode.value_of(credentials["mode"])