Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
v0 litellm (#5076)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan-jaff authored Nov 3, 2023
1 parent c437a91 commit 6c80241
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from parlai.core.message import Message

try:
import openai
import litellm
except ImportError:
raise ImportError('Please run `pip install openai`.')
raise ImportError('Please run `pip install litellm`.')


class OpenaiChatCompletionsAgent(Agent):
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, opt, shared=None):
if self.init_prompt:
self.turns.append({'role': 'system', 'content': self.init_prompt})

openai.api_key = opt.get('openai_api_key')
litellm.api_key = opt.get('openai_api_key')

def reset(self):
"""
Expand Down Expand Up @@ -169,7 +169,7 @@ def act(self):
return Message({'id': self.getID(), 'text': resp_txt, 'episode_done': False})

def query_chat_completion_api(self):
response = openai.ChatCompletion.create(
response = litellm.completion(
model=self.model_name,
messages=self.turns,
temperature=self.temperature,
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ contractions~=0.1.72
fsspec~=2022.2.0
google-api-core<=2.11.0
openai<=0.27.7
litellm>=0.1.400

0 comments on commit 6c80241

Please sign in to comment.