alberto-azgz commited on
Commit
298f83f
·
verified ·
1 Parent(s): 83da9d4

Upload agent

Browse files
agent.json CHANGED
@@ -11,8 +11,8 @@
11
  "model": {
12
  "class": "HfApiModel",
13
  "data": {
14
- "last_input_token_count": null,
15
- "last_output_token_count": null,
16
  "model_id": "Qwen/Qwen2.5-Coder-32B-Instruct"
17
  }
18
  },
 
11
  "model": {
12
  "class": "HfApiModel",
13
  "data": {
14
+ "last_input_token_count": 15850,
15
+ "last_output_token_count": 110,
16
  "model_id": "Qwen/Qwen2.5-Coder-32B-Instruct"
17
  }
18
  },
app.py CHANGED
@@ -33,6 +33,7 @@ agent = CodeAgent(
33
  model=model,
34
  tools=[web_search, visit_webpage, suggest_menu, catering_service_tool, superhero_party_theme_generator],
35
  managed_agents=[],
 
36
  max_steps=10,
37
  verbosity_level=2,
38
  grammar=None,
 
33
  model=model,
34
  tools=[web_search, visit_webpage, suggest_menu, catering_service_tool, superhero_party_theme_generator],
35
  managed_agents=[],
36
+ class='CodeAgent',
37
  max_steps=10,
38
  verbosity_level=2,
39
  grammar=None,
tools/superhero_party_theme_generator.py CHANGED
@@ -6,17 +6,17 @@ class SuperheroPartyThemeTool(Tool):
6
  description = """
7
  This tool suggests creative superhero-themed party ideas based on a category.
8
  It returns a unique party theme idea."""
9
- inputs = {'category': {'type': 'string', 'description': "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic gotham')."}}
10
  output_type = "string"
11
 
12
  def forward(self, category: str):
13
  themes = {
14
  "classic heroes": "Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.",
15
  "villain masquerade": "Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.",
16
- "futuristic gotham": "Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets."
17
  }
18
 
19
- return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic gotham'.")
20
 
21
  def __init__(self, *args, **kwargs):
22
  self.is_initialized = False
 
6
  description = """
7
  This tool suggests creative superhero-themed party ideas based on a category.
8
  It returns a unique party theme idea."""
9
+ inputs = {'category': {'type': 'string', 'description': "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic Gotham')."}}
10
  output_type = "string"
11
 
12
  def forward(self, category: str):
13
  themes = {
14
  "classic heroes": "Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.",
15
  "villain masquerade": "Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.",
16
+ "futuristic Gotham": "Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets."
17
  }
18
 
19
+ return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic Gotham'.")
20
 
21
  def __init__(self, *args, **kwargs):
22
  self.is_initialized = False
tools/visit_webpage.py CHANGED
@@ -1,9 +1,8 @@
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
3
- import re
4
  import requests
 
5
  import markdownify
6
- import smolagents
7
 
8
  class VisitWebpageTool(Tool):
9
  name = "visit_webpage"
@@ -15,6 +14,15 @@ class VisitWebpageTool(Tool):
15
  super().__init__()
16
  self.max_output_length = max_output_length
17
 
 
 
 
 
 
 
 
 
 
18
  def forward(self, url: str) -> str:
19
  try:
20
  import re
@@ -22,8 +30,6 @@ class VisitWebpageTool(Tool):
22
  import requests
23
  from markdownify import markdownify
24
  from requests.exceptions import RequestException
25
-
26
- from smolagents.utils import truncate_content
27
  except ImportError as e:
28
  raise ImportError(
29
  "You must install packages `markdownify` and `requests` to run this tool: for instance run `pip install markdownify requests`."
@@ -39,7 +45,7 @@ class VisitWebpageTool(Tool):
39
  # Remove multiple line breaks
40
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
41
 
42
- return truncate_content(markdown_content, self.max_output_length)
43
 
44
  except requests.exceptions.Timeout:
45
  return "The request timed out. Please try again later or check the URL."
 
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
 
3
  import requests
4
+ import re
5
  import markdownify
 
6
 
7
  class VisitWebpageTool(Tool):
8
  name = "visit_webpage"
 
14
  super().__init__()
15
  self.max_output_length = max_output_length
16
 
17
+ def _truncate_content(self, content: str, max_length: int) -> str:
18
+ if len(content) <= max_length:
19
+ return content
20
+ return (
21
+ content[: max_length // 2]
22
+ + f"\n..._This content has been truncated to stay below {max_length} characters_...\n"
23
+ + content[-max_length // 2 :]
24
+ )
25
+
26
  def forward(self, url: str) -> str:
27
  try:
28
  import re
 
30
  import requests
31
  from markdownify import markdownify
32
  from requests.exceptions import RequestException
 
 
33
  except ImportError as e:
34
  raise ImportError(
35
  "You must install packages `markdownify` and `requests` to run this tool: for instance run `pip install markdownify requests`."
 
45
  # Remove multiple line breaks
46
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
47
 
48
+ return self._truncate_content(markdown_content, self.max_output_length)
49
 
50
  except requests.exceptions.Timeout:
51
  return "The request timed out. Please try again later or check the URL."