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

Added anthropic as supported llm provider #963

Merged
merged 1 commit into from
Nov 1, 2024
Merged
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
19 changes: 19 additions & 0 deletions core/cat/factory/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain_openai import ChatOpenAI, OpenAI
from langchain_cohere import ChatCohere
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_anthropic import ChatAnthropic

from typing import Type
import json
Expand Down Expand Up @@ -282,6 +283,23 @@ class LLMGeminiChatConfig(LLMSettings):
)


class LLMAnthropicChatConfig(LLMSettings):
api_key: str
model: str = "claude-3-5-sonnet-20241022"
temperature: float = 0.7
max_tokens: int = 8192
max_retries: int = 2

_pyclass: Type = ChatAnthropic

model_config = ConfigDict(
json_schema_extra={
"humanReadableName": "Anthropic",
"description": "Configuration for Anthropic",
"link": "https://www.anthropic.com/",
}
)

def get_allowed_language_models():
list_llms_default = [
LLMOpenAIChatConfig,
Expand All @@ -296,6 +314,7 @@ def get_allowed_language_models():
LLMHuggingFaceTextGenInferenceConfig,
LLMCustomConfig,
LLMDefaultConfig,
LLMAnthropicChatConfig
]

mad_hatter_instance = MadHatter()
Expand Down
2 changes: 1 addition & 1 deletion core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies = [
"langchain==0.2.1",
"langchain-community==0.2.1",
"langchain-openai==0.1.7",
"langchain-anthropic==0.1.23",
"langchain-google-genai==1.0.8",
"langchain-cohere==0.1.5",
"huggingface-hub==0.20.3",
Expand All @@ -34,7 +35,6 @@ dependencies = [
"tiktoken==0.7.0",
"tomli",
"loguru==0.7.2",
"anthropic==0.2.9",
"text_generation==0.6.1",
"tinydb==4.8.0",
"python-slugify==8.0.1",
Expand Down
Loading