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 Llama2, Palm, Cohere, Anthropic, Replicate Models - using litellm #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ishaan-jaff
Copy link

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 ishaan-jaff changed the title Add support for Llama2, Palm, Cohere, Replicate Models - using litellm Add support for Llama2, Palm, Cohere, Anthropic, Replicate Models - using litellm Aug 16, 2023
@ishaan-jaff
Copy link
Author

@yyiilluu can you take a look at this PR when possible😊?
Happy to add more docs/tests if this initial commit looks good

@ishaan-jaff
Copy link
Author

This should also remove the need to separately maintain the HF integration in AutoChain

@yyiilluu
Copy link
Contributor

a few questions, does litellm an API wrapper around all different LLM providers by standardizing the outputs to match what OpenAI has? who is paying of the hosting cost for HF model, is litellm paying replicate for hosting?

@ishaan-jaff
Copy link
Author

does litellm an API wrapper around all different LLM providers by standardizing the outputs to match what OpenAI has

Yes, outputs match OpenAI, more info here: https://docs.litellm.ai/docs/completion/output

who is paying of the hosting cost for HF model, is litellm paying replicate for hosting?

You pay, you must set your API keys in your .env or pass it in completion or as litellm.api_key

@yyiilluu
Copy link
Contributor

got you, i have to say i am a bit worried about this as there could be changes from OpenAI but not picked up by LiteLLM, which cause AutoChain not able to be benefited from it

@ishaan-jaff
Copy link
Author

liteLLM is an actively maintained library and always uses the latest versions of openai
https://github.com/BerriAI/litellm/blob/main/pyproject.toml#L11

However if adding new LLMs is currently not a priority for AutoChain ,we can close this PR

@ishaan-jaff
Copy link
Author

Hi @yyiilluu wanted to follow up

What was litellm missing to be useful to you? Any feedback here would be helpful

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.

2 participants