Skip to content

Add support for Palm, Claude-2, Llama2, CodeLlama, Sagemaker (100+LLMs) - using LiteLLM #255

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

Open
wants to merge 1 commit into
base: main
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies = [
"cohere",
"ipywidgets",
"openai >= 0.27.0",
"litellm >= 0.1.574",
"pydantic >= 1.10.0",
"rouge-score >= 0.1.2",
"accelerate==0.22.0",
Expand Down
7 changes: 4 additions & 3 deletions src/xturing/model_apis/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime

import openai
import litellm

from xturing.model_apis.base import TextGenerationAPI

Expand Down Expand Up @@ -66,9 +67,9 @@ def generate_text(
response = None
target_length = max_tokens
if self.api_key is not None:
openai.api_key = self.api_key
litellm.api_key = self.api_key
if self.organization is not None:
openai.organization = self.organization
litellm.organization = self.organization
retry_cnt = 0
backoff_time = 30
while retry_cnt <= retries:
Expand Down Expand Up @@ -143,7 +144,7 @@ def __init__(self, api_key, organization=None, request_batch_size=10):

def get_completion(self, prompts, **kwargs):
messages = [{"role": "user", "content": prompt} for prompt in prompts]
completion = openai.ChatCompletion.create(
completion = litellm.completion(
model=self.engine,
messages=messages,
temperature=0,
Expand Down