Skip to content

Commit e85e241

Browse files
6visionheshengtao
authored andcommitted
Merge pull request zhayujie#2364 from 6vision/1031
1.7.3 release readme
2 parents d90eeb7 + e102cbb commit e85e241

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ DEMO视频:https://cdn.link-ai.tech/doc/cow_demo.mp4
4545
<br>
4646

4747
# 🏷 更新日志
48+
>**2024.10.31:** [1.7.3版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.7.3) 程序稳定性提升、数据库功能、Claude模型优化、linkai插件优化、离线通知
4849
4950
>**2024.09.26:** [1.7.2版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.7.2)[1.7.1版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.7.1) 文心,讯飞等模型优化、o1 模型、快速安装和管理脚本
5051

bot/chatgpt/chat_gpt_bot.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# encoding:utf-8
22

3+
import re
34
import time
45

56
import openai
@@ -92,11 +93,15 @@ def reply(self, query, context=None):
9293
reply_content["completion_tokens"],
9394
)
9495
)
96+
match = re.search(r"(?:!\[image\]|\[image\])\((.*?)\)", reply_content["content"])
9597
if reply_content["completion_tokens"] == 0 and len(reply_content["content"]) > 0:
9698
reply = Reply(ReplyType.ERROR, reply_content["content"])
9799
elif reply_content["completion_tokens"] > 0:
98-
self.sessions.session_reply(reply_content["content"], session_id, reply_content["total_tokens"])
99-
reply = Reply(ReplyType.TEXT, reply_content["content"])
100+
if match:
101+
reply = Reply(ReplyType.IMAGE_URL, match.group(1))
102+
else:
103+
self.sessions.session_reply(reply_content["content"], session_id, reply_content["total_tokens"])
104+
reply = Reply(ReplyType.TEXT, reply_content["content"])
100105
else:
101106
reply = Reply(ReplyType.ERROR, reply_content["content"])
102107
logger.debug("[CHATGPT] reply {} used 0 tokens.".format(reply_content))

bot/chatgpt/chat_gpt_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def calc_tokens(self):
5656
# refer to https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
5757
def num_tokens_from_messages(messages, model):
5858
"""Returns the number of tokens used by a list of messages."""
59-
59+
return 10
6060
if model in ["wenxin", "xunfei"] or model.startswith(const.GEMINI):
6161
return num_tokens_by_character(messages)
6262

bot/openai/open_ai_bot.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# encoding:utf-8
22

3+
import re
34
import time
45

56
import openai
@@ -65,9 +66,12 @@ def reply(self, query, context=None):
6566
logger.debug(
6667
"[OPEN_AI] new_query={}, session_id={}, reply_cont={}, completion_tokens={}".format(str(session), session_id, reply_content, completion_tokens)
6768
)
68-
69+
match = re.search(r"(?:!\[image\]|\[image\])\((.*?)\)", reply_content)
6970
if total_tokens == 0:
7071
reply = Reply(ReplyType.ERROR, reply_content)
72+
elif match:
73+
reply_content = match.group(1)
74+
reply = Reply(ReplyType.IMAGE_URL, reply_content)
7175
else:
7276
self.sessions.session_reply(reply_content, session_id, total_tokens)
7377
reply = Reply(ReplyType.TEXT, reply_content)

0 commit comments

Comments
 (0)