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 Ollama, Palm, Claude-2, Cohere, Replicate Llama2 CodeLlama (100+LLMs) - LiteLLM #53

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

Conversation

ishaan-jaff
Copy link

@ishaan-jaff ishaan-jaff commented Oct 5, 2023

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)

Summary by CodeRabbit

Refactor:

  • Switched from openai to litellm for language model completions. This change enhances the underlying AI capabilities of our application, potentially improving the user experience with more accurate and context-aware responses.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 5, 2023

Walkthrough

The changes primarily involve a shift from the OpenAI API to the LiteLLM API for text generation. This includes updating import statements, API key assignments, and function calls.

Changes

File Summary
main.py Transitioned from OpenAI to LiteLLM: updated imports, API key assignments, and function calls.

🐇🎉

In the land of code, where logic is king,
A rabbit hopped forth, changes to bring.
From OpenAI to LiteLLM we leap,
For better text generation while you sleep.
So celebrate now, for the change is done,
Onwards to new tasks, the race is on! 🏁🥕


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@ishaan-jaff
Copy link
Author

ishaan-jaff commented Oct 5, 2023

addressing: #52 #50

@ishaan-jaff
Copy link
Author

@yoheinakajima can you take a look at this PR when possible

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between bc3866f and d0bf797.
Files ignored due to filter (1)
  • pyproject.toml
Files selected for processing (1)
  • main.py (3 hunks)
Additional comments (Suppressed): 3
main.py (3)
  • 2-8: The import of litellm is new and replaces the use of openai. Ensure that litellm is installed in your environment and all its dependencies are satisfied.

  • 24-24: The API key for litellm is being set using the same environment variable as was used for openai. Confirm if this is intentional and whether the same key can be used for both services.

- litellm.api_key = os.getenv("OPENAI_API_KEY")
+ litellm.api_key = os.getenv("LITELLM_API_KEY")
  • 134-137: The function call to litellm.completion() replaces the previous openai.ChatCompletion.create(). Verify that the parameters and their types passed to this function match the expected input. Also, ensure that the returned KnowledgeGraph object has the same structure and properties as before.

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.

None yet

1 participant