Co-authored-by: Gio Gutierrez <giovannygutierrez@gmail.com>tags/0.15.0
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 131072 | context_size: 131072 | ||||
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 131072 | context_size: 131072 | ||||
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.1' | output: '0.1' |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 131072 | context_size: 131072 | ||||
| default: 1024 | default: 1024 | ||||
| min: 1 | min: 1 | ||||
| max: 32768 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: "0.05" | input: "0.05" | ||||
| output: "0.1" | output: "0.1" |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 131072 | context_size: 131072 | ||||
| default: 1024 | default: 1024 | ||||
| min: 1 | min: 1 | ||||
| max: 32768 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: "0.05" | input: "0.05" | ||||
| output: "0.1" | output: "0.1" |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.20' | input: '0.20' | ||||
| output: '0.20' | output: '0.20' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 4096 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.7' | input: '0.7' | ||||
| output: '0.8' | output: '0.8' |
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.59' | input: '0.59' | ||||
| output: '0.79' | output: '0.79' |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 8192 | context_size: 8192 | ||||
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.08' | output: '0.08' |
| model_type: llm | model_type: llm | ||||
| features: | features: | ||||
| - agent-thought | - agent-thought | ||||
| - multi-tool-call | |||||
| model_properties: | model_properties: | ||||
| mode: chat | mode: chat | ||||
| context_size: 8192 | context_size: 8192 | ||||
| default: 512 | default: 512 | ||||
| min: 1 | min: 1 | ||||
| max: 8192 | max: 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_object | |||||
| pricing: | pricing: | ||||
| input: '0.05' | input: '0.05' | ||||
| output: '0.08' | output: '0.08' |
| options: | options: | ||||
| - text | - text | ||||
| - json_object | - json_object | ||||
| - json_schema | |||||
| - name: json_schema | |||||
| use_template: json_schema | |||||
| pricing: | pricing: | ||||
| input: '2.50' | input: '2.50' | ||||
| output: '10.00' | output: '10.00' |
| if not endpoint_url.endswith("/"): | if not endpoint_url.endswith("/"): | ||||
| endpoint_url += "/" | 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} | data = {"model": model, "stream": stream, **model_parameters} | ||||
| completion_type = LLMMode.value_of(credentials["mode"]) | completion_type = LLMMode.value_of(credentials["mode"]) |