gpt-code-assistant icon indicating copy to clipboard operation
gpt-code-assistant copied to clipboard

Add support for Azure, OpenAI, Palm, Anthropic, Cohere, Replicate Models - using litellm

Open ishaan-jaff opened this issue 2 years ago • 2 comments

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

TLDR: gpt-code-assistant gets:

  • more LLM models out of the box
  • instant integration of models by modifying the model param (Easy to add models in the future)
  • log I/O to Posthog, Sentry, Helicone, Supabase without making any code changes & get API Key management

Here's a sample of how litellm completion is 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)

ishaan-jaff avatar Aug 08 '23 15:08 ishaan-jaff

cc @narenmanoharan can you please take a look at this when you get the chance ?

Happy to add docs/tests if this initial commit looks good😊

ishaan-jaff avatar Aug 08 '23 15:08 ishaan-jaff

@ishaan-jaff Thanks for the PR. litellm seems super helpful. I was thinking about adding support for claude recently and was looking into it. This makes it super straightforward.

There's a couple of changes required to make this work:

  1. You need to modify the load_selected_model in config.py to expose other models from cohere and anthropic to allow users to select it.
  2. Also, now that this support other models than open_ai, might be good to rename open_ai.py to ai.py
  3. Update the readme with the supported models and how to set the api keys for each

I can merge this PR then and release a new version! Again, thanks for the contribution! ❤️

Also, does this package collect any analytics by default?

narenmanoharan avatar Aug 09 '23 13:08 narenmanoharan