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: support baichuan3 turbo, baichuan3 turbo 128k, and baichuan4 (#4762)
xielonge1cd9aef8ff8
diff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo-128k.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo-128k.yamlnew file mode 100644index 00000000000..bf72e822967--- /dev/null+++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo-128k.yaml@@ -0,0 +1,45 @@+model: baichuan3-turbo-128k+label:+ en_US: Baichuan3-Turbo-128k+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 128000+parameter_rules:+ - name: temperature+ use_template: temperature+ - name: top_p+ use_template: top_p+ - name: top_k+ label:+ zh_Hans: 取样数量+ en_US: Top k+ type: int+ help:+ zh_Hans: 仅从每个后续标记的前 K 个选项中采样。+ en_US: Only sample from the top K options for each subsequent token.+ required: false+ - name: max_tokens+ use_template: max_tokens+ required: true+ default: 8000+ min: 1+ max: 128000+ - name: presence_penalty+ use_template: presence_penalty+ - name: frequency_penalty+ use_template: frequency_penalty+ default: 1+ min: 1+ max: 2+ - name: with_search_enhance+ label:+ zh_Hans: 搜索增强+ en_US: Search Enhance+ type: boolean+ help:+ zh_Hans: 允许模型自行进行外部搜索,以增强生成结果。+ en_US: Allow the model to perform external search to enhance the generation results.+ required: falsediff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo.yamlnew file mode 100644index 00000000000..85882519b86--- /dev/null+++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan3-turbo.yaml@@ -0,0 +1,45 @@+model: baichuan3-turbo+label:+ en_US: Baichuan3-Turbo+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 32000+parameter_rules:+ - name: temperature+ use_template: temperature+ - name: top_p+ use_template: top_p+ - name: top_k+ label:+ zh_Hans: 取样数量+ en_US: Top k+ type: int+ help:+ zh_Hans: 仅从每个后续标记的前 K 个选项中采样。+ en_US: Only sample from the top K options for each subsequent token.+ required: false+ - name: max_tokens+ use_template: max_tokens+ required: true+ default: 8000+ min: 1+ max: 32000+ - name: presence_penalty+ use_template: presence_penalty+ - name: frequency_penalty+ use_template: frequency_penalty+ default: 1+ min: 1+ max: 2+ - name: with_search_enhance+ label:+ zh_Hans: 搜索增强+ en_US: Search Enhance+ type: boolean+ help:+ zh_Hans: 允许模型自行进行外部搜索,以增强生成结果。+ en_US: Allow the model to perform external search to enhance the generation results.+ required: falsediff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan4.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan4.yamlnew file mode 100644index 00000000000..f8c65660818--- /dev/null+++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan4.yaml@@ -0,0 +1,45 @@+model: baichuan4+label:+ en_US: Baichuan4+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 32000+parameter_rules:+ - name: temperature+ use_template: temperature+ - name: top_p+ use_template: top_p+ - name: top_k+ label:+ zh_Hans: 取样数量+ en_US: Top k+ type: int+ help:+ zh_Hans: 仅从每个后续标记的前 K 个选项中采样。+ en_US: Only sample from the top K options for each subsequent token.+ required: false+ - name: max_tokens+ use_template: max_tokens+ required: true+ default: 8000+ min: 1+ max: 32000+ - name: presence_penalty+ use_template: presence_penalty+ - name: frequency_penalty+ use_template: frequency_penalty+ default: 1+ min: 1+ max: 2+ - name: with_search_enhance+ label:+ zh_Hans: 搜索增强+ en_US: Search Enhance+ type: boolean+ help:+ zh_Hans: 允许模型自行进行外部搜索,以增强生成结果。+ en_US: Allow the model to perform external search to enhance the generation results.+ required: falsediff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py b/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.pyindex d524ee84b18..ad7cf4096c9 100644--- a/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py+++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py@@ -51,6 +51,9 @@ class BaichuanModel:'baichuan2-turbo': 'Baichuan2-Turbo','baichuan2-turbo-192k': 'Baichuan2-Turbo-192k','baichuan2-53b': 'Baichuan2-53B',+ 'baichuan3-turbo': 'Baichuan3-Turbo',+ 'baichuan3-turbo-128k': 'Baichuan3-Turbo-128k',+ 'baichuan4': 'Baichuan4',}[model]def _handle_chat_generate_response(self, response) -> BaichuanMessage:@@ -110,7 +113,8 @@ class BaichuanModel:def _build_parameters(self, model: str, stream: bool, messages: list[BaichuanMessage],parameters: dict[str, Any]) \-> dict[str, Any]:- if model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b':+ if (model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b'+ or model == 'baichuan3-turbo' or model == 'baichuan3-turbo-128k' or model == 'baichuan4'):prompt_messages = []for message in messages:if message.role == BaichuanMessage.Role.USER.value or message.role == BaichuanMessage.Role._SYSTEM.value:@@ -143,7 +147,8 @@ class BaichuanModel:raise BadRequestError(f"Unknown model: {model}")def _build_headers(self, model: str, data: dict[str, Any]) -> dict[str, Any]:- if model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b':+ if (model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b'+ or model == 'baichuan3-turbo' or model == 'baichuan3-turbo-128k' or model == 'baichuan4'):# there is no secret key for turbo apireturn {'Content-Type': 'application/json',@@ -160,7 +165,8 @@ class BaichuanModel:parameters: dict[str, Any], timeout: int) \-> Union[Generator, BaichuanMessage]:- if model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b':+ if (model == 'baichuan2-turbo' or model == 'baichuan2-turbo-192k' or model == 'baichuan2-53b'+ or model == 'baichuan3-turbo' or model == 'baichuan3-turbo-128k' or model == 'baichuan4'):api_base = 'https://api.baichuan-ai.com/v1/chat/completions'else:raise BadRequestError(f"Unknown model: {model}")