fatwang2 / sum4all

网页、视频、图片大模型总结
MIT License
223 stars 42 forks source link

图片总结跟小红书总结 #53

Open rexinshimin0001 opened 2 months ago

rexinshimin0001 commented 2 months ago

这是私聊图片总结的报错, 1714268527822 User [DEBUG][2024-04-28 09:20:58][wechat_channel.py:176] - [WX]receive image msg: tmp/240428-092058.png [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin SUMMARY triggered by event Event.ON_RECEIVE_MESSAGE [DEBUG][2024-04-28 09:20:58][main.py:90] - [Summary] insert record: 韩 4959949438074564357 韩 tmp/240428-092058.png IMAGE 1714267256 0 [DEBUG][2024-04-28 09:20:58][chat_channel.py:345] - [WX] consume context: Context(type=IMAGE, content=tmp/240428-092058.png, kwargs={'isgroup': False, 'msg': <channel.wechat.wechat_message.WechatMessage object at 0x7fc7047edbd0>, 'origin_ctype': <ContextType.IMAGE: 3>, 'openai_api_key': None, 'gpt_model': None, 'session_id': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14', 'receiver': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14'}) [DEBUG][2024-04-28 09:20:58][chat_channel.py:168] - [WX] ready to handle context: Context(type=IMAGE, content=tmp/240428-092058.png, kwargs={'isgroup': False, 'msg': <channel.wechat.wechat_message.WechatMessage object at 0x7fc7047edbd0>, 'origin_ctype': <ContextType.IMAGE: 3>, 'openai_api_key': None, 'gpt_model': None, 'session_id': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14', 'receiver': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14'}) [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin GODCMD triggered by event Event.ON_HANDLE_CONTEXT [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin TIMETASK triggered by event Event.ON_HANDLE_CONTEXT [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin APILOT triggered by event Event.ON_HANDLE_CONTEXT [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin XINUO triggered by event Event.ON_HANDLE_CONTEXT [DEBUG][2024-04-28 09:20:58][plugin_manager.py:189] - Plugin SUM4ALL triggered by event Event.ON_HANDLE_CONTEXT [INFO][2024-04-28 09:20:58][sum4all.py:208] - on_handle_context: 开始处理图片 [INFO][2024-04-28 09:20:58][sum4all.py:211] - on_handle_context: 获取到图片路径 tmp/240428-092058.png [INFO][2024-04-28 09:20:58][sum4all.py:221] - Updated last_image_base64 in params_cache for user. [INFO][2024-04-28 09:20:58][sum4all.py:781] - handle_image: 解析图像处理API的响应 [ERROR][2024-04-28 09:20:59][sum4all.py:876] - Error processing LLM API response: 403 Client Error: Forbidden for url: https://pro.sum4all.site/v1/chat/completions [INFO][2024-04-28 09:20:59][sum4all.py:228] - 文件 tmp/240428-092058.png 已删除 [DEBUG][2024-04-28 09:20:59][plugin_manager.py:194] - Plugin SUM4ALL breaked event Event.ON_HANDLE_CONTEXT [DEBUG][2024-04-28 09:20:59][chat_channel.py:172] - [WX] ready to decorate reply: Reply(type=TEXT, content=An error occurred while processing LLM API response

💬5min内输入问+问题,可继续追问) [DEBUG][2024-04-28 09:20:59][chat_channel.py:284] - [WX] ready to send reply: Reply(type=TEXT, content=[ai] An error occurred while processing LLM API response

💬5min内输入问+问题,可继续追问), context: Context(type=IMAGE, content=tmp/240428-092058.png, kwargs={'isgroup': False, 'msg': <channel.wechat.wechat_message.WechatMessage object at 0x7fc7047edbd0>, 'origin_ctype': <ContextType.IMAGE: 3>, 'openai_api_key': None, 'gpt_model': None, 'session_id': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14', 'receiver': '@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14'}) [INFO][2024-04-28 09:20:59][wechat_channel.py:214] - [WX] sendMsg=Reply(type=TEXT, content=[ai] An error occurred while processing LLM API response

💬5min内输入问+问题,可继续追问), receiver=@fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14 [DEBUG][2024-04-28 09:20:59][chat_channel.py:300] - Worker return success, session_id = @fcb45b705f3325fc3b5be0f1cdcb38675e6287d8385337a247b752a4a40acc14

这是小红书,小红书总结需要人机验证,不知道这个怎么跳过 1714268548690

rexinshimin0001 commented 2 months ago

还有个问题,就是当我分享音乐链接的时候,比如网易云的歌曲,它也会进行总结,但是它会反馈 [ai] 抱歉,我无法查看网页内容。如果你有其他问题或需要帮助,请随时告诉我!我会尽力回答。

💬5min内输入问+问题,可继续追问 我想如何才能进行歌曲的总结,或者发送音乐的时候不进行总结

fatwang2 commented 2 months ago
  1. 图片的总结要看下你现在用的是什么sum_service,需要配置对应的key
  2. 小红书增强了反扒策略,你把sum_service切换到bibigpt,配置对应的key试试
  3. 歌曲当前没法总结。现在也没法判断你发的是不是个音乐,将来可行的方案就是放一个黑名单的配置变量给用户,黑名单域名下的链接都不总结,有能力的话可以pr一下哈哈
rexinshimin0001 commented 2 months ago

[INFO][2024-04-29 11:11:03][sum4all.py:252] - [sum4all] Summary URL : https://www.xiaohongshu.com/discovery/item/66211349000000001c00433b?app_platform=android&ignoreEngage=true&app_version=8.33.0&share_from_user_hidden=true&type=normal&author_share=1&xhsshare=WeixinSession&shareRedId=ODY7NkQ7PEs2NzUyOTgwNjY0OThIOEdM&apptime=1714352226 [INFO][2024-04-29 11:11:03][sum4all.py:256] - Updated last_url in params_cache for user. [ERROR][2024-04-29 11:11:05][chat_channel.py:303] - Worker return exception: local variable 'summary' referenced before assignment Traceback (most recent call last): File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) File "/home/kanxi/chatgpt-on-wechat/channel/chat_channel.py", line 170, in _handle reply = self._generate_reply(context) File "/home/kanxi/chatgpt-on-wechat/channel/chat_channel.py", line 182, in _generate_reply e_context = PluginManager().emit_event( File "/home/kanxi/chatgpt-on-wechat/plugins/plugin_manager.py", line 191, in emit_event instance.handlers[e_context.event](e_context, args, **kwargs) File "/home/kanxi/chatgpt-on-wechat/plugins/sum4all/sum4all.py", line 257, in on_handle_context self.call_service(content, e_context, "sum") File "/home/kanxi/chatgpt-on-wechat/plugins/sum4all/sum4all.py", line 282, in call_service self.handle_bibigpt(content, e_context) File "/home/kanxi/chatgpt-on-wechat/plugins/sum4all/sum4all.py", line 437, in handle_bibigpt reply.content = f"{summary}\n\n详细链接:{short_url}" UnboundLocalError: local variable 'summary' referenced before assignment 1714360305509 这是改成bibigpt之后,微信的公众号可以总结,但是,小红书,报错

rexinshimin0001 commented 2 months ago

def handle_bibigpt(self, content, e_context):
headers = { 'Content-Type': 'application/json' } payload_params = { "url": content, "includeDetail": False, "promptConfig": { "outputLanguage": self.outputLanguage } }

    payload = json.dumps(payload_params)           
    try:
        api_url = f"https://bibigpt.co/api/open/{self.bibigpt_key}"
        response = requests.request("POST",api_url, headers=headers, data=payload)
        response.raise_for_status()
        data = json.loads(response.text)
        summary_original = data.get('summary', 'Summary not available')
        html_url = data.get('htmlUrl', 'HTML URL not available')
        # 获取短链接
        short_url = self.short_url(html_url) 

        # 如果获取短链接失败,使用 html_url
        if short_url is None:
            short_url = html_url if html_url != 'HTML URL not available' else 'URL not available'

        # 移除 "##摘要"、"## 亮点" 和 "-"
        summary = summary_original.split("详细版(支持对话追问)")[0].replace("## 摘要\n", "📌总结:").replace("## 亮点\n", "").replace("- ", "")
    except requests.exceptions.RequestException as e:
        reply = f"An error occurred"

    reply = Reply()
    reply.type = ReplyType.TEXT
    reply.content = f"{summary}\n\n详细链接:{short_url}"

    e_context["reply"] = reply
    e_context.action = EventAction.BREAK_PASS
    这是配置里的,我不懂代码
fatwang2 commented 2 months ago

你不用修改代码,修改配置文件就行,你是不是改错地方了

rexinshimin0001 commented 2 months ago

你不用修改代码,修改配置文件就行,你是不是改错地方了

我就是改的配置文件,然后,把第一个的改成bibigpt,然后,就报错,然后我就想看看哪里报错

rexinshimin0001 commented 2 months ago

你不用修改代码,修改配置文件就行,你是不是改错地方了

代码文件我没动

fatwang2 commented 2 months ago

好,那可能小红书不能总结了,说明文档里有列不能总结服务可以总结的内容,bibigpt 主要是可以总结视频

rexinshimin0001 @.***>于2024年4月29日 周一11:57写道:

你不用修改代码,修改配置文件就行,你是不是改错地方了

代码文件我没动

— Reply to this email directly, view it on GitHub https://github.com/fatwang2/sum4all/issues/53#issuecomment-2081850128, or unsubscribe https://github.com/notifications/unsubscribe-auth/A77NZSX4QD3PKDGHZ42L3BLY7XAMJAVCNFSM6AAAAABG4RTQASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRHA2TAMJSHA . You are receiving this because you commented.Message ID: @.***>