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

Add support for Azure, OpenAI, Palm, Anthropic, Cohere Models - using litellm #15

Open
wants to merge 1 commit into
base: master
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
22 changes: 16 additions & 6 deletions backend/app/pkgs/tools/llm_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import threading
import time
import openai
import litellm
from app.pkgs.tools.llm_interface import LLMInterface
from config import LLM_MODEL
from config import GPT_KEYS
Expand Down Expand Up @@ -37,12 +38,21 @@ def chatCompletion(self, context):
openai.api_key = get_next_api_key()
print("chartGPT - get api key:"+openai.api_key, flush=True)

response = openai.ChatCompletion.create(
model= LLM_MODEL,
messages=context,
max_tokens=12000,
temperature=0,
)
if LLM_MODEL in litellm.models:
# see litellm supported models here: https://litellm.readthedocs.io/en/latest/supported/
response = litellm.completion(
model= LLM_MODEL,
messages=context,
max_tokens=12000,
temperature=0,
)
else:
response = openai.ChatCompletion.create(
model= LLM_MODEL,
messages=context,
max_tokens=12000,
temperature=0,
)

response_text = response["choices"][0]["message"]["content"]
print("chartGPT - response_text:"+response_text, flush=True)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ flask-sqlalchemy
flask-cors==3.0.10
pyyaml
python-gitlab
openai==0.27.8
openai==0.27.8
litellm==0.1.226