Closed Garrise closed 4 months ago
这个日志不全吧?
我先概述一下日志内容
1. 系统成功接收并开始处理来自群组xxxxxxxxx的消息"你好"
[2024-06-21 03:04:46.860] /home/garrise/QChatGPT/pkg/pipeline/process/process.py (42) - [INFO] :
处理 group_xxxxxxxxx 的请求(1): 你好
[2024-06-21 03:04:46.860] /home/garrise/QChatGPT/pkg/pipeline/controller.py (128) - [DEBUG] :
Stage MessageProcessor processed query query_id=1 launcher_type=<LauncherTypes.GROUP: 'group'> launcher_id=xxxxxxxxx sender_id=xxxxxxxxx message_event=GroupMessage(...)
2. 系统使用默认提示创建新会话,使用gpt-4-turbo模型。
session=Session(launcher_type=<LauncherTypes.GROUP: 'group'>, launcher_id=xxxxxxxxx, sender_id=0, use_prompt_name='default', using_conversation=Conversation(...))
use_model=LLMModelInfo(name='gpt-4-turbo', model_name=None, token_mgr=<pkg.provider.modelmgr.token.TokenManager object at 0x7f0d4f03c6a0>, requester=<pkg.provider.modelmgr.apis.chatcmpl.OpenAIChatCompletions object at 0x7f0d4f03dcf0>, tool_call_supported=True, vision_supported=True)
3. 插件处理:
[2024-06-21 03:04:46.861] /home/garrise/QChatGPT/pkg/plugin/manager.py (169) - [DEBUG] :
事件 GroupNormalMessageReceived(5) 处理完成,返回值 {}
(消息被当作普通群消息处理,但没有任何插件对其进行处理(返回值为空))
但是到这里戛然而止,缺少了很关键的API调用部分
日志信息是不完整的,还需要提供:
建议发一下更完整的日志,特别是API调用和消息发送的部分,这个有助于进一步诊断问题,如果没有这部分信息的话只能帮你算一卦了。
因为日志不全不能继续分析下去,这里提供一些更通用的debug方式,
from openai import OpenAI
import os
API_KEY = os.getenv(f"OPENAI_API_KEY") BASE_URL = os.getenv(f"OPENAI_BASE_URL") MODEL_NAME = "gpt-4o"
client = OpenAI(api_key=API_KEY, base_url=BASE_URL)
def get_response(): client = OpenAI(api_key=API_KEY, base_url=BASE_URL) completion = client.chat.completions.create( model=MODEL_NAME, messages=[{'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': '你是谁?你的开发者是谁?'}] ) print(completion.model_dump_json())
if name == 'main': get_response()
确保可以正常返回消息比如
```json
{
"id": "chatcmpl-xxxxxxx",
"choices": [{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "我是一个由OpenAI开发的人工智能助手。我的目的是提供信息和帮助回答问题。我没有特定的个人身份或背景,只是一个用于处理和生成自然语言文本的工具。你有什么具体的问题或需要帮助的地方吗?",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}],
"created": "xxxxxxx",
"model": "gpt-4o-2024-05-13",
"object": "chat.completion",
"system_fingerprint": "xxxxxxx",
"usage": {
"completion_tokens": 53,
"prompt_tokens": 25,
"total_tokens": 78
}
}
/pkg/provider/modelmgr/apis/chatcmpl.py
的_req函数
加上中间的print输出语句,之后在日志里面可以很清楚地看到请求参数是否正确等等,可以更迅速地定位问题。
部署方式
手动部署
消息平台适配器
yiri-mirai(Mirai)
系统环境
Ubuntu 22.04
Python环境
Python 3.11
QChatGPT版本
v3.2.2
异常情况
输入信息后,Bot不回答任何消息。 查看后台日志有接受并处理,但不返回任何信息。
日志信息
[2024-06-21 03:04:46.860] /home/garrise/QChatGPT/pkg/pipeline/process/process.py (42) - [INFO] : 处理 group_645492747 的请求(1): 你好 [2024-06-21 03:04:46.860] /home/garrise/QChatGPT/pkg/pipeline/controller.py (128) - [DEBUG] : Stage MessageProcessor processed query query_id=1 launcher_type=<LauncherTypes.GROUP: 'group'> launcher_id=645492747 sender_id=370957070 message_event=GroupMessage(message_chain=MessageChain([Source(id=-2147329964, time=datetime.datetime(1970, 1, 20, 21, 28, 59, tzinfo=datetime.timezone.utc)), Plain(' 你好')]), sender=GroupMember(id=370957070, member_name='加利斯', permission='OWNER', group=Group(id=645492747, name='哈罗测试', permission='ADMINISTRATOR'), join_timestamp=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), last_speak_timestamp=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc))) message_chain=MessageChain([Source(id=-2147329964, time=datetime.datetime(1970, 1, 20, 21, 28, 59, tzinfo=datetime.timezone.utc)), Plain(' 你好')]) adapter=<pkg.platform.sources.yirimirai.YiriMiraiAdapter object at 0x7f0d4e44cfa0> session=Session(launcher_type=<LauncherTypes.GROUP: 'group'>, launcher_id=645492747, sender_id=0, use_prompt_name='default', using_conversation=Conversation(prompt=Prompt(name='default', messages=[Message(role='system', name=None, content='', tool_calls=None, tool_call_id=None)]), messages=[], create_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 934972), update_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 934976), use_model=LLMModelInfo(name='gpt-4-turbo', model_name=None, token_mgr=<pkg.provider.modelmgr.token.TokenManager object at 0x7f0d4f03c6a0>, requester=<pkg.provider.modelmgr.apis.chatcmpl.OpenAIChatCompletions object at 0x7f0d4f03dcf0>, tool_call_supported=True, vision_supported=True), use_funcs=[]), conversations=[Conversation(prompt=Prompt(name='default', messages=[Message(role='system', name=None, content='', tool_calls=None, tool_call_id=None)]), messages=[], create_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 934972), update_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 934976), use_model=LLMModelInfo(name='gpt-4-turbo', model_name=None, token_mgr=<pkg.provider.modelmgr.token.TokenManager object at 0x7f0d4f03c6a0>, requester=<pkg.provider.modelmgr.apis.chatcmpl.OpenAIChatCompletions object at 0x7f0d4f03dcf0>, tool_call_supported=True, vision_supported=True), use_funcs=[])], create_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 931774), update_time=datetime.datetime(2024, 6, 21, 3, 4, 38, 931778), semaphore=<asyncio.locks.Semaphore object at 0x7f0d4daf0490 [locked]>) messages=[] prompt=Prompt(name='default', messages=[Message(role='system', name=None, content='', tool_calls=None, tool_call_id=None)]) user_message=Message(role='user', name=None, content=[ContentElement(type='text', text=' 你好', image_url=None)], tool_calls=None, tool_call_id=None) use_model=LLMModelInfo(name='gpt-4-turbo', model_name=None, token_mgr=<pkg.provider.modelmgr.token.TokenManager object at 0x7f0d4f03c6a0>, requester=<pkg.provider.modelmgr.apis.chatcmpl.OpenAIChatCompletions object at 0x7f0d4f03dcf0>, tool_call_supported=True, vision_supported=True) use_funcs=[] resp_messages=[] resp_message_chain=[] gen [2024-06-21 03:04:46.861] /home/garrise/QChatGPT/pkg/plugin/manager.py (169) - [DEBUG] : 事件 GroupNormalMessageReceived(5) 处理完成,返回值 {}
启用的插件
无