fix:统一llm请求函数,改动模型名称
This commit is contained in:
@@ -426,8 +426,8 @@ class ConfigEditor:
|
||||
# "model.memory_summary": "记忆概括模型",
|
||||
# "model.vlm": "图像识别模型",
|
||||
# "model.embedding": "嵌入模型",
|
||||
# "model.normal_chat_1": "普通聊天:主要聊天模型",
|
||||
# "model.normal_chat_2": "普通聊天:次要聊天模型",
|
||||
# "model.replyer_1": "普通聊天:主要聊天模型",
|
||||
# "model.replyer_2": "普通聊天:次要聊天模型",
|
||||
# "model.focus_working_memory": "专注模式:工作记忆模型",
|
||||
# "model.focus_tool_use": "专注模式:工具调用模型",
|
||||
# "model.focus_planner": "专注模式:决策模型",
|
||||
@@ -489,12 +489,11 @@ class ConfigEditor:
|
||||
"model.memory_summary": "记忆概括模型",
|
||||
"model.vlm": "图像识别模型",
|
||||
"model.embedding": "嵌入模型",
|
||||
"model.normal_chat_1": "主要聊天模型",
|
||||
"model.normal_chat_2": "次要聊天模型",
|
||||
"model.replyer_1": "主要聊天模型",
|
||||
"model.replyer_2": "次要聊天模型",
|
||||
"model.focus_working_memory": "工作记忆模型",
|
||||
"model.focus_tool_use": "工具调用模型",
|
||||
"model.focus_planner": "决策模型",
|
||||
"model.focus_expressor": "表达器模型",
|
||||
}
|
||||
section_trans = self.translations.get("sections", {}).get(full_section_path, {})
|
||||
section_name = section_trans.get("name") or section_translations.get(full_section_path) or section
|
||||
|
||||
@@ -76,8 +76,7 @@ class DefaultExpressor:
|
||||
self.log_prefix = "expressor"
|
||||
# TODO: API-Adapter修改标记
|
||||
self.express_model = LLMRequest(
|
||||
model=global_config.model.focus_expressor,
|
||||
# temperature=global_config.model.focus_expressor["temp"],
|
||||
model=global_config.model.replyer_1,
|
||||
max_tokens=256,
|
||||
request_type="focus.expressor",
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ class ExpressionLearner:
|
||||
def __init__(self) -> None:
|
||||
# TODO: API-Adapter修改标记
|
||||
self.express_learn_model: LLMRequest = LLMRequest(
|
||||
model=global_config.model.focus_expressor,
|
||||
model=global_config.model.replyer_1,
|
||||
temperature=0.1,
|
||||
max_tokens=256,
|
||||
request_type="expressor.learner",
|
||||
|
||||
@@ -28,9 +28,7 @@ def init_prompt():
|
||||
|
||||
请仔细分析聊天内容,考虑以下几点:
|
||||
1. 内容中是否包含需要查询信息的问题
|
||||
2. 是否需要执行特定操作
|
||||
3. 是否有明确的工具使用指令
|
||||
4. 考虑用户与你的关系以及当前的对话氛围
|
||||
2. 是否有明确的工具使用指令
|
||||
|
||||
If you need to use a tool, please directly call the corresponding tool function. If you do not need to use any tool, simply output "No tool needed".
|
||||
"""
|
||||
@@ -146,23 +144,27 @@ class ToolProcessor(BaseProcessor):
|
||||
prompt = await global_prompt_manager.format_prompt(
|
||||
"tool_executor_prompt",
|
||||
memory_str=memory_str,
|
||||
# extra_info="extra_structured_info",
|
||||
chat_observe_info=chat_observe_info,
|
||||
# chat_target_name=chat_target_name,
|
||||
is_group_chat=is_group_chat,
|
||||
# relation_prompt=relation_prompt,
|
||||
# prompt_personality=prompt_personality,
|
||||
# mood_info=mood_info,
|
||||
bot_name=individuality.name,
|
||||
time_now=time_now,
|
||||
)
|
||||
|
||||
# 调用LLM,专注于工具使用
|
||||
logger.debug(f"开始执行工具调用{prompt}")
|
||||
response, _, tool_calls = await self.llm_model.generate_response_tool_async(prompt=prompt, tools=tools)
|
||||
# logger.info(f"开始执行工具调用{prompt}")
|
||||
response, other_info = await self.llm_model.generate_response_async(
|
||||
prompt=prompt, tools=tools
|
||||
)
|
||||
|
||||
if len(other_info) == 3:
|
||||
reasoning_content, model_name, tool_calls = other_info
|
||||
else:
|
||||
reasoning_content, model_name = other_info
|
||||
tool_calls = None
|
||||
|
||||
# print("tooltooltooltooltooltooltooltooltooltooltooltooltooltooltooltooltool")
|
||||
if tool_calls:
|
||||
logger.debug(f"获取到工具原始输出:\n{tool_calls}")
|
||||
logger.info(f"获取到工具原始输出:\n{tool_calls}")
|
||||
# 处理工具调用和结果收集,类似于SubMind中的逻辑
|
||||
new_structured_items = []
|
||||
used_tools = [] # 记录使用了哪些工具
|
||||
|
||||
@@ -112,14 +112,9 @@ class MemoryActivator:
|
||||
|
||||
# logger.debug(f"prompt: {prompt}")
|
||||
|
||||
response = await self.summary_model.generate_response(prompt)
|
||||
response, (reasoning_content, model_name) = await self.summary_model.generate_response_async(prompt)
|
||||
|
||||
# logger.debug(f"response: {response}")
|
||||
|
||||
# 只取response的第一个元素(字符串)
|
||||
response_str = response[0]
|
||||
# print(f"response_str: {response_str[1]}")
|
||||
keywords = list(get_keywords_from_json(response_str))
|
||||
keywords = list(get_keywords_from_json(response))
|
||||
|
||||
# 更新关键词缓存
|
||||
if keywords:
|
||||
|
||||
@@ -123,12 +123,13 @@ class EmojiAction(BaseAction):
|
||||
)
|
||||
|
||||
reply_text = ""
|
||||
for reply in reply_set:
|
||||
type = reply[0]
|
||||
data = reply[1]
|
||||
if type == "text":
|
||||
reply_text += data
|
||||
elif type == "emoji":
|
||||
reply_text += data
|
||||
if reply_set:
|
||||
for reply in reply_set:
|
||||
type = reply[0]
|
||||
data = reply[1]
|
||||
if type == "text":
|
||||
reply_text += data
|
||||
elif type == "emoji":
|
||||
reply_text += data
|
||||
|
||||
return success, reply_text
|
||||
|
||||
@@ -87,8 +87,7 @@ class DefaultReplyer:
|
||||
self.log_prefix = "replyer"
|
||||
# TODO: API-Adapter修改标记
|
||||
self.express_model = LLMRequest(
|
||||
model=global_config.model.focus_expressor,
|
||||
# temperature=global_config.model.focus_expressor["temp"],
|
||||
model=global_config.model.replyer_1,
|
||||
max_tokens=256,
|
||||
request_type="focus.expressor",
|
||||
)
|
||||
|
||||
@@ -346,10 +346,10 @@ class Hippocampus:
|
||||
# 使用LLM提取关键词
|
||||
topic_num = min(5, max(1, int(len(text) * 0.1))) # 根据文本长度动态调整关键词数量
|
||||
# logger.info(f"提取关键词数量: {topic_num}")
|
||||
topics_response = await self.model_summary.generate_response(self.find_topic_llm(text, topic_num))
|
||||
topics_response, (reasoning_content, model_name) = await self.model_summary.generate_response_async(self.find_topic_llm(text, topic_num))
|
||||
|
||||
# 提取关键词
|
||||
keywords = re.findall(r"<([^>]+)>", topics_response[0])
|
||||
keywords = re.findall(r"<([^>]+)>", topics_response)
|
||||
if not keywords:
|
||||
keywords = []
|
||||
else:
|
||||
@@ -701,10 +701,10 @@ class Hippocampus:
|
||||
# 使用LLM提取关键词
|
||||
topic_num = min(5, max(1, int(len(text) * 0.1))) # 根据文本长度动态调整关键词数量
|
||||
# logger.info(f"提取关键词数量: {topic_num}")
|
||||
topics_response = await self.model_summary.generate_response(self.find_topic_llm(text, topic_num))
|
||||
topics_response, (reasoning_content, model_name) = await self.model_summary.generate_response_async(self.find_topic_llm(text, topic_num))
|
||||
|
||||
# 提取关键词
|
||||
keywords = re.findall(r"<([^>]+)>", topics_response[0])
|
||||
keywords = re.findall(r"<([^>]+)>", topics_response)
|
||||
if not keywords:
|
||||
keywords = []
|
||||
else:
|
||||
@@ -1248,12 +1248,12 @@ class ParahippocampalGyrus:
|
||||
|
||||
# 2. 使用LLM提取关键主题
|
||||
topic_num = self.hippocampus.calculate_topic_num(input_text, compress_rate)
|
||||
topics_response = await self.hippocampus.model_summary.generate_response(
|
||||
topics_response, (reasoning_content, model_name) = await self.hippocampus.model_summary.generate_response_async(
|
||||
self.hippocampus.find_topic_llm(input_text, topic_num)
|
||||
)
|
||||
|
||||
# 提取<>中的内容
|
||||
topics = re.findall(r"<([^>]+)>", topics_response[0])
|
||||
topics = re.findall(r"<([^>]+)>", topics_response)
|
||||
|
||||
if not topics:
|
||||
topics = ["none"]
|
||||
|
||||
@@ -18,14 +18,14 @@ class NormalChatGenerator:
|
||||
def __init__(self):
|
||||
# TODO: API-Adapter修改标记
|
||||
self.model_reasoning = LLMRequest(
|
||||
model=global_config.model.normal_chat_1,
|
||||
model=global_config.model.replyer_1,
|
||||
# temperature=0.7,
|
||||
max_tokens=3000,
|
||||
request_type="normal.chat_1",
|
||||
)
|
||||
self.model_normal = LLMRequest(
|
||||
model=global_config.model.normal_chat_2,
|
||||
# temperature=global_config.model.normal_chat_2["temp"],
|
||||
model=global_config.model.replyer_2,
|
||||
# temperature=global_config.model.replyer_2["temp"],
|
||||
max_tokens=256,
|
||||
request_type="normal.chat_2",
|
||||
)
|
||||
@@ -103,7 +103,7 @@ class NormalChatGenerator:
|
||||
logger.debug(f"构建prompt时间: {t_build_prompt.human_readable}")
|
||||
|
||||
try:
|
||||
content, reasoning_content, self.current_model_name = await model.generate_response(prompt)
|
||||
content, (reasoning_content, model_name) = await model.generate_response_async(prompt)
|
||||
|
||||
logger.debug(f"prompt:{prompt}\n生成回复:{content}")
|
||||
|
||||
@@ -147,7 +147,7 @@ class NormalChatGenerator:
|
||||
"""
|
||||
|
||||
# 调用模型生成结果
|
||||
result, _, _ = await self.model_sum.generate_response(prompt)
|
||||
result, (reasoning_content, model_name) = await self.model_sum.generate_response_async(prompt)
|
||||
result = result.strip()
|
||||
|
||||
# 解析模型输出的结果
|
||||
|
||||
@@ -148,10 +148,12 @@ class NormalChatPlanner:
|
||||
|
||||
# 使用LLM生成动作决策
|
||||
try:
|
||||
content, reasoning_content, model_name = await self.planner_llm.generate_response(prompt)
|
||||
content, (reasoning_content, model_name) = await self.planner_llm.generate_response_async(prompt)
|
||||
|
||||
logger.info(f"{self.log_prefix}规划器原始提示词: {prompt}")
|
||||
logger.info(f"{self.log_prefix}规划器原始响应: {content}")
|
||||
logger.info(f"{self.log_prefix}规划器推理: {reasoning_content}")
|
||||
logger.info(f"{self.log_prefix}规划器模型: {model_name}")
|
||||
|
||||
# 解析JSON响应
|
||||
try:
|
||||
|
||||
@@ -424,10 +424,10 @@ class ModelConfig(ConfigBase):
|
||||
utils_small: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""组件小模型配置"""
|
||||
|
||||
normal_chat_1: dict[str, Any] = field(default_factory=lambda: {})
|
||||
replyer_1: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""normal_chat首要回复模型模型配置"""
|
||||
|
||||
normal_chat_2: dict[str, Any] = field(default_factory=lambda: {})
|
||||
replyer_2: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""normal_chat次要回复模型配置"""
|
||||
|
||||
memory_summary: dict[str, Any] = field(default_factory=lambda: {})
|
||||
@@ -449,9 +449,6 @@ class ModelConfig(ConfigBase):
|
||||
relation: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""关系模型配置"""
|
||||
|
||||
focus_expressor: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""专注表达器模型配置"""
|
||||
|
||||
embedding: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""嵌入模型配置"""
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def init_prompt() -> None:
|
||||
class PersonalityExpression:
|
||||
def __init__(self):
|
||||
self.express_learn_model: LLMRequest = LLMRequest(
|
||||
model=global_config.model.focus_expressor,
|
||||
model=global_config.model.replyer_1,
|
||||
max_tokens=512,
|
||||
request_type="expressor.learner",
|
||||
)
|
||||
|
||||
@@ -500,11 +500,11 @@ class LLMRequest:
|
||||
logger.warning(f"检测到403错误,模型从 {old_model_name} 降级为 {self.model_name}")
|
||||
|
||||
# 对全局配置进行更新
|
||||
if global_config.model.normal_chat_2.get("name") == old_model_name:
|
||||
global_config.model.normal_chat_2["name"] = self.model_name
|
||||
if global_config.model.replyer_2.get("name") == old_model_name:
|
||||
global_config.model.replyer_2["name"] = self.model_name
|
||||
logger.warning(f"将全局配置中的 llm_normal 模型临时降级至{self.model_name}")
|
||||
if global_config.model.normal_chat_1.get("name") == old_model_name:
|
||||
global_config.model.normal_chat_1["name"] = self.model_name
|
||||
if global_config.model.replyer_1.get("name") == old_model_name:
|
||||
global_config.model.replyer_1["name"] = self.model_name
|
||||
logger.warning(f"将全局配置中的 llm_reasoning 模型临时降级至{self.model_name}")
|
||||
|
||||
if payload and "model" in payload:
|
||||
@@ -715,18 +715,6 @@ class LLMRequest:
|
||||
return {"Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json"}
|
||||
# 防止小朋友们截图自己的key
|
||||
|
||||
async def generate_response(self, prompt: str) -> Tuple:
|
||||
"""根据输入的提示生成模型的异步响应"""
|
||||
|
||||
response = await self._execute_request(endpoint="/chat/completions", prompt=prompt)
|
||||
# 根据返回值的长度决定怎么处理
|
||||
if len(response) == 3:
|
||||
content, reasoning_content, tool_calls = response
|
||||
return content, reasoning_content, self.model_name, tool_calls
|
||||
else:
|
||||
content, reasoning_content = response
|
||||
return content, reasoning_content, self.model_name
|
||||
|
||||
async def generate_response_for_image(self, prompt: str, image_base64: str, image_format: str) -> Tuple:
|
||||
"""根据输入的提示和图片生成模型的异步响应"""
|
||||
|
||||
@@ -761,29 +749,6 @@ class LLMRequest:
|
||||
content, reasoning_content = response
|
||||
return content, (reasoning_content, self.model_name)
|
||||
|
||||
async def generate_response_tool_async(self, prompt: str, tools: list, **kwargs) -> tuple[str, str, list]:
|
||||
"""异步方式根据输入的提示生成模型的响应"""
|
||||
# 构建请求体,不硬编码max_tokens
|
||||
data = {
|
||||
"model": self.model_name,
|
||||
"messages": [{"role": "user", "content": prompt}],
|
||||
**self.params,
|
||||
**kwargs,
|
||||
"tools": tools,
|
||||
}
|
||||
|
||||
response = await self._execute_request(endpoint="/chat/completions", payload=data, prompt=prompt)
|
||||
logger.debug(f"向模型 {self.model_name} 发送工具调用请求,包含 {len(tools)} 个工具,返回结果: {response}")
|
||||
# 检查响应是否包含工具调用
|
||||
if len(response) == 3:
|
||||
content, reasoning_content, tool_calls = response
|
||||
logger.debug(f"收到工具调用响应,包含 {len(tool_calls) if tool_calls else 0} 个工具调用")
|
||||
return content, reasoning_content, tool_calls
|
||||
else:
|
||||
content, reasoning_content = response
|
||||
logger.debug("收到普通响应,无工具调用")
|
||||
return content, reasoning_content, None
|
||||
|
||||
async def get_embedding(self, text: str) -> Union[list, None]:
|
||||
"""异步方法:获取文本的embedding向量
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class PersonInfoManager:
|
||||
old_name = await self.get_value(person_id, "person_name")
|
||||
old_reason = await self.get_value(person_id, "name_reason")
|
||||
|
||||
max_retries = 5
|
||||
max_retries = 8
|
||||
current_try = 0
|
||||
existing_names_str = ""
|
||||
current_name_set = set(self.person_name_list.values())
|
||||
@@ -269,7 +269,7 @@ class PersonInfoManager:
|
||||
"nickname": "昵称",
|
||||
"reason": "理由"
|
||||
}"""
|
||||
response = await self.qv_name_llm.generate_response(qv_name_prompt)
|
||||
response, (reasoning_content, model_name) = await self.qv_name_llm.generate_response_async(qv_name_prompt)
|
||||
logger.trace(f"取名提示词:{qv_name_prompt}\n取名回复:{response}")
|
||||
result = self._extract_json_from_text(response[0])
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
from src.tools.tool_can_use.base_tool import BaseTool
|
||||
from src.chat.memory_system.Hippocampus import HippocampusManager
|
||||
from src.common.logger import get_module_logger
|
||||
from typing import Dict, Any
|
||||
|
||||
logger = get_module_logger("mid_chat_mem_tool")
|
||||
|
||||
|
||||
class GetMemoryTool(BaseTool):
|
||||
"""从记忆系统中获取相关记忆的工具"""
|
||||
|
||||
name = "get_memory"
|
||||
description = "使用工具从记忆系统中获取相关记忆"
|
||||
parameters = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topic": {"type": "string", "description": "要查询的相关主题,用逗号隔开"},
|
||||
"max_memory_num": {"type": "integer", "description": "最大返回记忆数量"},
|
||||
},
|
||||
"required": ["topic"],
|
||||
}
|
||||
|
||||
async def execute(self, function_args: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""执行记忆获取
|
||||
|
||||
Args:
|
||||
function_args: 工具参数
|
||||
|
||||
Returns:
|
||||
Dict: 工具执行结果
|
||||
"""
|
||||
try:
|
||||
topic = function_args.get("topic")
|
||||
max_memory_num = function_args.get("max_memory_num", 2)
|
||||
|
||||
# 将主题字符串转换为列表
|
||||
topic_list = topic.split(",")
|
||||
|
||||
# 调用记忆系统
|
||||
related_memory = await HippocampusManager.get_instance().get_memory_from_topic(
|
||||
valid_keywords=topic_list, max_memory_num=max_memory_num, max_memory_length=2, max_depth=3
|
||||
)
|
||||
|
||||
memory_info = ""
|
||||
if related_memory:
|
||||
for memory in related_memory:
|
||||
memory_info += memory[1] + "\n"
|
||||
|
||||
if memory_info:
|
||||
content = f"你记得这些事情: {memory_info}\n"
|
||||
content += "以上是你的回忆,不一定是目前聊天里的人说的,也不一定是现在发生的事情,请记住。\n"
|
||||
|
||||
else:
|
||||
content = f"{topic}的记忆,你记不太清"
|
||||
|
||||
return {"type": "memory", "id": topic_list, "content": content}
|
||||
except Exception as e:
|
||||
logger.error(f"记忆获取工具执行失败: {str(e)}")
|
||||
# 在失败时也保持格式一致,但id可能不适用或设为None/Error
|
||||
return {"type": "memory_error", "id": topic_list, "content": f"记忆获取失败: {str(e)}"}
|
||||
|
||||
|
||||
# 注册工具
|
||||
# register_tool(GetMemoryTool)
|
||||
@@ -1,5 +1,5 @@
|
||||
[inner]
|
||||
version = "2.12.2"
|
||||
version = "2.13.0"
|
||||
|
||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||
@@ -72,7 +72,7 @@ ban_msgs_regex = [
|
||||
|
||||
[normal_chat] #普通聊天
|
||||
#一般回复参数
|
||||
normal_chat_first_probability = 0.3 # 麦麦回答时选择首要模型的概率(与之相对的,次要模型的概率为1 - normal_chat_first_probability)
|
||||
normal_chat_first_probability = 0.5 # 麦麦回答时选择首要模型的概率(与之相对的,次要模型的概率为1 - normal_chat_first_probability)
|
||||
max_context_size = 15 #上下文长度
|
||||
emoji_chance = 0.2 # 麦麦一般回复时使用表情包的概率,设置为1让麦麦自己决定发不发
|
||||
thinking_timeout = 120 # 麦麦最长思考时间,超过这个时间的思考会放弃(往往是api反应太慢)
|
||||
@@ -200,6 +200,22 @@ pri_out = 0
|
||||
temp = 0.7
|
||||
enable_thinking = false # 是否启用思考
|
||||
|
||||
[model.replyer_1] # 首要回复模型,还用于表达器和表达方式学习
|
||||
name = "Pro/deepseek-ai/DeepSeek-V3"
|
||||
provider = "SILICONFLOW"
|
||||
pri_in = 2 #模型的输入价格(非必填,可以记录消耗)
|
||||
pri_out = 8 #模型的输出价格(非必填,可以记录消耗)
|
||||
#默认temp 0.2 如果你使用的是老V3或者其他模型,请自己修改temp参数
|
||||
temp = 0.2 #模型的温度,新V3建议0.1-0.3
|
||||
|
||||
[model.replyer_2] # 一般聊天模式的次要回复模型
|
||||
name = "Pro/deepseek-ai/DeepSeek-R1"
|
||||
provider = "SILICONFLOW"
|
||||
pri_in = 4.0 #模型的输入价格(非必填,可以记录消耗)
|
||||
pri_out = 16.0 #模型的输出价格(非必填,可以记录消耗)
|
||||
temp = 0.7
|
||||
|
||||
|
||||
[model.memory_summary] # 记忆的概括模型
|
||||
name = "Qwen/Qwen3-30B-A3B"
|
||||
provider = "SILICONFLOW"
|
||||
@@ -236,23 +252,6 @@ provider = "SILICONFLOW"
|
||||
pri_in = 0
|
||||
pri_out = 0
|
||||
|
||||
#------------普通聊天必填模型------------
|
||||
|
||||
[model.normal_chat_1] # 一般聊天模式的首要回复模型,推荐使用 推理模型
|
||||
name = "Pro/deepseek-ai/DeepSeek-R1"
|
||||
provider = "SILICONFLOW"
|
||||
pri_in = 4.0 #模型的输入价格(非必填,可以记录消耗)
|
||||
pri_out = 16.0 #模型的输出价格(非必填,可以记录消耗)
|
||||
temp = 0.7
|
||||
|
||||
[model.normal_chat_2] # 一般聊天模式的次要回复模型,推荐使用 非推理模型
|
||||
name = "Pro/deepseek-ai/DeepSeek-V3"
|
||||
provider = "SILICONFLOW"
|
||||
pri_in = 2 #模型的输入价格(非必填,可以记录消耗)
|
||||
pri_out = 8 #模型的输出价格(非必填,可以记录消耗)
|
||||
#默认temp 0.2 如果你使用的是老V3或者其他模型,请自己修改temp参数
|
||||
temp = 0.2 #模型的温度,新V3建议0.1-0.3
|
||||
|
||||
#------------专注聊天必填模型------------
|
||||
|
||||
[model.focus_working_memory] #工作记忆模型
|
||||
@@ -272,16 +271,7 @@ pri_out = 2
|
||||
temp = 0.7
|
||||
enable_thinking = false # 是否启用思考(qwen3 only)
|
||||
|
||||
#表达器模型,用于表达麦麦的想法,生成最终回复,对语言风格影响极大
|
||||
#也用于表达方式学习
|
||||
[model.focus_expressor]
|
||||
name = "Pro/deepseek-ai/DeepSeek-V3"
|
||||
# name = "Qwen/Qwen3-30B-A3B"
|
||||
provider = "SILICONFLOW"
|
||||
# enable_thinking = false # 是否启用思考(qwen3 only)
|
||||
pri_in = 2
|
||||
pri_out = 8
|
||||
temp = 0.3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
44
tests/test_utils_model.py
Normal file
44
tests/test_utils_model.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import asyncio
|
||||
import pytest
|
||||
from src.llm_models.utils_model import LLMRequest
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 加载环境变量
|
||||
load_dotenv()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_model_request():
|
||||
# 创建模型配置
|
||||
model_config = {
|
||||
"name": "deepseek-v3", # 使用测试模型
|
||||
"provider": "CHATANY", # 使用测试提供商
|
||||
"temp": 0.3,
|
||||
"enable_thinking": False
|
||||
}
|
||||
|
||||
# 创建LLMRequest实例
|
||||
llm = LLMRequest(model=model_config)
|
||||
|
||||
# 测试提示词
|
||||
test_prompt = "你好,请做个自我介绍"
|
||||
|
||||
try:
|
||||
# 测试生成响应
|
||||
content, (reasoning_content, model_name) = await llm.generate_response_async(test_prompt)
|
||||
|
||||
# 打印结果
|
||||
print(f"\n模型名称: {model_name}")
|
||||
print(f"回复内容: {content}")
|
||||
print(f"推理内容: {reasoning_content}")
|
||||
|
||||
# 基本断言
|
||||
assert content is not None, "回复内容不应为空"
|
||||
assert isinstance(content, str), "回复内容应为字符串"
|
||||
|
||||
except Exception as e:
|
||||
pytest.fail(f"测试失败: {str(e)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 直接运行测试
|
||||
asyncio.run(test_model_request())
|
||||
Reference in New Issue
Block a user