diff --git a/examples/graph_examples/search_graph_example.py b/examples/graph_examples/search_graph_example.py index 458274ef..5d3a2270 100644 --- a/examples/graph_examples/search_graph_example.py +++ b/examples/graph_examples/search_graph_example.py @@ -5,6 +5,7 @@ Example of Search Graph import os from dotenv import load_dotenv from scrapegraphai.graphs import SearchGraph +from scrapegraphai.utils import convert_to_csv, convert_to_json load_dotenv() openai_key = os.getenv("OPENAI_APIKEY") @@ -25,4 +26,8 @@ smart_scraper_graph = SearchGraph( ) result = smart_scraper_graph.run() -print(result) \ No newline at end of file +print(result) + +# Save to json and csv +convert_to_csv(result, "result") +convert_to_json(result, "result") diff --git a/scrapegraphai/nodes/search_internet_node.py b/scrapegraphai/nodes/search_internet_node.py index 0b33f79b..88297c1d 100644 --- a/scrapegraphai/nodes/search_internet_node.py +++ b/scrapegraphai/nodes/search_internet_node.py @@ -80,7 +80,8 @@ class SearchInternetNode(BaseNode): output_parser = CommaSeparatedListOutputParser() - search_template = """Given the following user prompt, return a query that can be used to search the internet for relevant information. \n + search_template = """Given the following user prompt, return a query that can be + used to search the internet for relevant information. \n You should return only the query string. \n User Prompt: {user_prompt}""" @@ -95,7 +96,7 @@ class SearchInternetNode(BaseNode): print(f"Search Query: {search_query}") # TODO: handle multiple URLs - answer = search_on_web(query=search_query, search_engine="DuckDuckGo", max_results=1)[0] + answer = search_on_web(query=search_query, max_results=1)[0] # Update the state with the generated answer state.update({self.output[0]: answer})