akshata29 / entaoai

Chat and Ask on your own data. Accelerator to quickly upload your own enterprise data and use OpenAI services to chat to that uploaded data and ask questions
MIT License
841 stars 254 forks source link

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

Closed ishaan-jaff closed 1 year ago

ishaan-jaff commented 1 year ago

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

ChatLiteLLM() is integrated into langchain and allows you to call all models using the OpenAI I/O interface https://python.langchain.com/docs/integrations/chat/litellm

Here's an example of how to use ChatLiteLLM()

ChatLiteLLM(model="gpt-3.5-turbo")
ChatLiteLLM(model="claude-2", temperature=0.3)
ChatLiteLLM(model="command-nightly")
ChatLiteLLM(model="replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1")

Here's an example of how just using litellm.completion works

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 commented 1 year ago

@akshata29 can you please take a look at this PR ?😊

If this initial commit looks good happy to add liteLLM throughout + add docs/testing on the same

akshata29 commented 1 year ago

@ishaan-jaff - Looks good to me, let me do a quick testing and appreciate if you can help liteLLM throughout + help add docs/testing.