yoheinakajima / babyagi

https://babyagi.org/
20.08k stars 2.63k forks source link

Add support for Palm, Claude-2, Cohere Llama2, CodeLlama (100+LLMs) #362

Closed ishaan-jaff closed 2 days ago

ishaan-jaff commented 1 year ago

This PR adds support for the above mentioned LLMs using LiteLLM https://github.com/BerriAI/litellm/ LiteLLM is a lightweight package to simplify LLM API calls - use any llm as a drop in replacement for gpt-3.5-turbo.

Example

from litellm import completion

## set ENV variables
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(model="command-nightly", messages)

# anthropic call
response = completion(model="claude-instant-1", messages=messages)
ishaan-jaff commented 1 year ago

@yoheinakajima can I get a review on this PR?

I think it will be interesting to explore swapping in/out different LLMs for different sub components of BabyAGI

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