Skip to content

Commit

Permalink
add o1 preview
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanker committed Sep 12, 2024
1 parent 8f82358 commit c148c4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions lite_llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class TextModel(Enum):
GPT_4O = "gpt-4o"
GPT_4O_MINI = "gpt-4o-mini"
GPT_4_TURBO = "gpt-4-turbo"
O1_PREVIEW = "o1-preview"
CLAUDE_3_OPUS = "claude-3-opus-20240229"
CLAUDE_35_SONNET = "claude-3-5-sonnet-20240620"
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
Expand Down
14 changes: 11 additions & 3 deletions session.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, user_id: str, channel_id: str, client: WebClient):
# Retrieve the sender's information using the Slack API
sender_info = client.users_info(user=user_id)
self.user_name = sender_info["user"]["real_name"]
self.model = TextModel.CLAUDE_35_SONNET
self.model = TextModel.O1_PREVIEW
self.system_instr = (
"You are a helpful assistant called SushiBot running as a Slack App. Keep the "
"conversation natural and flowing, don't respond with robotic or closing statements like "
Expand Down Expand Up @@ -220,6 +220,9 @@ def process_command(self, text, say=lambda text: None):
say(text="Session has been reset.")
elif cmd in ("\\who?", "\\who", "\\llm", "\\model"):
say(text=f"You are currently chatting with {self.model.value}.")
elif cmd in ["\\o1", "\\o1-preview"]:
self.model = TextModel.O1_PREVIEW
say(text="Model set to O1 Preview.")
elif cmd in ["\\gpt4o", "\\gpt"]:
self.model = TextModel.GPT_4O
say(text="Model set to GPT-4o (Omni).")
Expand All @@ -244,7 +247,7 @@ def process_command(self, text, say=lambda text: None):
elif cmd == "\\opus":
self.model = TextModel.CLAUDE_3_OPUS
say(text="Model set to Claude 3 Opus.")
elif cmd == "\\sonnet":
elif cmd in ["\\sonnet", "\\claude"]:
self.model = TextModel.CLAUDE_35_SONNET
say(text="Model set to Claude 3.5 Sonnet.")
elif cmd == "\\haiku":
Expand All @@ -270,6 +273,7 @@ def process_command(self, text, say=lambda text: None):
{HELP_PREAMBLE} I am a basic chatbot to quickly use GPT4, Claude, LLaMA & Gemini in one place. The chat is organized in sessions. Once you reset a session, all the previous conversation is lost. I am incapable of analyzing images or writing code right now, but feel free to upload PDFs, text files, or link to any websites, and I'll try to scrape whatever text I can. Here's the full list of available commands you can use:\n
- \\reset: Reset the chat session. Preserves the previous LLM you were chatting with.\n
- \\who: Returns the name of the chat model you are chatting with.\n
- \\o1: Use O1 Preview for future messages. Preserves the session so far.\n
- \\gpt4o: Use GPT-4o (Omni) for future messages. Preserves the session so far.\n
- \\mini: Use GPT-4o Mini for future messages. Preserves the session so far.\n
- \\sonnet: Use Claude 3.5 Sonnet for future messages. Preserves the session so far.\n
Expand Down Expand Up @@ -305,7 +309,11 @@ def process_direct_message(self, text, say, logger):
elif commands:
self.process_command(commands[-1])

messages = [ChatMessage.from_system(self.system_instr)] + messages
messages = (
[ChatMessage.from_system(self.system_instr)] + messages
if self.model != TextModel.O1_PREVIEW
else [ChatMessage.from_user(self.system_instr)] + messages
)
messages = [msg.to_openai_format() for msg in messages]
logger.debug(messages)

Expand Down

0 comments on commit c148c4d

Please sign in to comment.