mirror of https://github.com/Mai-with-u/MaiBot.git
feat: 添加模型级别最大token数配置,并更新相关逻辑以支持优先级处理
parent
6680afaa4a
commit
12bc661790
|
|
@ -63,6 +63,9 @@ class ModelInfo(ConfigBase):
|
||||||
temperature: float | None = field(default=None)
|
temperature: float | None = field(default=None)
|
||||||
"""模型级别温度(可选),会覆盖任务配置中的温度"""
|
"""模型级别温度(可选),会覆盖任务配置中的温度"""
|
||||||
|
|
||||||
|
max_tokens: int | None = field(default=None)
|
||||||
|
"""模型级别最大token数(可选),会覆盖任务配置中的max_tokens"""
|
||||||
|
|
||||||
force_stream_mode: bool = field(default=False)
|
force_stream_mode: bool = field(default=False)
|
||||||
"""是否强制使用流式输出模式"""
|
"""是否强制使用流式输出模式"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -324,11 +324,20 @@ class LLMRequest:
|
||||||
if effective_temperature is None:
|
if effective_temperature is None:
|
||||||
effective_temperature = self.model_for_task.temperature
|
effective_temperature = self.model_for_task.temperature
|
||||||
|
|
||||||
|
# max_tokens 优先级:参数传入 > 模型级别配置 > extra_params > 任务配置
|
||||||
|
effective_max_tokens = max_tokens
|
||||||
|
if effective_max_tokens is None:
|
||||||
|
effective_max_tokens = model_info.max_tokens
|
||||||
|
if effective_max_tokens is None:
|
||||||
|
effective_max_tokens = (model_info.extra_params or {}).get("max_tokens")
|
||||||
|
if effective_max_tokens is None:
|
||||||
|
effective_max_tokens = self.model_for_task.max_tokens
|
||||||
|
|
||||||
return await client.get_response(
|
return await client.get_response(
|
||||||
model_info=model_info,
|
model_info=model_info,
|
||||||
message_list=(compressed_messages or message_list),
|
message_list=(compressed_messages or message_list),
|
||||||
tool_options=tool_options,
|
tool_options=tool_options,
|
||||||
max_tokens=self.model_for_task.max_tokens if max_tokens is None else max_tokens,
|
max_tokens=effective_max_tokens,
|
||||||
temperature=effective_temperature,
|
temperature=effective_temperature,
|
||||||
response_format=response_format,
|
response_format=response_format,
|
||||||
stream_response_handler=stream_response_handler,
|
stream_response_handler=stream_response_handler,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[inner]
|
[inner]
|
||||||
version = "1.8.2"
|
version = "1.9.0"
|
||||||
|
|
||||||
# 配置文件版本号迭代规则同bot_config.toml
|
# 配置文件版本号迭代规则同bot_config.toml
|
||||||
|
|
||||||
|
|
@ -54,9 +54,11 @@ name = "siliconflow-deepseek-v3.2"
|
||||||
api_provider = "SiliconFlow"
|
api_provider = "SiliconFlow"
|
||||||
price_in = 2.0
|
price_in = 2.0
|
||||||
price_out = 3.0
|
price_out = 3.0
|
||||||
|
# temperature = 0.5 # 可选:为该模型单独指定温度,会覆盖任务配置中的温度
|
||||||
|
# max_tokens = 4096 # 可选:为该模型单独指定最大token数,会覆盖任务配置中的max_tokens
|
||||||
[models.extra_params] # 可选的额外参数配置
|
[models.extra_params] # 可选的额外参数配置
|
||||||
enable_thinking = false # 不启用思考
|
enable_thinking = false # 不启用思考
|
||||||
# temperature = 0.5 # 可选:为该模型单独指定温度,会覆盖任务配置中的温度
|
|
||||||
|
|
||||||
[[models]]
|
[[models]]
|
||||||
model_identifier = "deepseek-ai/DeepSeek-V3.2-Exp"
|
model_identifier = "deepseek-ai/DeepSeek-V3.2-Exp"
|
||||||
|
|
@ -64,9 +66,11 @@ name = "siliconflow-deepseek-v3.2-think"
|
||||||
api_provider = "SiliconFlow"
|
api_provider = "SiliconFlow"
|
||||||
price_in = 2.0
|
price_in = 2.0
|
||||||
price_out = 3.0
|
price_out = 3.0
|
||||||
|
# temperature = 0.7 # 可选:为该模型单独指定温度,会覆盖任务配置中的温度
|
||||||
|
# max_tokens = 4096 # 可选:为该模型单独指定最大token数,会覆盖任务配置中的max_tokens
|
||||||
[models.extra_params] # 可选的额外参数配置
|
[models.extra_params] # 可选的额外参数配置
|
||||||
enable_thinking = true # 启用思考
|
enable_thinking = true # 启用思考
|
||||||
# temperature = 0.7 # 可选:为该模型单独指定温度,会覆盖任务配置中的温度
|
|
||||||
|
|
||||||
[[models]]
|
[[models]]
|
||||||
model_identifier = "Qwen/Qwen3-Next-80B-A3B-Instruct"
|
model_identifier = "Qwen/Qwen3-Next-80B-A3B-Instruct"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue