Ver código fonte

Merge branch 'master' into master

master
Saboteur7 GitHub 10 meses atrás
pai
commit
7090722565
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: B5690EEEBB952194
8 arquivos alterados com 109 adições e 79 exclusões
  1. +1
    -1
      README.md
  2. +12
    -4
      bot/baidu/baidu_wenxin.py
  3. +0
    -1
      bot/bot_factory.py
  4. +35
    -31
      bridge/bridge.py
  5. +1
    -0
      channel/terminal/terminal_channel.py
  6. +40
    -40
      common/const.py
  7. +3
    -2
      config.py
  8. +17
    -0
      plugins/config.json.template

+ 1
- 1
README.md Ver arquivo

@@ -167,7 +167,7 @@ pip3 install -r requirements-optional.txt

**4.其他配置**

+ `model`: 模型名称,目前支持 `gpt-3.5-turbo`, `gpt-4o`, `gpt-4-turbo`, `gpt-4`, `wenxin` , `claude` , `gemini`, `glm-4`, `xunfei`, `moonshot`
+ `model`: 模型名称,目前支持 `gpt-3.5-turbo`, `gpt-4o`, `gpt-4-turbo`, `gpt-4`, `wenxin` , `claude` , `gemini`, `glm-4`, `xunfei`, `moonshot`等,全部模型名称参考[common/const.py](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/common/const.py)文件
+ `temperature`,`frequency_penalty`,`presence_penalty`: Chat API接口参数,详情参考[OpenAI官方文档。](https://platform.openai.com/docs/api-reference/chat)
+ `proxy`:由于目前 `openai` 接口国内无法访问,需配置代理客户端的地址,详情参考 [#351](https://github.com/zhayujie/chatgpt-on-wechat/issues/351)
+ 对于图像生成,在满足个人或群组触发条件外,还需要额外的关键词前缀来触发,对应配置 `image_create_prefix `


+ 12
- 4
bot/baidu/baidu_wenxin.py Ver arquivo

@@ -1,6 +1,8 @@
# encoding:utf-8

import requests, json
import requests
import json
from common import const
from bot.bot import Bot
from bot.session_manager import SessionManager
from bridge.context import ContextType
@@ -16,9 +18,15 @@ class BaiduWenxinBot(Bot):

def __init__(self):
super().__init__()
wenxin_model = conf().get("baidu_wenxin_model") or "eb-instant"
if conf().get("model") and conf().get("model") == "wenxin-4":
wenxin_model = "completions_pro"
wenxin_model = conf().get("baidu_wenxin_model")
if wenxin_model is not None:
wenxin_model = conf().get("baidu_wenxin_model") or "eb-instant"
else:
if conf().get("model") and conf().get("model") == const.WEN_XIN:
wenxin_model = "completions"
elif conf().get("model") and conf().get("model") == const.WEN_XIN_4:
wenxin_model = "completions_pro"

self.sessions = SessionManager(BaiduWenxinSession, model=wenxin_model)

def reply(self, query, context=None):


+ 0
- 1
bot/bot_factory.py Ver arquivo

@@ -2,7 +2,6 @@
channel factory
"""
from common import const
from common.log import logger


def create_bot(bot_type):


+ 35
- 31
bridge/bridge.py Ver arquivo

@@ -19,41 +19,45 @@ class Bridge(object):
"translate": conf().get("translate", "baidu"),
}
# 这边取配置的模型
model_type = conf().get("model") or const.GPT35
if model_type in ["text-davinci-003"]:
self.btype["chat"] = const.OPEN_AI
if conf().get("use_azure_chatgpt", False):
self.btype["chat"] = const.CHATGPTONAZURE
if model_type in ["wenxin", "wenxin-4"]:
self.btype["chat"] = const.BAIDU
if model_type in ["xunfei"]:
self.btype["chat"] = const.XUNFEI
if model_type in [const.QWEN]:
self.btype["chat"] = const.QWEN
if model_type in [const.QWEN_TURBO, const.QWEN_PLUS, const.QWEN_MAX]:
self.btype["chat"] = const.QWEN_DASHSCOPE
if model_type in [const.GEMINI]:
self.btype["chat"] = const.GEMINI
if model_type in [const.ZHIPU_AI]:
self.btype["chat"] = const.ZHIPU_AI
if model_type and model_type.startswith("claude-3"):
self.btype["chat"] = const.CLAUDEAPI
bot_type = conf().get("bot_type")
if bot_type:
self.btype["chat"] = bot_type
else:
model_type = conf().get("model") or const.GPT35
if model_type in ["text-davinci-003"]:
self.btype["chat"] = const.OPEN_AI
if conf().get("use_azure_chatgpt", False):
self.btype["chat"] = const.CHATGPTONAZURE
if model_type in ["wenxin", "wenxin-4"]:
self.btype["chat"] = const.BAIDU
if model_type in ["xunfei"]:
self.btype["chat"] = const.XUNFEI
if model_type in [const.QWEN]:
self.btype["chat"] = const.QWEN
if model_type in [const.QWEN_TURBO, const.QWEN_PLUS, const.QWEN_MAX]:
self.btype["chat"] = const.QWEN_DASHSCOPE
if model_type in [const.GEMINI]:
self.btype["chat"] = const.GEMINI
if model_type in [const.ZHIPU_AI]:
self.btype["chat"] = const.ZHIPU_AI
if model_type and model_type.startswith("claude-3"):
self.btype["chat"] = const.CLAUDEAPI

if model_type in ["claude"]:
self.btype["chat"] = const.CLAUDEAI
if model_type in ["claude"]:
self.btype["chat"] = const.CLAUDEAI

if model_type in ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"]:
self.btype["chat"] = const.MOONSHOT
if model_type in ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"]:
self.btype["chat"] = const.MOONSHOT

if model_type in ["abab6.5-chat"]:
self.btype["chat"] = const.MiniMax
if model_type in ["abab6.5-chat"]:
self.btype["chat"] = const.MiniMax

if conf().get("use_linkai") and conf().get("linkai_api_key"):
self.btype["chat"] = const.LINKAI
if not conf().get("voice_to_text") or conf().get("voice_to_text") in ["openai"]:
self.btype["voice_to_text"] = const.LINKAI
if not conf().get("text_to_voice") or conf().get("text_to_voice") in ["openai", const.TTS_1, const.TTS_1_HD]:
self.btype["text_to_voice"] = const.LINKAI
if conf().get("use_linkai") and conf().get("linkai_api_key"):
self.btype["chat"] = const.LINKAI
if not conf().get("voice_to_text") or conf().get("voice_to_text") in ["openai"]:
self.btype["voice_to_text"] = const.LINKAI
if not conf().get("text_to_voice") or conf().get("text_to_voice") in ["openai", const.TTS_1, const.TTS_1_HD]:
self.btype["text_to_voice"] = const.LINKAI

self.bots = {}
self.chat_bots = {}


+ 1
- 0
channel/terminal/terminal_channel.py Ver arquivo

@@ -78,6 +78,7 @@ class TerminalChannel(ChatChannel):
prompt = trigger_prefixs[0] + prompt # 给没触发的消息加上触发前缀

context = self._compose_context(ContextType.TEXT, prompt, msg=TerminalMessage(msg_id, prompt))
context["isgroup"] = False
if context:
self.produce(context)
else:


+ 40
- 40
common/const.py Ver arquivo

@@ -1,68 +1,68 @@
# bot_type
OPEN_AI = "openAI"
CHATGPT = "chatGPT"
BAIDU = "baidu"
BAIDU = "baidu" # 百度文心一言模型
XUNFEI = "xunfei"
CHATGPTONAZURE = "chatGPTOnAzure"
LINKAI = "linkai"
CLAUDEAI = "claude"
CLAUDEAPI = "claudeAPI"
QWEN = "qwen"
CLAUDEAI = "claude" # 使用cookie的历史模型
CLAUDEAPI= "claudeAPI" # 通过Claude api调用模型
QWEN = "qwen" # 旧版通义模型
QWEN_DASHSCOPE = "dashscope" # 通义新版sdk和api key

QWEN_DASHSCOPE = "dashscope"
QWEN_TURBO = "qwen-turbo"
QWEN_PLUS = "qwen-plus"
QWEN_MAX = "qwen-max"

GEMINI = "gemini"
ZHIPU_AI = "glm-4"
MOONSHOT = "moonshot"
MiniMax = "minimax"
MINIMAX = "minimax"


# model
CLAUDE3 = "claude-3-opus-20240229"
GPT35 = "gpt-3.5-turbo"
GPT4 = "gpt-4"
GPT35_0125 = "gpt-3.5-turbo-0125"
GPT35_1106 = "gpt-3.5-turbo-1106"

GPT_4o = "gpt-4o"
LINKAI_35 = "linkai-3.5"
LINKAI_4_TURBO = "linkai-4-turbo"
LINKAI_4o = "linkai-4o"
GPT4_TURBO_PREVIEW = "gpt-4-turbo-2024-04-09"
GPT4_TURBO = "gpt-4-turbo"
GPT4_TURBO_PREVIEW = "gpt-4-turbo-preview"
GPT4_TURBO_04_09 = "gpt-4-turbo-2024-04-09"
GPT4_TURBO_01_25 = "gpt-4-0125-preview"
GPT4_TURBO_11_06 = "gpt-4-1106-preview"
GPT4_VISION_PREVIEW = "gpt-4-vision-preview"

GPT4 = "gpt-4"
GPT4_32k = "gpt-4-32k"
GPT4_06_13 = "gpt-4-0613"
GPT4_32k_06_13 = "gpt-4-32k-0613"

WHISPER_1 = "whisper-1"
TTS_1 = "tts-1"
TTS_1_HD = "tts-1-hd"

WEN_XIN = "wenxin"
WEN_XIN_4 = "wenxin-4"

QWEN_TURBO = "qwen-turbo"
QWEN_PLUS = "qwen-plus"
QWEN_MAX = "qwen-max"

LINKAI_35 = "linkai-3.5"
LINKAI_4_TURBO = "linkai-4-turbo"
LINKAI_4o = "linkai-4o"


MODEL_LIST = [
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
"gpt-4",
"wenxin",
"wenxin-4",
"xunfei",
"claude",
"claude-3-opus-20240229",
"gpt-4-turbo",
"gpt-4-turbo-preview",
"gpt-4-1106-preview",
GPT4_TURBO_PREVIEW,
GPT4_TURBO_01_25,
GPT_4o,
QWEN,
GEMINI,
ZHIPU_AI,
MOONSHOT,
QWEN_TURBO,
QWEN_PLUS,
QWEN_MAX,
LINKAI_35,
LINKAI_4_TURBO,
LINKAI_4o,
MiniMax,
]
GPT35, GPT35_0125, GPT35_1106, "gpt-3.5-turbo-16k",
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,
WEN_XIN, WEN_XIN_4,
XUNFEI, GEMINI, ZHIPU_AI, MOONSHOT,
"claude", "claude-3-haiku", "claude-3-sonnet", "claude-3-opus", "claude-3-opus-20240229",
"moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k",
QWEN, QWEN_TURBO, QWEN_PLUS, QWEN_MAX,
MINIMAX,
LINKAI_35, LINKAI_4_TURBO, LINKAI_4o
]

# channel
FEISHU = "feishu"


+ 3
- 2
config.py Ver arquivo

@@ -17,7 +17,8 @@ available_setting = {
"open_ai_api_base": "https://api.openai.com/v1",
"proxy": "", # openai使用的代理
# chatgpt模型, 当use_azure_chatgpt为true时,其名称为Azure上model deployment名称
"model": "gpt-3.5-turbo", # 还支持 gpt-4, gpt-4-turbo, wenxin, xunfei, qwen
"model": "gpt-3.5-turbo", # 支持ChatGPT、Claude、Gemini、文心一言、通义千问、Kimi、讯飞星火、智谱、LinkAI等模型,模型具体名称详见common/const.py文件列出的模型
"bot_type": "", # 可选配置,使用兼容openai格式的三方服务时候,需填"chatGPT"。bot具体名称详见common/const.py文件列出的bot_type,如不填根据model名称判断,
"use_azure_chatgpt": False, # 是否使用azure的chatgpt
"azure_deployment_id": "", # azure 模型部署名称
"azure_api_version": "", # azure api版本
@@ -83,7 +84,7 @@ available_setting = {
"qwen_agent_key": "",
"qwen_app_id": "",
"qwen_node_id": "", # 流程编排模型用到的id,如果没有用到qwen_node_id,请务必保持为空字符串
# 阿里灵积模型api key
# 阿里灵积(通义新版sdk)模型api key
"dashscope_api_key": "",
# Google Gemini Api Key
"gemini_api_key": "",


+ 17
- 0
plugins/config.json.template Ver arquivo

@@ -40,5 +40,22 @@
"max_file_size": 5000,
"type": ["FILE", "SHARING"]
}
},
"hello": {
"group_welc_fixed_msg": {
"群聊1": "群聊1的固定欢迎语",
"群聊2": "群聊2的固定欢迎语"
},
"group_welc_prompt": "请你随机使用一种风格说一句问候语来欢迎新用户\"{nickname}\"加入群聊。",

"group_exit_prompt": "请你随机使用一种风格跟其他群用户说他违反规则\"{nickname}\"退出群聊。",

"patpat_prompt": "请你随机使用一种风格介绍你自己,并告诉用户输入#help可以查看帮助信息。",

"use_character_desc": false
},
"Apilot": {
"alapi_token": "xxx",
"morning_news_text_enabled": false
}
}

Carregando…
Cancelar
Salvar