Merge branch 'master' into dev

This commit is contained in:
Andres Caicedo
2023-04-04 11:47:37 +02:00
3 changed files with 27 additions and 50 deletions

View File

@@ -74,7 +74,7 @@ def execute_command(command_name, arguments):
elif command_name == "delete_agent":
return delete_agent(arguments["key"])
elif command_name == "get_text_summary":
return get_text_summary(arguments["url"])
return get_text_summary(arguments["url"], arguments["question"])
elif command_name == "get_hyperlinks":
return get_hyperlinks(arguments["url"])
elif command_name == "read_file":
@@ -86,7 +86,7 @@ def execute_command(command_name, arguments):
elif command_name == "delete_file":
return delete_file(arguments["file"])
elif command_name == "browse_website":
return browse_website(arguments["url"])
return browse_website(arguments["url"], arguments["question"])
# TODO: Change these to take in a file rather than pasted code, if
# non-file is given, return instructions "Input should be a python
# filepath, write your code to file and try again"
@@ -157,9 +157,9 @@ def google_official_search(query, num_results=8):
# Return the list of search result URLs
return search_results_links
def browse_website(url):
"""Return the results of a google search"""
summary = get_text_summary(url)
def browse_website(url, question):
"""Browse a website and return the summary and links"""
summary = get_text_summary(url, question)
links = get_hyperlinks(url)
# Limit links to 5
@@ -171,10 +171,10 @@ def browse_website(url):
return result
def get_text_summary(url):
def get_text_summary(url, question):
"""Return the results of a google search"""
text = browse.scrape_text(url)
summary = browse.summarize_text(text)
summary = browse.summarize_text(text, question)
return """ "Result" : """ + summary