jojopp commited on
Commit
72c7250
·
1 Parent(s): 77726b9

the agent is working again

Browse files
__pycache__/Gradio_UI.cpython-312.pyc CHANGED
Binary files a/__pycache__/Gradio_UI.cpython-312.pyc and b/__pycache__/Gradio_UI.cpython-312.pyc differ
 
__pycache__/app.cpython-312.pyc CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
 
app.py CHANGED
@@ -91,16 +91,44 @@ def research_topic(query: str) -> str:
91
  """
92
  try:
93
  # Create a fresh instance for each search
94
- search_tool = get_search_tool(max_results=3)
95
 
96
  # Add focus on tech and AI product development
97
  enhanced_query = f"{query} AI product development"
98
  results = search_tool.forward(enhanced_query)
99
 
100
  # Format the results in your style
101
- response = f"Quick research on {query}:\n\n"
102
- response += results
103
- response += "\n\nNote: Always verify current info."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  return response
106
  except Exception as e:
 
91
  """
92
  try:
93
  # Create a fresh instance for each search
94
+ search_tool = get_search_tool(max_results=5) # Increased from 3 to 5
95
 
96
  # Add focus on tech and AI product development
97
  enhanced_query = f"{query} AI product development"
98
  results = search_tool.forward(enhanced_query)
99
 
100
  # Format the results in your style
101
+ response = f"# Research on {query}\n\n"
102
+
103
+ # Split content into examples and sources
104
+ examples = []
105
+ sources = []
106
+ current_example = []
107
+
108
+ for line in results.split('\n'):
109
+ if line.startswith('http'):
110
+ sources.append(line.strip())
111
+ if current_example:
112
+ examples.append('\n'.join(current_example))
113
+ current_example = []
114
+ elif line.strip():
115
+ current_example.append(line.strip())
116
+
117
+ if current_example:
118
+ examples.append('\n'.join(current_example))
119
+
120
+ # Add examples with clear separation
121
+ response += "## Key Insights\n\n"
122
+ for i, example in enumerate(examples, 1):
123
+ response += f"### Example {i}\n"
124
+ response += f"{example}\n\n"
125
+
126
+ # Add sources
127
+ response += "\n## Sources\n"
128
+ for source in sources:
129
+ response += f"- {source}\n"
130
+
131
+ response += "\n\nNote: Always verify current information."
132
 
133
  return response
134
  except Exception as e:
tools/__pycache__/blog_tools.cpython-312.pyc CHANGED
Binary files a/tools/__pycache__/blog_tools.cpython-312.pyc and b/tools/__pycache__/blog_tools.cpython-312.pyc differ
 
tools/__pycache__/final_answer.cpython-312.pyc CHANGED
Binary files a/tools/__pycache__/final_answer.cpython-312.pyc and b/tools/__pycache__/final_answer.cpython-312.pyc differ
 
tools/__pycache__/search_tools.cpython-312.pyc ADDED
Binary file (526 Bytes). View file
 
tools/final_answer.py CHANGED
@@ -1,14 +1,51 @@
1
- from typing import Any, Optional
2
  from smolagents.tools import Tool
3
 
4
  class FinalAnswerTool(Tool):
5
  name = "final_answer"
6
- description = "Provides a final answer to the given problem."
7
- inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
8
- output_type = "any"
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- def forward(self, answer: Any) -> Any:
11
- return answer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  def __init__(self, *args, **kwargs):
14
  self.is_initialized = False
 
1
+ from typing import Any, Optional, Dict, Union
2
  from smolagents.tools import Tool
3
 
4
  class FinalAnswerTool(Tool):
5
  name = "final_answer"
6
+ description = "Provides a final answer to the given problem with proper formatting and sources."
7
+ inputs = {
8
+ 'content': {'type': 'string', 'description': 'The main content of the answer'},
9
+ 'sources': {
10
+ 'type': 'array',
11
+ 'description': 'List of sources used in the research',
12
+ 'nullable': True
13
+ },
14
+ 'metadata': {
15
+ 'type': 'object',
16
+ 'description': 'Additional metadata like readability score, SEO info, etc.',
17
+ 'nullable': True
18
+ }
19
+ }
20
+ output_type = "string"
21
 
22
+ def format_output(self, content: str, sources: list = None, metadata: Dict = None) -> str:
23
+ """Format the output in a clean, readable way with proper sections."""
24
+ output_parts = []
25
+
26
+ # Add main content
27
+ output_parts.append("# Content\n")
28
+ output_parts.append(content.strip())
29
+ output_parts.append("\n\n")
30
+
31
+ # Add sources if available
32
+ if sources and len(sources) > 0:
33
+ output_parts.append("# Sources\n")
34
+ for idx, source in enumerate(sources, 1):
35
+ output_parts.append(f"{idx}. {source}\n")
36
+ output_parts.append("\n")
37
+
38
+ # Add metadata if available
39
+ if metadata:
40
+ output_parts.append("# Additional Information\n")
41
+ for key, value in metadata.items():
42
+ output_parts.append(f"- {key}: {value}\n")
43
+
44
+ return "".join(output_parts)
45
+
46
+ def forward(self, content: str, sources: list = None, metadata: Dict = None) -> str:
47
+ """Process the final answer with proper formatting."""
48
+ return self.format_output(content, sources, metadata)
49
 
50
  def __init__(self, *args, **kwargs):
51
  self.is_initialized = False