Skip to content

Commit

Permalink
litellm v0
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan-jaff committed Aug 4, 2023
1 parent db698c8 commit f972c42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gpttrace/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import tempfile
import openai
from litellm import completion

from gpttrace.utils.common import get_doc_content_for_query, init_conversation
from gpttrace.prompt import construct_running_prompt, construct_prompt_on_error, construct_prompt_for_explain
Expand All @@ -20,6 +21,19 @@ def call_gpt_api(prompt: str) -> str:
)
return response["choices"][0]["message"]["content"]

def call_litellm(prompt: str) -> str:
"""
This function sends a list of messages to the selected litellm model
OpenAI, Azure, Cohere, Anthropic, Replicate models supported
"""
messages = [{"role": "user", "content": prompt}]
# see supported models here:
# https://litellm.readthedocs.io/en/latest/supported/
response = completion(
model="claude-instant-1",
messages=messages,
)
return response["choices"][0]["message"]["content"]

def execute(user_input: str, verbose: bool = False, retry: int = 5, previous_prompt: str = None, output: str = None) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ langchain==0.0.227
llama_index==0.7.3
marko==2.0.0
openai==0.27.8
litellm==0.1.226
prompt_toolkit==3.0.38
Pygments==2.15.1
pygments_markdown_lexer==0.1.0.dev39
Expand Down

0 comments on commit f972c42

Please sign in to comment.