Skip to content

Commit f898ed6

Browse files
authored
Merge branch 'master' into claude-3.5-sonnet
2 parents 095f9cc + e6d0a15 commit f898ed6

File tree

9 files changed

+23
-11
lines changed

9 files changed

+23
-11
lines changed

bot/gemini/google_gemini_bot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def __init__(self):
2424
self.api_key = conf().get("gemini_api_key")
2525
# 复用文心的token计算方式
2626
self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "gpt-3.5-turbo")
27-
27+
self.model = conf().get("model") or "gemini-pro"
28+
if self.model == "gemini":
29+
self.model = "gemini-pro"
2830
def reply(self, query, context: Context = None) -> Reply:
2931
try:
3032
if context.type != ContextType.TEXT:
@@ -35,7 +37,7 @@ def reply(self, query, context: Context = None) -> Reply:
3537
session = self.sessions.session_query(query, session_id)
3638
gemini_messages = self._convert_to_gemini_messages(self.filter_messages(session.messages))
3739
genai.configure(api_key=self.api_key)
38-
model = genai.GenerativeModel('gemini-pro')
40+
model = genai.GenerativeModel(self.model)
3941
response = model.generate_content(gemini_messages)
4042
reply_text = response.text
4143
self.sessions.session_reply(reply_text, session_id)

bridge/bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self):
3636
self.btype["chat"] = const.QWEN
3737
if model_type in [const.QWEN_TURBO, const.QWEN_PLUS, const.QWEN_MAX]:
3838
self.btype["chat"] = const.QWEN_DASHSCOPE
39-
if model_type in [const.GEMINI]:
39+
if model_type and model_type.startswith("gemini"):
4040
self.btype["chat"] = const.GEMINI
4141
if model_type in [const.ZHIPU_AI]:
4242
self.btype["chat"] = const.ZHIPU_AI

channel/chat_channel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):
117117
logger.info("[chat_channel]receive group at")
118118
if not conf().get("group_at_off", False):
119119
flag = True
120+
self.name = self.name if self.name is not None else "" # 部分渠道self.name可能没有赋值
120121
pattern = f"@{re.escape(self.name)}(\u2005|\u0020)"
121122
subtract_res = re.sub(pattern, r"", content)
122123
if isinstance(context["msg"].at_list, list):

channel/dingtalk/dingtalk_channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def handle_group(self, cmsg: DingTalkMessage):
163163
elif cmsg.ctype == ContextType.PATPAT:
164164
logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content))
165165
elif cmsg.ctype == ContextType.TEXT:
166-
logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content))
166+
logger.debug("[DingTalk]receive text msg: {}".format(cmsg.content))
167167
else:
168168
logger.debug("[DingTalk]receive other msg: {}".format(cmsg.content))
169169
context = self._compose_context(cmsg.ctype, cmsg.content, isgroup=True, msg=cmsg)

channel/dingtalk/dingtalk_message.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, event: ChatbotMessage, image_download_handler):
4949
if self.is_group:
5050
self.from_user_id = event.conversation_id
5151
self.actual_user_id = event.sender_id
52+
self.is_at = True
5253
else:
5354
self.from_user_id = event.sender_id
5455
self.actual_user_id = event.sender_id

common/const.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
QWEN_DASHSCOPE = "dashscope" # 通义新版sdk和api key
1212

1313

14-
GEMINI = "gemini"
14+
GEMINI = "gemini" # gemini-1.0-pro
1515
ZHIPU_AI = "glm-4"
1616
MOONSHOT = "moonshot"
1717
MiniMax = "minimax"
@@ -51,16 +51,19 @@
5151
LINKAI_4_TURBO = "linkai-4-turbo"
5252
LINKAI_4o = "linkai-4o"
5353

54+
GEMINI_PRO = "gemini-1.0-pro"
55+
GEMINI_15_flash = "gemini-1.5-flash"
56+
GEMINI_15_PRO = "gemini-1.5-pro"
5457

