zilliztech / GPTCache

Semantic cache for LLMs. Fully integrated with LangChain and llama_index.
https://gptcache.readthedocs.io
MIT License
7.18k stars 502 forks source link

Add support for Bard, Anthropic, Cohere, Azure, OpenAI Models - using litellm #503

Open ishaan-jaff opened 1 year ago

ishaan-jaff commented 1 year ago

I'm the maintainer of litellm https://github.com/BerriAI/litellm - a simple & light package to call Bard, Anthropic, Cohere, Azure, OpenAI LLM Models

This PR adds support for models from all the above mentioned providers, in this pr I made a new adapter called litellm.py

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

from litellm import completion

## 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)

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

# anthropic call
response = completion(model="claude-instant-1", messages=messages)
sre-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ishaan-jaff To complete the pull request process, please assign simfg after the PR has been reviewed. You can assign the PR to them by writing /assign @simfg in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/zilliztech/GPTCache/blob/main/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
sre-ci-robot commented 1 year ago

Welcome @ishaan-jaff! It looks like this is your first PR to zilliztech/GPTCache 🎉

ishaan-jaff commented 1 year ago

@cxie @SimFG @xiaofan-luan saw adding new LLM models was on the roadmap, made a PR to integrate with liteLLM which adds new LLM models. if this looks good would love to add support to GPTCache

SimFG commented 1 year ago

@ishaan-jaff thanks for your pr, please make the dev branch as the target

krrishdholakia commented 1 year ago

what would next steps on this PR be? @ishaan-jaff @SimFG

SimFG commented 1 year ago

@ishaan-jaff please add some test cases for your pull request