diff --git a/bot.py b/bot.py index 76acf1ab..7915e9fb 100644 --- a/bot.py +++ b/bot.py @@ -289,7 +289,7 @@ async def delete_message(update, context, messageid, delay=10): # InlineKeyboardButton("gpt-4-32k-0613", callback_data="gpt-4-32k-0613"), # ], [ - InlineKeyboardButton("claude-2.1", callback_data="claude-2.1"), + InlineKeyboardButton("claude-2", callback_data="claude-2"), InlineKeyboardButton("claude-2-web", callback_data="claude-2-web"), ], [ @@ -341,7 +341,7 @@ async def button_press(update, context): data = callback_query.data if "gpt-" in data or "claude" in data: config.GPT_ENGINE = data - if config.API and "gpt-" in data: + if (config.API and "gpt-" in data) or (config.API and not config.ClaudeAPI): config.ChatGPTbot = GPT(api_key=f"{config.API}", engine=config.GPT_ENGINE, system_prompt=config.systemprompt, temperature=config.temperature) config.ChatGPTbot.reset(convo_id=str(update.effective_chat.id), system_prompt=config.systemprompt) if config.ClaudeAPI and "claude" in data: diff --git a/test/test_claude.py b/test/test_claude.py index 5a16fcc8..047efabe 100644 --- a/test/test_claude.py +++ b/test/test_claude.py @@ -53,7 +53,7 @@ class claudebot: def __init__( self, api_key: str, - engine: str = os.environ.get("GPT_ENGINE") or "claude-2.1", + engine: str = os.environ.get("GPT_ENGINE") or "claude-2", temperature: float = 0.5, top_p: float = 0.7, chat_url: str = "https://api.anthropic.com/v1/complete", diff --git a/utils/chatgpt2api.py b/utils/chatgpt2api.py index 70d7a343..f5e1e7e6 100644 --- a/utils/chatgpt2api.py +++ b/utils/chatgpt2api.py @@ -50,7 +50,7 @@ def get_filtered_keys_from_object(obj: object, *keys: str) -> Set[str]: "gpt-4-32k-0613", "gpt-4-1106-preview", "claude-2-web", - "claude-2.1", + "claude-2", ] class claudeConversation(dict): @@ -63,7 +63,7 @@ class claudebot: def __init__( self, api_key: str, - engine: str = os.environ.get("GPT_ENGINE") or "claude-2.1", + engine: str = os.environ.get("GPT_ENGINE") or "claude-2", temperature: float = 0.5, top_p: float = 0.7, chat_url: str = "https://api.anthropic.com/v1/complete", @@ -353,10 +353,14 @@ def add_to_conversation( """ if convo_id not in self.conversation: self.reset(convo_id=convo_id) - if function_name == "" and message != "": + if function_name == "" and message != "" and message != None: self.conversation[convo_id].append({"role": role, "content": message}) - else: + elif function_name != "" and message != "" and message != None: self.conversation[convo_id].append({"role": role, "name": function_name, "content": message}) + else: + print('\033[31m') + print("error: add_to_conversation message is None or empty") + print('\033[0m') def __truncate_conversation(self, convo_id: str = "default") -> None: """