BUGFIX: Selenium Driver object reference was included in the browsing results for some reason (#3642)

* * there is really no need to return the  reference to the Selenium driver along with the text summary and list of links.

* * removing unused second return value from browse_website()

* * updated cassette

* * updated YAML cassette for test_browse_website

* * after requirements reinstall, another update YAML cassette for test_browse_website

* * another update YAML cassette for test_browse_website, only as a placholder commit to trigger re-testing due to some docker TCP timeout issue

* * another update YAML cassette for test_browse_website

---------

Co-authored-by: batyu <batyu@localhost>
This commit is contained in:
bszollosinagy
2023-05-05 00:11:21 +02:00
committed by GitHub
parent 7d234522b7
commit ea08050049
3 changed files with 428 additions and 1429 deletions

View File

@@ -34,7 +34,7 @@ CFG = Config()
'"url": "<url>", "question": "<what_you_want_to_find_on_website>"', '"url": "<url>", "question": "<what_you_want_to_find_on_website>"',
) )
@validate_url @validate_url
def browse_website(url: str, question: str) -> tuple[str, WebDriver]: def browse_website(url: str, question: str) -> str:
"""Browse a website and return the answer and links to the user """Browse a website and return the answer and links to the user
Args: Args:
@@ -50,7 +50,7 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]:
# These errors are often quite long and include lots of context. # These errors are often quite long and include lots of context.
# Just grab the first line. # Just grab the first line.
msg = e.msg.split("\n")[0] msg = e.msg.split("\n")[0]
return f"Error: {msg}", None return f"Error: {msg}"
add_header(driver) add_header(driver)
summary_text = summary.summarize_text(url, text, question, driver) summary_text = summary.summarize_text(url, text, question, driver)
@@ -60,7 +60,7 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]:
if len(links) > 5: if len(links) > 5:
links = links[:5] links = links[:5]
close_browser(driver) close_browser(driver)
return f"Answer gathered from website: {summary_text} \n \n Links: {links}", driver return f"Answer gathered from website: {summary_text} \n \n Links: {links}"
def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]: def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:

View File

@@ -5,7 +5,7 @@ def test_browse_website():
url = "https://barrel-roll.com" url = "https://barrel-roll.com"
question = "How to execute a barrel roll" question = "How to execute a barrel roll"
response, _ = browse_website(url, question) response = browse_website(url, question)
assert "Error" in response assert "Error" in response
# Sanity check that the response is not too long # Sanity check that the response is not too long
assert len(response) < 200 assert len(response) < 200