| model: ernie-3.5-8k | |||||
| label: | |||||
| en_US: Ernie-3.5-8K | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 4096 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.8 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 2048 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| - name: frequency_penalty | |||||
| use_template: frequency_penalty | |||||
| - name: response_format | |||||
| use_template: response_format | |||||
| - name: disable_search | |||||
| label: | |||||
| zh_Hans: 禁用搜索 | |||||
| en_US: Disable Search | |||||
| type: boolean | |||||
| help: | |||||
| zh_Hans: 禁用模型自行进行外部搜索。 | |||||
| en_US: Disable the model to perform external search. | |||||
| required: false |
| model: ernie-3.5-8k-0205 | |||||
| label: | |||||
| en_US: Ernie-3.5-8K-0205 | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.8 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 2048 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| - name: frequency_penalty | |||||
| use_template: frequency_penalty | |||||
| - name: response_format | |||||
| use_template: response_format | |||||
| - name: disable_search | |||||
| label: | |||||
| zh_Hans: 禁用搜索 | |||||
| en_US: Disable Search | |||||
| type: boolean | |||||
| help: | |||||
| zh_Hans: 禁用模型自行进行外部搜索。 | |||||
| en_US: Disable the model to perform external search. | |||||
| required: false |
| model: ernie-3.5-8k-1222 | |||||
| label: | |||||
| en_US: Ernie-3.5-8K-1222 | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.8 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 2048 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| - name: frequency_penalty | |||||
| use_template: frequency_penalty | |||||
| - name: response_format | |||||
| use_template: response_format | |||||
| - name: disable_search | |||||
| label: | |||||
| zh_Hans: 禁用搜索 | |||||
| en_US: Disable Search | |||||
| type: boolean | |||||
| help: | |||||
| zh_Hans: 禁用模型自行进行外部搜索。 | |||||
| en_US: Disable the model to perform external search. | |||||
| required: false |
| model: ernie-3.5-8k | |||||
| label: | |||||
| en_US: Ernie-3.5-8K | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.8 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 2048 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| - name: frequency_penalty | |||||
| use_template: frequency_penalty | |||||
| - name: response_format | |||||
| use_template: response_format | |||||
| - name: disable_search | |||||
| label: | |||||
| zh_Hans: 禁用搜索 | |||||
| en_US: Disable Search | |||||
| type: boolean | |||||
| help: | |||||
| zh_Hans: 禁用模型自行进行外部搜索。 | |||||
| en_US: Disable the model to perform external search. | |||||
| required: false |
| model: ernie-4.0-8k | |||||
| label: | |||||
| en_US: Ernie-4.0-8K | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.8 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 2048 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| - name: frequency_penalty | |||||
| use_template: frequency_penalty | |||||
| - name: response_format | |||||
| use_template: response_format | |||||
| - name: disable_search | |||||
| label: | |||||
| zh_Hans: 禁用搜索 | |||||
| en_US: Disable Search | |||||
| type: boolean | |||||
| help: | |||||
| zh_Hans: 禁用模型自行进行外部搜索。 | |||||
| en_US: Disable the model to perform external search. | |||||
| required: false |
| zh_Hans: 禁用模型自行进行外部搜索。 | zh_Hans: 禁用模型自行进行外部搜索。 | ||||
| en_US: Disable the model to perform external search. | en_US: Disable the model to perform external search. | ||||
| required: false | required: false | ||||
| deprecated: true |
| zh_Hans: 禁用模型自行进行外部搜索。 | zh_Hans: 禁用模型自行进行外部搜索。 | ||||
| en_US: Disable the model to perform external search. | en_US: Disable the model to perform external search. | ||||
| required: false | required: false | ||||
| deprecated: true |
| use_template: frequency_penalty | use_template: frequency_penalty | ||||
| - name: response_format | - name: response_format | ||||
| use_template: response_format | use_template: response_format | ||||
| deprecated: true |
| required: false | required: false | ||||
| - name: response_format | - name: response_format | ||||
| use_template: response_format | use_template: response_format | ||||
| deprecated: true |
| model: ernie-lite-8k-0308 | |||||
| label: | |||||
| en_US: ERNIE-Lite-8K-0308 | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.95 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| min: 0 | |||||
| max: 1.0 | |||||
| default: 0.7 | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 1024 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| default: 1.0 | |||||
| min: 1.0 | |||||
| max: 2.0 |
| model: ernie-lite-8k-0922 | |||||
| label: | |||||
| en_US: ERNIE-Lite-8K-0922 | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.95 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| min: 0 | |||||
| max: 1.0 | |||||
| default: 0.7 | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 1024 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| default: 1.0 | |||||
| min: 1.0 | |||||
| max: 2.0 |
| model: ernie-speed-128k | |||||
| label: | |||||
| en_US: ERNIE-Speed-128K | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 128000 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.95 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| min: 0 | |||||
| max: 1.0 | |||||
| default: 0.7 | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 1024 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| default: 1.0 | |||||
| min: 1.0 | |||||
| max: 2.0 |
| model: ernie-speed-8k | |||||
| label: | |||||
| en_US: ERNIE-Speed-8K | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.95 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| min: 0 | |||||
| max: 1.0 | |||||
| default: 0.7 | |||||
| - name: max_tokens | |||||
| use_template: max_tokens | |||||
| default: 1024 | |||||
| min: 2 | |||||
| max: 1024 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| default: 1.0 | |||||
| min: 1.0 | |||||
| max: 2.0 |
| model: ernie-speed-appbuilder | |||||
| label: | |||||
| en_US: ERNIE-Speed-AppBuilder | |||||
| model_type: llm | |||||
| features: | |||||
| - agent-thought | |||||
| model_properties: | |||||
| mode: chat | |||||
| context_size: 8192 | |||||
| parameter_rules: | |||||
| - name: temperature | |||||
| use_template: temperature | |||||
| min: 0.1 | |||||
| max: 1.0 | |||||
| default: 0.95 | |||||
| - name: top_p | |||||
| use_template: top_p | |||||
| min: 0 | |||||
| max: 1.0 | |||||
| default: 0.7 | |||||
| - name: presence_penalty | |||||
| use_template: presence_penalty | |||||
| default: 1.0 | |||||
| min: 1.0 | |||||
| max: 2.0 |
| class ErnieBotModel: | class ErnieBotModel: | ||||
| api_bases = { | api_bases = { | ||||
| 'ernie-bot': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions', | |||||
| 'ernie-bot': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-3.5-4k-0205', | |||||
| 'ernie-bot-4': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro', | 'ernie-bot-4': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro', | ||||
| 'ernie-bot-8k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie_bot_8k', | |||||
| 'ernie-bot-8k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions', | |||||
| 'ernie-bot-turbo': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant', | 'ernie-bot-turbo': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant', | ||||
| 'ernie-3.5-8k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions', | |||||
| 'ernie-3.5-8k-0205': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-3.5-8k-0205', | |||||
| 'ernie-3.5-8k-1222': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-3.5-8k-1222', | |||||
| 'ernie-3.5-4k-0205': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-3.5-4k-0205', | |||||
| 'ernie-4.0-8k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro', | |||||
| 'ernie-speed-8k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie_speed', | |||||
| 'ernie-speed-128k': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-speed-128k', | |||||
| 'ernie-speed-appbuilder': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ai_apaas', | |||||
| 'ernie-lite-8k-0922': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant', | |||||
| 'ernie-lite-8k-0308': 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-lite-8k', | |||||
| } | } | ||||
| function_calling_supports = [ | function_calling_supports = [ | ||||
| 'ernie-bot', | 'ernie-bot', | ||||
| 'ernie-bot-8k', | 'ernie-bot-8k', | ||||
| 'ernie-3.5-8k', | |||||
| 'ernie-3.5-8k-0205', | |||||
| 'ernie-3.5-8k-1222', | |||||
| 'ernie-3.5-4k-0205' | |||||
| ] | ] | ||||
| api_key: str = '' | api_key: str = '' | ||||
| **parameters | **parameters | ||||
| } | } | ||||
| if 'max_tokens' in parameters and type(parameters['max_tokens']) == int: | |||||
| body['max_output_tokens'] = parameters['max_tokens'] | |||||
| if 'presence_penalty' in parameters and type(parameters['presence_penalty']) == float: | |||||
| body['penalty_score'] = parameters['presence_penalty'] | |||||
| if system_message: | if system_message: | ||||
| body['system'] = system_message | body['system'] = system_message | ||||
| model = ErnieBotLargeLanguageModel() | model = ErnieBotLargeLanguageModel() | ||||
| response = model.invoke( | response = model.invoke( | ||||
| model='ernie-bot', | |||||
| model='ernie-3.5-8k', | |||||
| credentials={ | credentials={ | ||||
| 'api_key': os.environ.get('WENXIN_API_KEY'), | 'api_key': os.environ.get('WENXIN_API_KEY'), | ||||
| 'secret_key': os.environ.get('WENXIN_SECRET_KEY') | 'secret_key': os.environ.get('WENXIN_SECRET_KEY') |