Skip to content

feat: add integrarion for anthropic #582

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ By the way if you to use not mandatory modules it is necessary to install by you

### Installing "Other Language Models"

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

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ docs = ["sphinx==6.0", "furo==2024.5.6"]
# Group 1: Other Language Models
other-language-models = [
"langchain-fireworks>=0.1.3",
"langchain-anthropic==0.1.23",
"langchain-groq>=0.1.3",
"langchain-anthropic>=0.1.11",
"langchain-huggingface>=0.0.3",
Expand Down
8 changes: 7 additions & 1 deletion scrapegraphai/graphs/abstract_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def handle_model(model_name, provider, token_key, default_token=8192):
warnings.simplefilter("ignore")
return init_chat_model(**llm_params)

known_models = {"chatgpt","gpt","openai", "azure_openai", "google_genai",
known_models = {"anthropic", "chatgpt","gpt","openai", "azure_openai", "google_genai",
"ollama", "oneapi", "nvidia", "groq", "google_vertexai",
"bedrock", "mistralai", "hugging_face", "deepseek", "ernie", "fireworks"}

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

elif "claude-3-" in llm_params["model"]:
return handle_model(llm_params["model"], "anthropic", "claude3")

elif "anthropic" in llm_params["model"]:
from langchain_anthropic import ChatAnthropic

model_name = llm_params["model"].split("/")[-1]
return handle_model(model_name, "anthropic", model_name)

elif llm_params["model"].startswith("mistral"):
model_name = llm_params["model"].split("/")[-1]
Expand Down
8 changes: 8 additions & 0 deletions scrapegraphai/helpers/models_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@
"claude-3-haiku-20240307": 200000,
"claude-3-5-sonnet-20240620": 200000,
},
"anthropic": {
"claude-3-haiku-20240307-v1:0": 200000,
"claude-3-sonnet-20240229-v1:0": 200000,
"laude-3-opus-20240229-v1:0": 200000,
"claude-v2:1": 200000,
"claude-v2": 100000,
"claude-instant-v1": 100000,
},
"bedrock": {
"anthropic.claude-3-haiku-20240307-v1:0": 200000,
"anthropic.claude-3-sonnet-20240229-v1:0": 200000,
Expand Down
Loading