mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
Support setting base URL and proxy for Claude model. Also support reset command.
This commit is contained in:
@@ -23,16 +23,13 @@ user_session = dict()
|
|||||||
class ClaudeAPIBot(Bot, OpenAIImage):
|
class ClaudeAPIBot(Bot, OpenAIImage):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
proxy = conf().get("proxy", None)
|
||||||
|
base_url = conf().get("open_ai_api_base", None) # 复用"open_ai_api_base"参数作为base_url
|
||||||
self.claudeClient = anthropic.Anthropic(
|
self.claudeClient = anthropic.Anthropic(
|
||||||
api_key=conf().get("claude_api_key")
|
api_key=conf().get("claude_api_key"),
|
||||||
|
proxies=proxy if proxy else None,
|
||||||
|
base_url=base_url if base_url else None
|
||||||
)
|
)
|
||||||
openai.api_key = conf().get("open_ai_api_key")
|
|
||||||
if conf().get("open_ai_api_base"):
|
|
||||||
openai.api_base = conf().get("open_ai_api_base")
|
|
||||||
proxy = conf().get("proxy")
|
|
||||||
if proxy:
|
|
||||||
openai.proxy = proxy
|
|
||||||
|
|
||||||
self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "text-davinci-003")
|
self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "text-davinci-003")
|
||||||
|
|
||||||
def reply(self, query, context=None):
|
def reply(self, query, context=None):
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class Godcmd(Plugin):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
ok, result = False, "你没有设置私有GPT模型"
|
ok, result = False, "你没有设置私有GPT模型"
|
||||||
elif cmd == "reset":
|
elif cmd == "reset":
|
||||||
if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI]:
|
if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI, const.CLAUDEAPI]:
|
||||||
bot.sessions.clear_session(session_id)
|
bot.sessions.clear_session(session_id)
|
||||||
if Bridge().chat_bots.get(bottype):
|
if Bridge().chat_bots.get(bottype):
|
||||||
Bridge().chat_bots.get(bottype).sessions.clear_session(session_id)
|
Bridge().chat_bots.get(bottype).sessions.clear_session(session_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user