Skip to content

Commit d25cab0

Browse files
committed
Claude model supports system prompts.
1 parent 84da0a8 commit d25cab0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bot/claudeapi/claude_api_bot.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
from bot.bot import Bot
1010
from bot.openai.open_ai_image import OpenAIImage
11-
from bot.chatgpt.chat_gpt_session import ChatGPTSession
12-
from bot.gemini.google_gemini_bot import GoogleGeminiBot
11+
from bot.baidu.baidu_wenxin_session import BaiduWenxinSession
1312
from bot.session_manager import SessionManager
1413
from bridge.context import ContextType
1514
from bridge.reply import Reply, ReplyType
@@ -34,7 +33,7 @@ def __init__(self):
3433
if proxy:
3534
openai.proxy = proxy
3635

37-
self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "text-davinci-003")
36+
self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "text-davinci-003")
3837

3938
def reply(self, query, context=None):
4039
# acquire reply content
@@ -77,14 +76,14 @@ def reply(self, query, context=None):
7776
reply = Reply(ReplyType.ERROR, retstring)
7877
return reply
7978

80-
def reply_text(self, session: ChatGPTSession, retry_count=0):
79+
def reply_text(self, session: BaiduWenxinSession, retry_count=0):
8180
try:
8281
actual_model = self._model_mapping(conf().get("model"))
8382
response = self.claudeClient.messages.create(
8483
model=actual_model,
85-
max_tokens=1024,
86-
# system=conf().get("system"),
87-
messages=GoogleGeminiBot.filter_messages(session.messages)
84+
max_tokens=4096,
85+
system=conf().get("character_desc", ""),
86+
messages=session.messages
8887
)
8988
# response = openai.Completion.create(prompt=str(session), **self.args)
9089
res_content = response.content[0].text.strip().replace("<|endoftext|>", "")

common/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def convert_webp_to_png(webp_image):
7070
logger.error(f"Failed to convert WEBP to PNG: {e}")
7171
raise
7272

73+
7374
def remove_markdown_symbol(text: str):
7475
# 移除markdown格式,目前先移除**
7576
if not text:

0 commit comments

Comments
 (0)