Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for palm, anthropic, llama2, cohere #342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bot/openai_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config

from litellm import completion
import tiktoken
import openai

Expand Down Expand Up @@ -48,6 +48,15 @@ async def send_message(self, message, dialog_messages=[], chat_mode="assistant")
**OPENAI_COMPLETION_OPTIONS
)
answer = r.choices[0].text
elif self.model in ["gpt-3.5-turbo-16k-0613", "command-nightly", "claude-2", "claude-instant-1", "chat-bison-001", "text-bison-001"] or "replicate" in self.model:
messages = self._generate_prompt_messages(message, dialog_messages, chat_mode)
r = completion(
model=self.model,
messages=messages,
stream=True,
**OPENAI_COMPLETION_OPTIONS
)
answer = r.choices[0].message["content"]
else:
raise ValueError(f"Unknown model: {self.model}")

Expand Down Expand Up @@ -105,8 +114,6 @@ async def send_message_stream(self, message, dialog_messages=[], chat_mode="assi
n_first_dialog_messages_removed = n_dialog_messages_before - len(dialog_messages)
yield "not_finished", answer, (n_input_tokens, n_output_tokens), n_first_dialog_messages_removed

answer = self._postprocess_answer(answer)

except openai.error.InvalidRequestError as e: # too many tokens
if len(dialog_messages) == 0:
raise e
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ tiktoken>=0.3.0
PyYAML==6.0
pymongo==4.3.3
python-dotenv==0.21.0
pydub==0.25.1
pydub==0.25.1
litellm==0.1.218