mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
feat: add json response format for siliconflow models (#10657)
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
This commit is contained in:
parent
5b8f03cd9d
commit
317ae9233e
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '1.33'
|
input: '1.33'
|
||||||
output: '1.33'
|
output: '1.33'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '1.26'
|
input: '1.26'
|
||||||
output: '1.26'
|
output: '1.26'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '1'
|
input: '1'
|
||||||
output: '1'
|
output: '1'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -29,6 +29,9 @@ class SiliconflowLargeLanguageModel(OAIAPICompatLargeLanguageModel):
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
) -> Union[LLMResult, Generator]:
|
) -> Union[LLMResult, Generator]:
|
||||||
self._add_custom_parameters(credentials)
|
self._add_custom_parameters(credentials)
|
||||||
|
# {"response_format": "json_object"} need convert to {"response_format": {"type": "json_object"}}
|
||||||
|
if "response_format" in model_parameters:
|
||||||
|
model_parameters["response_format"] = {"type": model_parameters.get("response_format")}
|
||||||
return super()._invoke(model, credentials, prompt_messages, model_parameters, tools, stop, stream)
|
return super()._invoke(model, credentials, prompt_messages, model_parameters, tools, stop, stream)
|
||||||
|
|
||||||
def validate_credentials(self, model: str, credentials: dict) -> None:
|
def validate_credentials(self, model: str, credentials: dict) -> None:
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '21'
|
input: '21'
|
||||||
output: '21'
|
output: '21'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '4.13'
|
input: '4.13'
|
||||||
output: '4.13'
|
output: '4.13'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0.7'
|
input: '0.7'
|
||||||
output: '0.7'
|
output: '0.7'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '1.26'
|
input: '1.26'
|
||||||
output: '1.26'
|
output: '1.26'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '4.13'
|
input: '4.13'
|
||||||
output: '4.13'
|
output: '4.13'
|
||||||
|
|
|
@ -32,6 +32,18 @@ parameter_rules:
|
||||||
required: false
|
required: false
|
||||||
- name: frequency_penalty
|
- name: frequency_penalty
|
||||||
use_template: frequency_penalty
|
use_template: frequency_penalty
|
||||||
|
- 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -66,7 +66,17 @@ parameter_rules:
|
||||||
zh_Hans: 用于控制模型生成时的重复度。提高repetition_penalty时可以降低模型生成的重复度。1.0表示不做惩罚。
|
zh_Hans: 用于控制模型生成时的重复度。提高repetition_penalty时可以降低模型生成的重复度。1.0表示不做惩罚。
|
||||||
en_US: Used to control the repeatability when generating models. Increasing repetition_penalty can reduce the duplication of model generation. 1.0 means no punishment.
|
en_US: Used to control the repeatability when generating models. Increasing repetition_penalty can reduce the duplication of model generation. 1.0 means no punishment.
|
||||||
- name: response_format
|
- name: response_format
|
||||||
use_template: 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '0'
|
input: '0'
|
||||||
output: '0'
|
output: '0'
|
||||||
|
|
|
@ -66,7 +66,17 @@ parameter_rules:
|
||||||
zh_Hans: 用于控制模型生成时的重复度。提高repetition_penalty时可以降低模型生成的重复度。1.0表示不做惩罚。
|
zh_Hans: 用于控制模型生成时的重复度。提高repetition_penalty时可以降低模型生成的重复度。1.0表示不做惩罚。
|
||||||
en_US: Used to control the repeatability when generating models. Increasing repetition_penalty can reduce the duplication of model generation. 1.0 means no punishment.
|
en_US: Used to control the repeatability when generating models. Increasing repetition_penalty can reduce the duplication of model generation. 1.0 means no punishment.
|
||||||
- name: response_format
|
- name: response_format
|
||||||
use_template: 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_object
|
||||||
pricing:
|
pricing:
|
||||||
input: '4.13'
|
input: '4.13'
|
||||||
output: '4.13'
|
output: '4.13'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user