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 Palm, Claude-2, Cohere Llama2, CodeLlama (100+LLMs) #1212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 3 additions & 7 deletions flaml/autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

try:
import openai
import litellm
from openai.error import (
ServiceUnavailableError,
RateLimitError,
Expand Down Expand Up @@ -192,20 +193,15 @@ def _get_response(cls, config: Dict, raise_on_ratelimit_or_timeout=False, use_ca
# print("using cached response")
cls._book_keeping(config, response)
return response
openai_completion = (
openai.ChatCompletion
if config["model"] in cls.chat_models or issubclass(cls, ChatCompletion)
else openai.Completion
)
start_time = time.time()
request_timeout = cls.request_timeout
retry_timeout = config.pop("retry_timeout", cls.retry_timeout)
while True:
try:
if "request_timeout" in config:
response = openai_completion.create(**config)
response = litellm.completion(**config)
else:
response = openai_completion.create(request_timeout=request_timeout, **config)
response = litellm.completion(request_timeout=request_timeout, **config)
except (
ServiceUnavailableError,
APIConnectionError,
Expand Down