Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
add new example for gemini
VinciGit00e0c5bfe09340
diff --git a/examples/graph_examples/custom_graph_example.py b/examples/graph_examples/custom_graph_example.pyindex c22cd369..8d4f1bd0 100644--- a/examples/graph_examples/custom_graph_example.py+++ b/examples/graph_examples/custom_graph_example.py@@ -4,36 +4,27 @@ Example of custom graph using existing nodesimport osfrom dotenv import load_dotenv-#from scrapegraphai.models import OpenAI-from scrapegraphai.models import Gemini+from scrapegraphai.models import OpenAIfrom scrapegraphai.graphs import BaseGraph-from scrapegraphai.nodes import FetchHTMLNode, ParseNode, GenerateAnswerNodeVanilla--+from scrapegraphai.nodes import FetchHTMLNode, ParseNode, RAGNode, GenerateAnswerNodeVanillaload_dotenv()# Define the configuration for the language model-""" openai_key = os.getenv("OPENAI_APIKEY")+openai_key = os.getenv("OPENAI_APIKEY")llm_config = {"api_key": openai_key,"model_name": "gpt-3.5-turbo","temperature": 0,"streaming": True}-model = OpenAI(llm_config) """--gemini_key = os.getenv("GOOGLE_API_KEY")-llm_config = {- "api_key": gemini_key,- "model_name": "gemini-pro",-}--model = Gemini(llm_config)+model = OpenAI(llm_config)# define the nodes for the graphfetch_html_node = FetchHTMLNode("fetch_html")-parse_document_node = ParseNode(doc_type="html", chunks_size=4000, node_name="parse_document")+parse_document_node = ParseNode(+ doc_type="html", chunks_size=4000, node_name="parse_document")+rag_node = RAGNode(model, "rag")generate_answer_node = GenerateAnswerNodeVanilla(model, "generate_answer")# create the graph@@ -41,18 +32,20 @@ graph = BaseGraph(nodes={fetch_html_node,parse_document_node,+ rag_node,generate_answer_node},edges={(fetch_html_node, parse_document_node),- (parse_document_node,generate_answer_node)+ (parse_document_node, rag_node),+ (rag_node, generate_answer_node)},entry_point=fetch_html_node)# execute the graphinputs = {"user_input": "List me the projects with their description",- "url": "https://perinim.github.io/projects/"}+ "url": "https://perinim.github.io/projects/"}result = graph.execute(inputs)# get the answer from the resultdiff --git a/examples/graph_examples/custom_graph_gemini.py b/examples/graph_examples/custom_graph_gemini.pynew file mode 100644index 00000000..86117846--- /dev/null+++ b/examples/graph_examples/custom_graph_gemini.py@@ -0,0 +1,49 @@+"""+Example of custom graph using existing node using Gemini APIs+"""++import os+from dotenv import load_dotenv+from scrapegraphai.models import Gemini+from scrapegraphai.graphs import BaseGraph+from scrapegraphai.nodes import FetchHTMLNode, ParseNode, GenerateAnswerNodeVanilla+++load_dotenv()++gemini_key = os.getenv("GOOGLE_API_KEY")+llm_config = {+ "api_key": gemini_key,+ "model_name": "gemini-pro",+}++model = Gemini(llm_config)++# define the nodes for the graph+fetch_html_node = FetchHTMLNode("fetch_html")+parse_document_node = ParseNode(+ doc_type="html", chunks_size=4000, node_name="parse_document")+generate_answer_node = GenerateAnswerNodeVanilla(model, "generate_answer")++# create the graph+graph = BaseGraph(+ nodes={+ fetch_html_node,+ parse_document_node,+ generate_answer_node+ },+ edges={+ (fetch_html_node, parse_document_node),+ (parse_document_node, generate_answer_node)+ },+ entry_point=fetch_html_node+)++# execute the graph+inputs = {"user_input": "List me the projects with their description",+ "url": "https://perinim.github.io/projects/"}+result = graph.execute(inputs)++# get the answer from the result+answer = result.get("answer", "No answer found.")+print(answer)diff --git a/pyproject.toml b/pyproject.tomlindex 0a1a552e..ade0885a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "scrapegraphai"-version = "0.0.8"+version = "0.0.9"description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines."authors = ["Marco Vinciguerra <[email protected]>",