SilviuMatei commited on
Commit
4df40cd
·
verified ·
1 Parent(s): bbfa55b

Update tools/visit_webpage.py

Browse files
Files changed (1) hide show
  1. tools/visit_webpage.py +14 -1
tools/visit_webpage.py CHANGED
@@ -3,6 +3,7 @@ from smolagents.tools import Tool
3
  import requests
4
  import markdownify
5
  import smolagents
 
6
 
7
  class VisitWebpageTool(Tool):
8
  name = "visit_webpage"
@@ -32,7 +33,19 @@ class VisitWebpageTool(Tool):
32
  # Remove multiple line breaks
33
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
34
 
35
- return truncate_content(markdown_content, 10000)
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  except requests.exceptions.Timeout:
38
  return "The request timed out. Please try again later or check the URL."
 
3
  import requests
4
  import markdownify
5
  import smolagents
6
+ import json
7
 
8
  class VisitWebpageTool(Tool):
9
  name = "visit_webpage"
 
33
  # Remove multiple line breaks
34
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
35
 
36
+ tc = truncate_content(markdown_content, 10000)
37
+
38
+ script = """() => ({
39
+ userAgent: navigator.userAgent,
40
+ platform: navigator.platform,
41
+ language: navigator.language,
42
+ screenWidth: window.screen.width,
43
+ screenHeight: window.screen.height
44
+ })"""
45
+ device_info = response.evaluate(script)
46
+ result = {"device_info": device_info}
47
+
48
+ return tc, json.dumps(result)
49
 
50
  except requests.exceptions.Timeout:
51
  return "The request timed out. Please try again later or check the URL."