Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify model parameters in Spark LLMs and zhipuai LLMs #8078

Merged
merged 30 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7618190
ifEsle node add regex match (#8007)
charli117 Sep 6, 2024
340fd14
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
f808e76
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
bbcaf8f
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
5577367
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
5109300
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
f40323c
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
b7c7639
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
4eb4adf
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
af2217c
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
c3d4454
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
81eae56
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
51f9a86
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
10018cc
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
9b478cf
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
6a6b727
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
ab84afc
Update Spark-4.0Ultra.yaml
AAEE86 Sep 7, 2024
764c417
Update Spark-4.0Ultra.yaml
AAEE86 Sep 7, 2024
61d96bc
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
3e4240b
Merge branch 'langgenius:main' into main
AAEE86 Sep 7, 2024
e77a17c
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
e9a42b1
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
b7b8f3d
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 7, 2024
33676b0
Merge branch 'main' of https://github.com/AAEE86/dify
AAEE86 Sep 9, 2024
c63ce9a
Rename Spark-Lite.yaml to spark-lite.yaml
AAEE86 Sep 9, 2024
531e6bd
Rename Spark-Max.yaml to spark-max.yaml
AAEE86 Sep 9, 2024
d5e41c3
Rename Spark-Pro.yaml to spark-pro.yaml
AAEE86 Sep 9, 2024
4e27622
Rename Spark-Pro-128K.yaml to spark-pro-128k.yaml
AAEE86 Sep 9, 2024
dfc5156
Update spark-4.0-ultra.yaml
AAEE86 Sep 9, 2024
125a782
Update _position.yaml
AAEE86 Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions api/core/model_runtime/model_providers/spark/llm/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@ def __init__(self, model: str, app_id: str, api_key: str, api_secret: str, api_d
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'
}
Expand All @@ -48,7 +46,12 @@ def __init__(self, model: str, app_id: str, api_key: str, api_secret: str, api_d
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- spark-4.0-ultra
- spark-max
- spark-pro-128k
- spark-pro
- spark-lite
- spark-4
- spark-3.5
- spark-3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
model: spark-1.5
deprecated: true
label:
en_US: Spark V1.5
model_type: llm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
model: spark-3.5
deprecated: true
label:
en_US: Spark V3.5
model_type: llm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
model: spark-3
deprecated: true
label:
en_US: Spark V3.0
model_type: llm
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
model: spark-4
deprecated: true
label:
en_US: Spark V4.0
model_type: llm
Expand Down
33 changes: 33 additions & 0 deletions api/core/model_runtime/model_providers/spark/llm/spark-lite.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 33 additions & 0 deletions api/core/model_runtime/model_providers/spark/llm/spark-max.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 changes: 33 additions & 0 deletions api/core/model_runtime/model_providers/spark/llm/spark-pro.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@ parameter_rules:
help:
zh_Hans: 用温度取样的另一种方法,称为核取样取值范围是:(0.0, 1.0) 开区间,不能等于 0 或 1,默认值为 0.7 模型考虑具有 top_p 概率质量tokens的结果例如:0.1 意味着模型解码器只考虑从前 10% 的概率的候选集中取 tokens 建议您根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数。
en_US: Another method of temperature sampling is called kernel sampling. The value range is (0.0, 1.0) open interval, which cannot be equal to 0 or 1. The default value is 0.7. The model considers the results with top_p probability mass tokens. For example 0.1 means The model decoder only considers tokens from the candidate set with the top 10% probability. It is recommended that you adjust the top_p or temperature parameters according to the application scenario, but do not adjust both parameters at the same time.
- name: incremental
- name: do_sample
label:
zh_Hans: 增量返回
en_US: Incremental
zh_Hans: 采样策略
en_US: Sampling strategy
type: boolean
help:
zh_Hans: SSE接口调用时,用于控制每次返回内容方式是增量还是全量,不提供此参数时默认为增量返回,true 为增量返回,false 为全量返回。
en_US: When the SSE interface is called, it is used to control whether the content is returned incrementally or in full. If this parameter is not provided, the default is incremental return. true means incremental return, false means full return.
required: false
zh_Hans: do_sample 为 true 时启用采样策略,do_sample 为 false 时采样策略 temperature、top_p 将不生效。默认值为 true。
en_US: When `do_sample` is set to true, the sampling strategy is enabled. When `do_sample` is set to false, the sampling strategies such as `temperature` and `top_p` will not take effect. The default value is true.
default: true
- name: stream
label:
zh_Hans: 流处理
en_US: Event Stream
type: boolean
help:
zh_Hans: 使用同步调用时,此参数应当设置为 fasle 或者省略。表示模型生成完所有内容后一次性返回所有内容。默认值为 false。如果设置为 true,模型将通过标准 Event Stream ,逐块返回模型生成内容。Event Stream 结束时会返回一条data:[DONE]消息。注意:在模型流式输出生成内容的过程中,我们会分批对模型生成内容进行检测,当检测到违法及不良信息时,API会返回错误码(1301)。开发者识别到错误码(1301),应及时采取(清屏、重启对话)等措施删除生成内容,并确保不将含有违法及不良信息的内容传递给模型继续生成,避免其造成负面影响。
en_US: When using synchronous invocation, this parameter should be set to false or omitted. It indicates that the model will return all the generated content at once after the generation is complete. The default value is false. If set to true, the model will return the generated content in chunks via the standard Event Stream. A data:[DONE] message will be sent at the end of the Event Stream.Note:During the model's streaming output process, we will batch check the generated content. If illegal or harmful information is detected, the API will return an error code (1301). Developers who identify error code (1301) should promptly take actions such as clearing the screen or restarting the conversation to delete the generated content. They should also ensure that no illegal or harmful content is passed back to the model for continued generation to avoid negative impacts.
default: false
- name: return_type
label:
zh_Hans: 回复类型
Expand Down
23 changes: 16 additions & 7 deletions api/core/model_runtime/model_providers/zhipuai/llm/glm-4-0520.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,29 @@ parameter_rules:
help:
zh_Hans: 用温度取样的另一种方法,称为核取样取值范围是:(0.0, 1.0) 开区间,不能等于 0 或 1,默认值为 0.7 模型考虑具有 top_p 概率质量tokens的结果例如:0.1 意味着模型解码器只考虑从前 10% 的概率的候选集中取 tokens 建议您根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数。
en_US: Another method of temperature sampling is called kernel sampling. The value range is (0.0, 1.0) open interval, which cannot be equal to 0 or 1. The default value is 0.7. The model considers the results with top_p probability mass tokens. For example 0.1 means The model decoder only considers tokens from the candidate set with the top 10% probability. It is recommended that you adjust the top_p or temperature parameters according to the application scenario, but do not adjust both parameters at the same time.
- name: incremental
- name: do_sample
label:
zh_Hans: 增量返回
en_US: Incremental
zh_Hans: 采样策略
en_US: Sampling strategy
type: boolean
help:
zh_Hans: SSE接口调用时,用于控制每次返回内容方式是增量还是全量,不提供此参数时默认为增量返回,true 为增量返回,false 为全量返回。
en_US: When the SSE interface is called, it is used to control whether the content is returned incrementally or in full. If this parameter is not provided, the default is incremental return. true means incremental return, false means full return.
required: false
zh_Hans: do_sample 为 true 时启用采样策略,do_sample 为 false 时采样策略 temperature、top_p 将不生效。默认值为 true。
en_US: When `do_sample` is set to true, the sampling strategy is enabled. When `do_sample` is set to false, the sampling strategies such as `temperature` and `top_p` will not take effect. The default value is true.
default: true
- name: stream
label:
zh_Hans: 流处理
en_US: Event Stream
type: boolean
help:
zh_Hans: 使用同步调用时,此参数应当设置为 fasle 或者省略。表示模型生成完所有内容后一次性返回所有内容。默认值为 false。如果设置为 true,模型将通过标准 Event Stream ,逐块返回模型生成内容。Event Stream 结束时会返回一条data:[DONE]消息。注意:在模型流式输出生成内容的过程中,我们会分批对模型生成内容进行检测,当检测到违法及不良信息时,API会返回错误码(1301)。开发者识别到错误码(1301),应及时采取(清屏、重启对话)等措施删除生成内容,并确保不将含有违法及不良信息的内容传递给模型继续生成,避免其造成负面影响。
en_US: When using synchronous invocation, this parameter should be set to false or omitted. It indicates that the model will return all the generated content at once after the generation is complete. The default value is false. If set to true, the model will return the generated content in chunks via the standard Event Stream. A data:[DONE] message will be sent at the end of the Event Stream.Note:During the model's streaming output process, we will batch check the generated content. If illegal or harmful information is detected, the API will return an error code (1301). Developers who identify error code (1301) should promptly take actions such as clearing the screen or restarting the conversation to delete the generated content. They should also ensure that no illegal or harmful content is passed back to the model for continued generation to avoid negative impacts.
default: false
- name: max_tokens
use_template: max_tokens
default: 1024
min: 1
max: 8192
max: 4095
pricing:
input: '0.1'
output: '0.1'
Expand Down
23 changes: 16 additions & 7 deletions api/core/model_runtime/model_providers/zhipuai/llm/glm-4-air.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,29 @@ parameter_rules:
help:
zh_Hans: 用温度取样的另一种方法,称为核取样取值范围是:(0.0, 1.0) 开区间,不能等于 0 或 1,默认值为 0.7 模型考虑具有 top_p 概率质量tokens的结果例如:0.1 意味着模型解码器只考虑从前 10% 的概率的候选集中取 tokens 建议您根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数。
en_US: Another method of temperature sampling is called kernel sampling. The value range is (0.0, 1.0) open interval, which cannot be equal to 0 or 1. The default value is 0.7. The model considers the results with top_p probability mass tokens. For example 0.1 means The model decoder only considers tokens from the candidate set with the top 10% probability. It is recommended that you adjust the top_p or temperature parameters according to the application scenario, but do not adjust both parameters at the same time.
- name: incremental
- name: do_sample
label:
zh_Hans: 增量返回
en_US: Incremental
zh_Hans: 采样策略
en_US: Sampling strategy
type: boolean
help:
zh_Hans: SSE接口调用时,用于控制每次返回内容方式是增量还是全量,不提供此参数时默认为增量返回,true 为增量返回,false 为全量返回。
en_US: When the SSE interface is called, it is used to control whether the content is returned incrementally or in full. If this parameter is not provided, the default is incremental return. true means incremental return, false means full return.
required: false
zh_Hans: do_sample 为 true 时启用采样策略,do_sample 为 false 时采样策略 temperature、top_p 将不生效。默认值为 true。
en_US: When `do_sample` is set to true, the sampling strategy is enabled. When `do_sample` is set to false, the sampling strategies such as `temperature` and `top_p` will not take effect. The default value is true.
default: true
- name: stream
label:
zh_Hans: 流处理
en_US: Event Stream
type: boolean
help:
zh_Hans: 使用同步调用时,此参数应当设置为 fasle 或者省略。表示模型生成完所有内容后一次性返回所有内容。默认值为 false。如果设置为 true,模型将通过标准 Event Stream ,逐块返回模型生成内容。Event Stream 结束时会返回一条data:[DONE]消息。注意:在模型流式输出生成内容的过程中,我们会分批对模型生成内容进行检测,当检测到违法及不良信息时,API会返回错误码(1301)。开发者识别到错误码(1301),应及时采取(清屏、重启对话)等措施删除生成内容,并确保不将含有违法及不良信息的内容传递给模型继续生成,避免其造成负面影响。
en_US: When using synchronous invocation, this parameter should be set to false or omitted. It indicates that the model will return all the generated content at once after the generation is complete. The default value is false. If set to true, the model will return the generated content in chunks via the standard Event Stream. A data:[DONE] message will be sent at the end of the Event Stream.Note:During the model's streaming output process, we will batch check the generated content. If illegal or harmful information is detected, the API will return an error code (1301). Developers who identify error code (1301) should promptly take actions such as clearing the screen or restarting the conversation to delete the generated content. They should also ensure that no illegal or harmful content is passed back to the model for continued generation to avoid negative impacts.
default: false
- name: max_tokens
use_template: max_tokens
default: 1024
min: 1
max: 8192
max: 4095
pricing:
input: '0.001'
output: '0.001'
Expand Down
Loading