Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

Commit 6c80241

Browse files
authored
v0 litellm (#5076)
1 parent c437a91 commit 6c80241

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

parlai/agents/openai_chat_completions/openai_chat_completions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from parlai.core.message import Message
1212

1313
try:
14-
import openai
14+
import litellm
1515
except ImportError:
16-
raise ImportError('Please run `pip install openai`.')
16+
raise ImportError('Please run `pip install litellm`.')
1717

1818

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

130-
openai.api_key = opt.get('openai_api_key')
130+
litellm.api_key = opt.get('openai_api_key')
131131

132132
def reset(self):
133133
"""
@@ -169,7 +169,7 @@ def act(self):
169169
return Message({'id': self.getID(), 'text': resp_txt, 'episode_done': False})
170170

171171
def query_chat_completion_api(self):
172-
response = openai.ChatCompletion.create(
172+
response = litellm.completion(
173173
model=self.model_name,
174174
messages=self.turns,
175175
temperature=self.temperature,

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ contractions~=0.1.72
6060
fsspec~=2022.2.0
6161
google-api-core<=2.11.0
6262
openai<=0.27.7
63+
litellm>=0.1.400

0 commit comments

Comments
 (0)