v0.5.0
重构了消息发送系统,口牙
This commit is contained in:
@@ -21,9 +21,9 @@ config = driver.config
|
||||
|
||||
class ResponseGenerator:
|
||||
def __init__(self):
|
||||
self.model_r1 = LLM_request(model=global_config.llm_reasoning, temperature=0.7)
|
||||
self.model_v3 = LLM_request(model=global_config.llm_normal, temperature=0.7)
|
||||
self.model_r1_distill = LLM_request(model=global_config.llm_reasoning_minor, temperature=0.7)
|
||||
self.model_r1 = LLM_request(model=global_config.llm_reasoning, temperature=0.7,max_tokens=1000)
|
||||
self.model_v3 = LLM_request(model=global_config.llm_normal, temperature=0.7,max_tokens=1000)
|
||||
self.model_r1_distill = LLM_request(model=global_config.llm_reasoning_minor, temperature=0.7,max_tokens=1000)
|
||||
self.db = Database.get_instance()
|
||||
self.current_model_type = 'r1' # 默认使用 R1
|
||||
|
||||
@@ -77,22 +77,22 @@ class ResponseGenerator:
|
||||
group_id=message.group_id
|
||||
)
|
||||
|
||||
# 读空气模块
|
||||
if global_config.enable_kuuki_read:
|
||||
content_check, reasoning_content_check = await self.model_v3.generate_response(prompt_check)
|
||||
print(f"\033[1;32m[读空气]\033[0m 读空气结果为{content_check}")
|
||||
if 'yes' not in content_check.lower() and random.random() < 0.3:
|
||||
self._save_to_db(
|
||||
message=message,
|
||||
sender_name=sender_name,
|
||||
prompt=prompt,
|
||||
prompt_check=prompt_check,
|
||||
content="",
|
||||
content_check=content_check,
|
||||
reasoning_content="",
|
||||
reasoning_content_check=reasoning_content_check
|
||||
)
|
||||
return None
|
||||
# 读空气模块 简化逻辑,先停用
|
||||
# if global_config.enable_kuuki_read:
|
||||
# content_check, reasoning_content_check = await self.model_v3.generate_response(prompt_check)
|
||||
# print(f"\033[1;32m[读空气]\033[0m 读空气结果为{content_check}")
|
||||
# if 'yes' not in content_check.lower() and random.random() < 0.3:
|
||||
# self._save_to_db(
|
||||
# message=message,
|
||||
# sender_name=sender_name,
|
||||
# prompt=prompt,
|
||||
# prompt_check=prompt_check,
|
||||
# content="",
|
||||
# content_check=content_check,
|
||||
# reasoning_content="",
|
||||
# reasoning_content_check=reasoning_content_check
|
||||
# )
|
||||
# return None
|
||||
|
||||
# 生成回复
|
||||
content, reasoning_content = await model.generate_response(prompt)
|
||||
@@ -104,15 +104,17 @@ class ResponseGenerator:
|
||||
prompt=prompt,
|
||||
prompt_check=prompt_check,
|
||||
content=content,
|
||||
content_check=content_check if global_config.enable_kuuki_read else "",
|
||||
# content_check=content_check if global_config.enable_kuuki_read else "",
|
||||
reasoning_content=reasoning_content,
|
||||
reasoning_content_check=reasoning_content_check if global_config.enable_kuuki_read else ""
|
||||
# reasoning_content_check=reasoning_content_check if global_config.enable_kuuki_read else ""
|
||||
)
|
||||
|
||||
return content
|
||||
|
||||
# def _save_to_db(self, message: Message, sender_name: str, prompt: str, prompt_check: str,
|
||||
# content: str, content_check: str, reasoning_content: str, reasoning_content_check: str):
|
||||
def _save_to_db(self, message: Message, sender_name: str, prompt: str, prompt_check: str,
|
||||
content: str, content_check: str, reasoning_content: str, reasoning_content_check: str):
|
||||
content: str, reasoning_content: str,):
|
||||
"""保存对话记录到数据库"""
|
||||
self.db.db.reasoning_logs.insert_one({
|
||||
'time': time.time(),
|
||||
@@ -120,8 +122,8 @@ class ResponseGenerator:
|
||||
'user': sender_name,
|
||||
'message': message.processed_plain_text,
|
||||
'model': self.current_model_type,
|
||||
'reasoning_check': reasoning_content_check,
|
||||
'response_check': content_check,
|
||||
# 'reasoning_check': reasoning_content_check,
|
||||
# 'response_check': content_check,
|
||||
'reasoning': reasoning_content,
|
||||
'response': content,
|
||||
'prompt': prompt,
|
||||
|
||||
Reference in New Issue
Block a user