mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-19 21:38:18 +08:00
Claude model supports system prompts.
This commit is contained in:
@@ -8,8 +8,7 @@ import anthropic
|
|||||||
|
|
||||||
from bot.bot import Bot
|
from bot.bot import Bot
|
||||||
from bot.openai.open_ai_image import OpenAIImage
|
from bot.openai.open_ai_image import OpenAIImage
|
||||||
from bot.chatgpt.chat_gpt_session import ChatGPTSession
|
from bot.baidu.baidu_wenxin_session import BaiduWenxinSession
|
||||||
from bot.gemini.google_gemini_bot import GoogleGeminiBot
|
|
||||||
from bot.session_manager import SessionManager
|
from bot.session_manager import SessionManager
|
||||||
from bridge.context import ContextType
|
from bridge.context import ContextType
|
||||||
from bridge.reply import Reply, ReplyType
|
from bridge.reply import Reply, ReplyType
|
||||||
@@ -34,7 +33,7 @@ class ClaudeAPIBot(Bot, OpenAIImage):
|
|||||||
if proxy:
|
if proxy:
|
||||||
openai.proxy = proxy
|
openai.proxy = proxy
|
||||||
|
|
||||||
self.sessions = SessionManager(ChatGPTSession, 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):
|
||||||
# acquire reply content
|
# acquire reply content
|
||||||
@@ -77,14 +76,14 @@ class ClaudeAPIBot(Bot, OpenAIImage):
|
|||||||
reply = Reply(ReplyType.ERROR, retstring)
|
reply = Reply(ReplyType.ERROR, retstring)
|
||||||
return reply
|
return reply
|
||||||
|
|
||||||
def reply_text(self, session: ChatGPTSession, retry_count=0):
|
def reply_text(self, session: BaiduWenxinSession, retry_count=0):
|
||||||
try:
|
try:
|
||||||
actual_model = self._model_mapping(conf().get("model"))
|
actual_model = self._model_mapping(conf().get("model"))
|
||||||
response = self.claudeClient.messages.create(
|
response = self.claudeClient.messages.create(
|
||||||
model=actual_model,
|
model=actual_model,
|
||||||
max_tokens=1024,
|
max_tokens=4096,
|
||||||
# system=conf().get("system"),
|
system=conf().get("character_desc", ""),
|
||||||
messages=GoogleGeminiBot.filter_messages(session.messages)
|
messages=session.messages
|
||||||
)
|
)
|
||||||
# response = openai.Completion.create(prompt=str(session), **self.args)
|
# response = openai.Completion.create(prompt=str(session), **self.args)
|
||||||
res_content = response.content[0].text.strip().replace("<|endoftext|>", "")
|
res_content = response.content[0].text.strip().replace("<|endoftext|>", "")
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ def convert_webp_to_png(webp_image):
|
|||||||
logger.error(f"Failed to convert WEBP to PNG: {e}")
|
logger.error(f"Failed to convert WEBP to PNG: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def remove_markdown_symbol(text: str):
|
def remove_markdown_symbol(text: str):
|
||||||
# 移除markdown格式,目前先移除**
|
# 移除markdown格式,目前先移除**
|
||||||
if not text:
|
if not text:
|
||||||
|
|||||||
Reference in New Issue
Block a user