浏览代码

Modify model parameters in Spark LLMs and zhipuai LLMs (#8078)

Co-authored-by: Charlie.Wei <luowei@cvte.com>
AAEE86 7 月之前
父节点
当前提交
fa34b9aed6
共有 22 个文件被更改,包括 374 次插入80 次删除
  1. 14 11
      api/core/model_runtime/model_providers/spark/llm/_client.py
  2. 5 0
      api/core/model_runtime/model_providers/spark/llm/_position.yaml
  3. 1 0
      api/core/model_runtime/model_providers/spark/llm/spark-1.5.yaml
  4. 1 0
      api/core/model_runtime/model_providers/spark/llm/spark-3.5.yaml
  5. 1 0
      api/core/model_runtime/model_providers/spark/llm/spark-3.yaml
  6. 42 0
      api/core/model_runtime/model_providers/spark/llm/spark-4.0-ultra.yaml
  7. 1 0
      api/core/model_runtime/model_providers/spark/llm/spark-4.yaml
  8. 33 0
      api/core/model_runtime/model_providers/spark/llm/spark-lite.yaml
  9. 33 0
      api/core/model_runtime/model_providers/spark/llm/spark-max.yaml
  10. 33 0
      api/core/model_runtime/model_providers/spark/llm/spark-pro-128k.yaml
  11. 33 0
      api/core/model_runtime/model_providers/spark/llm/spark-pro.yaml
  12. 15 6
      api/core/model_runtime/model_providers/zhipuai/llm/chatglm_turbo.yaml
  13. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm-4-0520.yaml
  14. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm-4-air.yaml
  15. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm-4-airx.yaml
  16. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm-4-flash.yaml
  17. 15 6
      api/core/model_runtime/model_providers/zhipuai/llm/glm_3_turbo.yaml
  18. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm_4.yaml
  19. 19 1
      api/core/model_runtime/model_providers/zhipuai/llm/glm_4_long.yaml
  20. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm_4_plus.yaml
  21. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm_4v.yaml
  22. 16 7
      api/core/model_runtime/model_providers/zhipuai/llm/glm_4v_plus.yaml

+ 14 - 11
api/core/model_runtime/model_providers/spark/llm/_client.py

@@ -19,27 +19,25 @@ class SparkLLMClient:
         endpoint = 'chat'
         if api_domain:
             domain = api_domain
-            if model == 'spark-v3':
-                endpoint = 'multimodal'
 
         model_api_configs = {
-            'spark-1.5': {
+            'spark-lite': {
                 'version': 'v1.1',
                 'chat_domain': 'general'
             },
-            'spark-2': {
-                'version': 'v2.1',
-                'chat_domain': 'generalv2'
-            },
-            'spark-3': {
+            'spark-pro': {
                 'version': 'v3.1',
                 'chat_domain': 'generalv3'
             },
-            'spark-3.5': {
+            'spark-pro-128k': {
+                'version': 'pro-128k',
+                'chat_domain': 'pro-128k'
+            },
+            'spark-max': {
                 'version': 'v3.5',
                 'chat_domain': 'generalv3.5'
             },
-            'spark-4': {
+            'spark-4.0-ultra': {
                 'version': 'v4.0',
                 'chat_domain': '4.0Ultra'
             }
@@ -48,7 +46,12 @@ class SparkLLMClient:
         api_version = model_api_configs[model]['version']
 
         self.chat_domain = model_api_configs[model]['chat_domain']
-        self.api_base = f"wss://{domain}/{api_version}/{endpoint}"
+
+        if model == 'spark-pro-128k':
+            self.api_base = f"wss://{domain}/{endpoint}/{api_version}"
+        else:
+            self.api_base = f"wss://{domain}/{api_version}/{endpoint}"
+
         self.app_id = app_id
         self.ws_url = self.create_url(
             urlparse(self.api_base).netloc,

+ 5 - 0
api/core/model_runtime/model_providers/spark/llm/_position.yaml

@@ -1,3 +1,8 @@
+- spark-4.0-ultra
+- spark-max
+- spark-pro-128k
+- spark-pro
+- spark-lite
 - spark-4
 - spark-3.5
 - spark-3

+ 1 - 0
api/core/model_runtime/model_providers/spark/llm/spark-1.5.yaml

@@ -1,4 +1,5 @@
 model: spark-1.5
+deprecated: true
 label:
   en_US: Spark V1.5
 model_type: llm

+ 1 - 0
api/core/model_runtime/model_providers/spark/llm/spark-3.5.yaml

@@ -1,4 +1,5 @@
 model: spark-3.5
+deprecated: true
 label:
   en_US: Spark V3.5
 model_type: llm

+ 1 - 0
api/core/model_runtime/model_providers/spark/llm/spark-3.yaml

@@ -1,4 +1,5 @@
 model: spark-3
+deprecated: true
 label:
   en_US: Spark V3.0
 model_type: llm

+ 42 - 0
api/core/model_runtime/model_providers/spark/llm/spark-4.0-ultra.yaml

@@ -0,0 +1,42 @@
+model: spark-4.0-ultra
+label:
+  en_US: Spark 4.0 Ultra
+model_type: llm
+model_properties:
+  mode: chat
+parameter_rules:
+  - name: temperature
+    use_template: temperature
+    default: 0.5
+    help:
+      zh_Hans: 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。
+      en_US: Kernel sampling threshold. Used to determine the randomness of the results. The higher the value, the stronger the randomness, that is, the higher the possibility of getting different answers to the same question.
+  - name: max_tokens
+    use_template: max_tokens
+    default: 4096
+    min: 1
+    max: 8192
+    help:
+      zh_Hans: 模型回答的tokens的最大长度。
+      en_US: Maximum length of tokens for the model response.
+  - name: top_k
+    label:
+      zh_Hans: 取样数量
+      en_US: Top k
+    type: int
+    default: 4
+    min: 1
+    max: 6
+    help:
+      zh_Hans: 从 k 个候选中随机选择一个(非等概率)。
+      en_US: Randomly select one from k candidates (non-equal probability).
+    required: false
+  - name: show_ref_label
+    label:
+      zh_Hans: 联网检索
+      en_US: web search
+    type: boolean
+    default: false
+    help:
+      zh_Hans: 该参数仅4.0 Ultra版本支持,当设置为true时,如果输入内容触发联网检索插件,会先返回检索信源列表,然后再返回星火回复结果,否则仅返回星火回复结果
+      en_US: The parameter is only supported in the 4.0 Ultra version. When set to true, if the input triggers the online search plugin, it will first return a list of search sources and then return the Spark response. Otherwise, it will only return the Spark response.

+ 1 - 0
api/core/model_runtime/model_providers/spark/llm/spark-4.yaml

@@ -1,4 +1,5 @@
 model: spark-4
+deprecated: true
 label:
   en_US: Spark V4.0
 model_type: llm

+ 33 - 0
api/core/model_runtime/model_providers/spark/llm/spark-lite.yaml

@@ -0,0 +1,33 @@
+model: spark-lite
+label:
+  en_US: Spark Lite
+model_type: llm
+model_properties:
+  mode: chat
+parameter_rules:
+  - name: temperature
+    use_template: temperature
+    default: 0.5
+    help:
+      zh_Hans: 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。
+      en_US: Kernel sampling threshold. Used to determine the randomness of the results. The higher the value, the stronger the randomness, that is, the higher the possibility of getting different answers to the same question.
+  - name: max_tokens
+    use_template: max_tokens
+    default: 4096
+    min: 1
+    max: 4096
+    help:
+      zh_Hans: 模型回答的tokens的最大长度。
+      en_US: Maximum length of tokens for the model response.
+  - name: top_k
+    label:
+      zh_Hans: 取样数量
+      en_US: Top k
+    type: int
+    default: 4
+    min: 1
+    max: 6
+    help:
+      zh_Hans: 从 k 个候选中随机选择一个(非等概率)。
+      en_US: Randomly select one from k candidates (non-equal probability).
+    required: false

+ 33 - 0
api/core/model_runtime/model_providers/spark/llm/spark-max.yaml

@@ -0,0 +1,33 @@
+model: spark-max
+label:
+  en_US: Spark Max
+model_type: llm
+model_properties:
+  mode: chat
+parameter_rules:
+  - name: temperature
+    use_template: temperature
+    default: 0.5
+    help:
+      zh_Hans: 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。
+      en_US: Kernel sampling threshold. Used to determine the randomness of the results. The higher the value, the stronger the randomness, that is, the higher the possibility of getting different answers to the same question.
+  - name: max_tokens
+    use_template: max_tokens
+    default: 4096
+    min: 1
+    max: 8192
+    help:
+      zh_Hans: 模型回答的tokens的最大长度。
+      en_US: Maximum length of tokens for the model response.
+  - name: top_k
+    label:
+      zh_Hans: 取样数量
+      en_US: Top k
+    type: int
+    default: 4
+    min: 1
+    max: 6
+    help:
+      zh_Hans: 从 k 个候选中随机选择一个(非等概率)。
+      en_US: Randomly select one from k candidates (non-equal probability).
+    required: false

+ 33 - 0
api/core/model_runtime/model_providers/spark/llm/spark-pro-128k.yaml

@@ -0,0 +1,33 @@
+model: spark-pro-128k
+label:
+  en_US: Spark Pro-128K
+model_type: llm
+model_properties:
+  mode: chat
+parameter_rules:
+  - name: temperature
+    use_template: temperature
+    default: 0.5
+    help:
+      zh_Hans: 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。
+      en_US: Kernel sampling threshold. Used to determine the randomness of the results. The higher the value, the stronger the randomness, that is, the higher the possibility of getting different answers to the same question.
+  - name: max_tokens
+    use_template: max_tokens
+    default: 4096
+    min: 1
+    max: 4096
+    help:
+      zh_Hans: 模型回答的tokens的最大长度。
+      en_US: Maximum length of tokens for the model response.
+  - name: top_k
+    label:
+      zh_Hans: 取样数量
+      en_US: Top k
+    type: int
+    default: 4
+    min: 1
+    max: 6
+    help:
+      zh_Hans: 从 k 个候选中随机选择一个(非等概率)。
+      en_US: Randomly select one from k candidates (non-equal probability).
+    required: false

+ 33 - 0
api/core/model_runtime/model_providers/spark/llm/spark-pro.yaml

@@ -0,0 +1,33 @@
+model: spark-pro
+label:
+  en_US: Spark Pro
+model_type: llm
+model_properties:
+  mode: chat
+parameter_rules:
+  - name: temperature
+    use_template: temperature
+    default: 0.5
+    help:
+      zh_Hans: 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。
+      en_US: Kernel sampling threshold. Used to determine the randomness of the results. The higher the value, the stronger the randomness, that is, the higher the possibility of getting different answers to the same question.
+  - name: max_tokens
+    use_template: max_tokens
+    default: 4096
+    min: 1
+    max: 8192
+    help:
+      zh_Hans: 模型回答的tokens的最大长度。
+      en_US: Maximum length of tokens for the model response.
+  - name: top_k
+    label:
+      zh_Hans: 取样数量
+      en_US: Top k
+    type: int
+    default: 4
+    min: 1
+    max: 6
+    help:
+      zh_Hans: 从 k 个候选中随机选择一个(非等概率)。
+      en_US: Randomly select one from k candidates (non-equal probability).
+    required: false

文件差异内容过多而无法显示
+ 15 - 6
api/core/model_runtime/model_providers/zhipuai/llm/chatglm_turbo.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm-4-0520.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm-4-air.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm-4-airx.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm-4-flash.yaml


文件差异内容过多而无法显示
+ 15 - 6
api/core/model_runtime/model_providers/zhipuai/llm/glm_3_turbo.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm_4.yaml


文件差异内容过多而无法显示
+ 19 - 1
api/core/model_runtime/model_providers/zhipuai/llm/glm_4_long.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm_4_plus.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm_4v.yaml


文件差异内容过多而无法显示
+ 16 - 7
api/core/model_runtime/model_providers/zhipuai/llm/glm_4v_plus.yaml