Skip to content

Add support for Llama2, Palm, Cohere, Anthropic, Replicate Models - using litellm - #2

Open
ishaan-jaff wants to merge 1 commit into
slidoapp:mainfrom
ishaan-jaff:main
Open

Add support for Llama2, Palm, Cohere, Anthropic, Replicate Models - using litellm#2
ishaan-jaff wants to merge 1 commit into
slidoapp:mainfrom
ishaan-jaff:main

Conversation

@ishaan-jaff

Copy link
Copy Markdown

This PR adds support for models from all the above mentioned providers using https://github.com/BerriAI/litellm/

Here's a sample of how it's used:

from litellm import completion, acompletion

## set ENV variables
# ENV variables can be set in .env file, too. Example in .env.example
os.environ["OPENAI_API_KEY"] = "openai key"
os.environ["COHERE_API_KEY"] = "cohere key"

messages = [{ "content": "Hello, how are you?","role": "user"}]

# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)

# llama2 call
model_name = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1"
response = completion(model_name, messages)

# cohere call
response = completion("command-nightly", messages)

# anthropic call
response = completion(model="claude-instant-1", messages=messages)

@ishaan-jaff

Copy link
Copy Markdown
Author

Noticed you were also making calls to HF models, you can simplify I/O to HF models using litellm too

example

completion(model="stabilityai/stablecode-completion-alpha-3b-4k", messages=messages, custom_llm_provider="huggingface")

More info here: https://docs.litellm.ai/docs/completion/supported#hugging-face-inference-api

@ishaan-jaff

Copy link
Copy Markdown
Author

@virpo @mrshu can you take a look at this PR when possible😊

happy to add docs/tests if this initial commit looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant