Scrapegraph-ai/examples/single_node/robot_node.py
2024-04-27 19:07:37 +02:00

43 lines
901 B
Python

"""
Example of custom graph using existing nodes
"""
from scrapegraphai.models import Ollama
from scrapegraphai.nodes import RobotsNode
# ************************************************
# Define the configuration for the graph
# ************************************************
graph_config = {
"llm": {
"model": "ollama/llama3",
"temperature": 0,
"streaming": True
},
}
# ************************************************
# Define the node
# ************************************************
llm_model = Ollama(graph_config["llm"])
robots_node = RobotsNode(
input="url",
output=["is_scrapable"],
node_config={"llm": llm_model}
)
# ************************************************
# Test the node
# ************************************************
state = {
"url": "https://twitter.com/home"
}
result = robots_node.execute(state)
print(result)