fixed internet research

This commit is contained in:
VinciGit00 2024-04-06 14:39:19 +02:00
parent 57a53bd6af
commit a5fc71f34e
2 changed files with 9 additions and 3 deletions

View File

@ -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)
print(result)
# Save to json and csv
convert_to_csv(result, "result")
convert_to_json(result, "result")

View File

@ -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})