Skip to content

Commit

Permalink
added anthropic as supported llm provider
Browse files Browse the repository at this point in the history
  • Loading branch information
luca.gobbi committed Oct 31, 2024
1 parent a5e7d96 commit 4129d19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 4129d19

Please sign in to comment.