feat(agent): scrape linked pages to ground answers in real content
Adds `_fetch_page_content()`, which downloads a URL with a browser-like User-Agent and uses BeautifulSoup with the lxml parser to strip scripts, navigation, and other non-content markup, returning up to 3000 characters of readable text. The response validator now also compares generated replies against this scraped text, flagging named entities and claims that do not appear in the retrieved page content. Dependencies: adds beautifulsoup4==4.12.3 and pins lxml==5.3.0 for parser compatibility.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# cython: language_level=3
|
||||
# cython: language_level=2
|
||||
|
||||
#
|
||||
# ElementTree
|
||||
@@ -85,8 +85,6 @@ def xpath_tokenizer(pattern, namespaces=None, with_prefixes=True):
|
||||
yield ttype, "{%s}%s" % (namespaces[prefix], uri)
|
||||
except KeyError:
|
||||
raise SyntaxError("prefix %r not found in prefix map" % prefix)
|
||||
elif tag.isdecimal():
|
||||
yield token # index
|
||||
elif default_namespace and not parsing_attribute:
|
||||
yield ttype, "{%s}%s" % (default_namespace, tag)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user