Skip to content

Commit

Permalink
Merge pull request #597 from ScrapeGraphAI/593-abstract-graph-fix-rou…
Browse files Browse the repository at this point in the history
…nd-4

Abbstract graph fix, round 4
  • Loading branch information
VinciGit00 authored Aug 27, 2024
2 parents d33b347 + 229d74d commit d45064b
Show file tree
Hide file tree
Showing 102 changed files with 262 additions and 352 deletions.
4 changes: 2 additions & 2 deletions examples/anthropic/csv_scraper_graph_multi_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/csv_scraper_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
24 changes: 5 additions & 19 deletions examples/anthropic/custom_graph_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import os
from dotenv import load_dotenv

from langchain_openai import OpenAIEmbeddings
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from scrapegraphai.graphs import BaseGraph
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
from scrapegraphai.nodes import FetchNode, ParseNode, GenerateAnswerNode, RobotsNode
load_dotenv()

# ************************************************
Expand All @@ -19,16 +18,14 @@
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
},
}

# ************************************************
# Define the graph nodes
# ************************************************

llm_model = OpenAI(graph_config["llm"])
embedder = OpenAIEmbeddings(api_key=llm_model.openai_api_key)
llm_model = ChatAnthropic(graph_config["llm"])

# define the nodes for the graph
robot_node = RobotsNode(
Expand Down Expand Up @@ -57,15 +54,6 @@
"verbose": True,
}
)
rag_node = RAGNode(
input="user_prompt & (parsed_doc | doc)",
output=["relevant_chunks"],
node_config={
"llm_model": llm_model,
"embedder_model": embedder,
"verbose": True,
}
)
generate_answer_node = GenerateAnswerNode(
input="user_prompt & (relevant_chunks | parsed_doc | doc)",
output=["answer"],
Expand All @@ -84,14 +72,12 @@
robot_node,
fetch_node,
parse_node,
rag_node,
generate_answer_node,
],
edges=[
(robot_node, fetch_node),
(fetch_node, parse_node),
(parse_node, rag_node),
(rag_node, generate_answer_node)
(parse_node, generate_answer_node)
],
entry_point=robot_node
)
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/json_scraper_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/json_scraper_multi_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

FILE_NAME = "inputs/example.json"
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/pdf_scraper_graph_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

source = """
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/pdf_scraper_multi_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ***************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/scrape_plain_text_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/script_generator_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
7 changes: 3 additions & 4 deletions examples/anthropic/script_multi_generator_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"library": "beautifulsoup"
"model": "anthropic/claude-3-haiku-20240307",
},
"library": "beautifulsoup"
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/search_graph_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
4 changes: 2 additions & 2 deletions examples/anthropic/search_graph_schema_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Dishes(BaseModel):
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
20 changes: 4 additions & 16 deletions examples/anthropic/search_link_graph_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,11 @@

load_dotenv()

llm_model_instance = AzureChatOpenAI(
openai_api_version=os.environ["AZURE_OPENAI_API_VERSION"],
azure_deployment=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
)

embedder_model_instance = AzureOpenAIEmbeddings(
azure_deployment=os.environ["AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME"],
openai_api_version=os.environ["AZURE_OPENAI_API_VERSION"],
)

# ************************************************
# Create the SmartScraperGraph instance and run it
# ************************************************

graph_config = {
"llm": {"model_instance": llm_model_instance},
"embeddings": {"model_instance": embedder_model_instance}
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/smart_scraper_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

smart_scraper_graph = SmartScraperGraph(
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/smart_scraper_multi_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# *******************************************************
Expand Down
4 changes: 2 additions & 2 deletions examples/anthropic/smart_scraper_schema_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Projects(BaseModel):
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000},
"model": "anthropic/claude-3-haiku-20240307",
},
}

smart_scraper_graph = SmartScraperGraph(
Expand Down
4 changes: 2 additions & 2 deletions examples/anthropic/xml_scraper_graph_multi_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
5 changes: 2 additions & 3 deletions examples/anthropic/xml_scraper_haiku.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "claude-3-haiku-20240307",
"max_tokens": 4000
},
"model": "anthropic/claude-3-haiku-20240307",
},
}

# ************************************************
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/csv_scraper_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/csv_scraper_graph_multi_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/json_scraper_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/json_scraper_multi_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/pdf_scraper_graph_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/pdf_scraper_multi_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/scrape_plain_text_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/script_generator_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/script_multi_generator_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/search_graph_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/search_graph_schema_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Dishes(BaseModel):

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/search_link_graph_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/deepseek/smart_scraper_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

graph_config = {
"llm": {
"model": "deepseek-chat",
"model": "deepseek/deepseek-chat",
"openai_api_key": deepseek_key,
"openai_api_base": 'https://api.deepseek.com/v1',
},
Expand Down
Loading

0 comments on commit d45064b

Please sign in to comment.