5558
MODEL_LIST = [
5659
GPT35, GPT35_0125, GPT35_1106, "gpt-3.5-turbo-16k",
5760
GPT_4o, GPT4_TURBO, GPT4_TURBO_PREVIEW, GPT4_TURBO_01_25, GPT4_TURBO_11_06, GPT4, GPT4_32k, GPT4_06_13, GPT4_32k_06_13,
5861
WEN_XIN, WEN_XIN_4,
59-
XUNFEI, GEMINI, ZHIPU_AI, MOONSHOT,
62+
XUNFEI, ZHIPU_AI, MOONSHOT, MiniMax,
63+
GEMINI, GEMINI_PRO, GEMINI_15_flash, GEMINI_15_PRO,
6064
"claude", "claude-3-haiku", "claude-3-sonnet", "claude-3-opus", "claude-3-opus-20240229", "claude-3.5-sonnet",
6165
"moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k",
6266
QWEN, QWEN_TURBO, QWEN_PLUS, QWEN_MAX,
63-
MiniMax,
6467
LINKAI_35, LINKAI_4_TURBO, LINKAI_4o
6568
]
6669

config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"open_ai_api_base": "https://api.openai.com/v1",
1818
"proxy": "", # openai使用的代理
1919
# chatgpt模型, 当use_azure_chatgpt为true时,其名称为Azure上model deployment名称
20-
"model": "gpt-3.5-turbo", # 支持ChatGPT、Claude、Gemini、文心一言、通义千问、Kimi、讯飞星火、智谱、LinkAI等模型,模型具体名称详见common/const.py文件列出的模型
20+
"model": "gpt-3.5-turbo", # 可选择: gpt-4o, gpt-4-turbo, claude-3-sonnet, wenxin, moonshot, qwen-turbo, xunfei, glm-4, minimax, gemini等模型,全部可选模型详见common/const.py文件
2121
"bot_type": "", # 可选配置,使用兼容openai格式的三方服务时候,需填"chatGPT"。bot具体名称详见common/const.py文件列出的bot_type,如不填根据model名称判断,
2222
"use_azure_chatgpt": False, # 是否使用azure的chatgpt
2323
"azure_deployment_id": "", # azure 模型部署名称
@@ -96,7 +96,7 @@
9696
"voice_reply_voice": False, # 是否使用语音回复语音,需要设置对应语音合成引擎的api key
9797
"always_reply_voice": False, # 是否一直使用语音回复
9898
"voice_to_text": "openai", # 语音识别引擎,支持openai,baidu,google,azure
99-
"text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),azure,elevenlabs,edge(online)
99+
"text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),ali,azure,elevenlabs,edge(online)
100100
"text_to_voice_model": "tts-1",
101101
"tts_voice_id": "alloy",
102102
# baidu 语音api配置, 使用百度语音识别和语音合成时需要
@@ -242,15 +242,15 @@ def drag_sensitive(config):
242242
conf_dict_copy = copy.deepcopy(conf_dict)
243243
for key in conf_dict_copy:
244244
if "key" in key or "secret" in key:
245-
if isinstance(key, str):
245+
if isinstance(conf_dict_copy[key], str):
246246
conf_dict_copy[key] = conf_dict_copy[key][0:3] + "*" * 5 + conf_dict_copy[key][-3:]
247247
return json.dumps(conf_dict_copy, indent=4)
248248

249249
elif isinstance(config, dict):
250250
config_copy = copy.deepcopy(config)
251251
for key in config:
252252
if "key" in key or "secret" in key:
253-
if isinstance(key, str):
253+
if isinstance(config_copy[key], str):
254254
config_copy[key] = config_copy[key][0:3] + "*" * 5 + config_copy[key][-3:]
255255
return config_copy
256256
except Exception as e:

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
security_opt:
77
- seccomp:unconfined
88
environment:
9+
TZ: 'Asia/Shanghai'
910
OPEN_AI_API_KEY: 'YOUR API KEY'
1011
MODEL: 'gpt-3.5-turbo'
1112
PROXY: ''

plugins/source.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
"solitaire": {
3636
"url": "https://github.com/Wang-zhechao/solitaire.git",
3737
"desc": "机器人微信接龙插件"
38+
},
39+
"HighSpeedTicket": {
40+
"url": "https://github.com/He0607/HighSpeedTicket.git",
41+
"desc": "高铁(火车)票查询插件"
3842
}
3943
}
4044
}

0 commit comments

Comments
 (0)