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) - using LiteLLM #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion camel/model_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Any, Dict

import openai
Copy link

Choose a reason for hiding this comment

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

this import isn't used anymore it seems

import litellm
import tiktoken

from camel.typing import ModelType
Expand Down Expand Up @@ -66,7 +67,7 @@ def run(self, *args, **kwargs) -> Dict[str, Any]:
num_max_token = num_max_token_map[self.model_type.value]
num_max_completion_tokens = num_max_token - num_prompt_tokens
self.model_config_dict['max_tokens'] = num_max_completion_tokens
Copy link
Author

Choose a reason for hiding this comment

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

we also expose a util called get_max_tokens() happy to expose this in this PR too

response = openai.ChatCompletion.create(*args, **kwargs,
response = litellm.completion(*args, **kwargs,

Choose a reason for hiding this comment

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

When testing this for Claude, line 78 below ("if not isinstance(response, Dict)") fails because the response is an instance of ModelResponse. Similar thing happening in chat_agent.py line 192.

model=self.model_type.value,
**self.model_config_dict)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jedi==0.18.2
jieba==0.42.1
Jinja2==3.1.2
lazy-object-proxy==1.9.0
litellm>=0.1.609
Markdown==3.4.4
MarkupSafe==2.1.3
mccabe==0.7.0
Expand Down