diff --git a/exemples/find_file.png b/exemples/find_file.png deleted file mode 100644 index 11be4fc..0000000 Binary files a/exemples/find_file.png and /dev/null differ diff --git a/exemples/search_and_planner.png b/exemples/search_and_planner.png deleted file mode 100644 index 8fced31..0000000 Binary files a/exemples/search_and_planner.png and /dev/null differ diff --git a/exemples/whale_readme.jpg b/exemples/whale_readme.jpg deleted file mode 100644 index 1ad7539..0000000 Binary files a/exemples/whale_readme.jpg and /dev/null differ diff --git a/sources/agents/casual_agent.py b/sources/agents/casual_agent.py index 1d5467f..0b5f6ca 100644 --- a/sources/agents/casual_agent.py +++ b/sources/agents/casual_agent.py @@ -18,7 +18,7 @@ class CasualAgent(Agent): "file_finder": FileFinder(), "bash": BashInterpreter() } - self.role = "talking, advices and philosophical" + self.role = "talking, advices, events and philosophical" def process(self, prompt, speech_module) -> str: complete = False @@ -32,8 +32,10 @@ class CasualAgent(Agent): exec_success, _ = self.execute_modules(answer) answer = self.remove_blocks(answer) self.last_answer = answer - if exec_success: - complete = True + complete = True + for tool in self.tools.values(): + if tool.found_executable_blocks(): + complete = False # AI read results and continue the conversation return answer, reasoning if __name__ == "__main__": diff --git a/sources/agents/planner_agent.py b/sources/agents/planner_agent.py index d82b4e9..aaafc3a 100644 --- a/sources/agents/planner_agent.py +++ b/sources/agents/planner_agent.py @@ -81,6 +81,9 @@ class PlannerAgent(Agent): speech_module.speak(f"I will {task_name}. I assigned the {task['agent']} agent to the task.") try: self.agents[task['agent'].lower()].process(agent_prompt, None) + pretty_print(f"-- Agent answer ---\n\n", color="output") + self.agents[task['agent'].lower()].show_answer() + pretty_print(f"\n\n", color="output") except Exception as e: pretty_print(f"Error: {e}", color="failure") speech_module.speak(f"I encountered an error: {e}") diff --git a/sources/tools/tools.py b/sources/tools/tools.py index c6856e0..92acaba 100644 --- a/sources/tools/tools.py +++ b/sources/tools/tools.py @@ -39,6 +39,7 @@ class Tools(): self.messages = [] self.config = configparser.ConfigParser() self.current_dir = self.create_work_dir() + self.excutable_blocks_found = False def check_config_dir_validity(self): """ @@ -129,6 +130,14 @@ class Tools(): print(f"Saving code block to: {save_path}") with open(os.path.join(directory, save_path_file), 'w') as f: f.write(block) + + def found_executable_blocks(self): + """ + Check if executable blocks were found. + """ + tmp = self.excutable_blocks_found + self.excutable_blocks_found = False + return tmp def load_exec_block(self, llm_text: str) -> tuple[list[str], str | None]: """ @@ -178,6 +187,7 @@ class Tools(): if ':' in content.split('\n')[0]: save_path = content.split('\n')[0].split(':')[1] content = content[content.find('\n')+1:] + self.excutable_blocks_found = True code_blocks.append(content) start_index = end_pos + len(end_tag) return code_blocks, save_path diff --git a/sources/tools/webSearch.py b/sources/tools/webSearch.py index 2411902..4544d1f 100644 --- a/sources/tools/webSearch.py +++ b/sources/tools/webSearch.py @@ -6,9 +6,13 @@ import dotenv dotenv.load_dotenv() if __name__ == "__main__": + import sys + sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + from utility import animate_thinking, pretty_print from tools import Tools else: from sources.tools.tools import Tools + from sources.utility import animate_thinking, pretty_print class webSearch(Tools): def __init__(self, api_key: str = None): @@ -24,6 +28,7 @@ class webSearch(Tools): return "Error: No SerpApi key provided." for block in blocks: query = block.strip() + pretty_print(f"Searching for: {query}", color="status") if not query: return "Error: No search query provided." @@ -32,19 +37,21 @@ class webSearch(Tools): params = { "q": query, "api_key": self.api_key, - "num": 1, + "num": 100, "output": "json" } response = requests.get(url, params=params) response.raise_for_status() data = response.json() + results = [] if "organic_results" in data and len(data["organic_results"]) > 0: - first_result = data["organic_results"][0] - title = first_result.get("title", "No title") - snippet = first_result.get("snippet", "No snippet available") - link = first_result.get("link", "No link available") - return f"Title: {title}\nSnippet: {snippet}\nLink: {link}" + for result in data["organic_results"][:50]: + title = result.get("title", "No title") + snippet = result.get("snippet", "No snippet available") + link = result.get("link", "No link available") + results.append(f"Title: {title}\nSnippet: {snippet}\nLink: {link}") + return "\n\n".join(results) else: return "No results found for the query." except requests.RequestException as e: @@ -65,6 +72,6 @@ class webSearch(Tools): if __name__ == "__main__": search_tool = webSearch(api_key=os.getenv("SERPAPI_KEY")) query = "when did covid start" - result = search_tool.execute(query, safety=True) + result = search_tool.execute([query], safety=True) feedback = search_tool.interpreter_feedback(result) print(feedback) \ No newline at end of file