Skip to content

Commit 1887810

Browse files
committed
feat: add integrarion for anthropic
1 parent ab21576 commit 1887810

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ By the way if you to use not mandatory modules it is necessary to install by you
3636

3737
### Installing "Other Language Models"
3838

39-
This group allows you to use additional language models like Fireworks, Groq, Anthropic, Hugging Face, and Nvidia AI Endpoints.
39+
This group allows you to use additional language models like Fireworks, Groq, Anthropic, Anthropic apis, Hugging Face, and Nvidia AI Endpoints.
4040
```bash
4141
pip install scrapegraphai[other-language-models]
4242

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ docs = ["sphinx==6.0", "furo==2024.5.6"]
6969
# Group 1: Other Language Models
7070
other-language-models = [
7171
"langchain-fireworks>=0.1.3",
72+
"langchain-anthropic==0.1.23",
7273
"langchain-groq>=0.1.3",
7374
"langchain-anthropic>=0.1.11",
7475
"langchain-huggingface>=0.0.3",

scrapegraphai/graphs/abstract_graph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def handle_model(model_name, provider, token_key, default_token=8192):
139139
warnings.simplefilter("ignore")
140140
return init_chat_model(**llm_params)
141141

142-
known_models = {"chatgpt","gpt","openai", "azure_openai", "google_genai",
142+
known_models = {"anthropic", "chatgpt","gpt","openai", "azure_openai", "google_genai",
143143
"ollama", "oneapi", "nvidia", "groq", "google_vertexai",
144144
"bedrock", "mistralai", "hugging_face", "deepseek", "ernie", "fireworks"}
145145

@@ -173,6 +173,12 @@ def handle_model(model_name, provider, token_key, default_token=8192):
173173

174174
elif "claude-3-" in llm_params["model"]:
175175
return handle_model(llm_params["model"], "anthropic", "claude3")
176+
177+
elif "anthropic" in llm_params["model"]:
178+
from langchain_anthropic import ChatAnthropic
179+
180+
model_name = llm_params["model"].split("/")[-1]
181+
return handle_model(model_name, "anthropic", model_name)
176182

177183
elif llm_params["model"].startswith("mistral"):
178184
model_name = llm_params["model"].split("/")[-1]

scrapegraphai/helpers/models_tokens.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@
137137
"claude-3-haiku-20240307": 200000,
138138
"claude-3-5-sonnet-20240620": 200000,
139139
},
140+
"anthropic": {
141+
"claude-3-haiku-20240307-v1:0": 200000,
142+
"claude-3-sonnet-20240229-v1:0": 200000,
143+
"laude-3-opus-20240229-v1:0": 200000,
144+
"claude-v2:1": 200000,
145+
"claude-v2": 100000,
146+
"claude-instant-v1": 100000,
147+
},
140148
"bedrock": {
141149
"anthropic.claude-3-haiku-20240307-v1:0": 200000,
142150
"anthropic.claude-3-sonnet-20240229-v1:0": 200000,

0 commit comments

Comments
 (0)