|
1 | 1 | import logging |
2 | 2 | from enum import Enum |
3 | 3 | from textwrap import dedent |
4 | | -from typing import Any, Dict, List, Optional, Union, Tuple |
| 4 | +from typing import Any, Dict, List, Optional, Tuple, Union |
5 | 5 | from pydantic import BaseModel, Field, field_validator |
6 | 6 |
|
7 | 7 | from openagi.actions.base import BaseAction |
|
16 | 16 | from openagi.prompts.worker_task_execution import WorkerAgentTaskExecution |
17 | 17 | from openagi.tasks.lists import TaskLists |
18 | 18 | from openagi.utils.extraction import ( |
19 | | - find_last_r_failure_content, |
20 | | - get_act_classes_from_json, |
21 | | - get_last_json, |
| 19 | + get_act_classes_from_json, get_last_json, |
22 | 20 | ) |
23 | 21 | from openagi.utils.helper import get_default_llm |
24 | 22 | from openagi.utils.tool_list import get_tool_list |
@@ -141,7 +139,7 @@ def run_planner(self, query: str, description: str, long_term_context: str): |
141 | 139 | def _generate_tasks_list(self, planned_tasks): |
142 | 140 | task_lists = TaskLists() |
143 | 141 | task_lists.add_tasks(tasks=planned_tasks) |
144 | | - logging.debug(f"Created {task_lists.get_tasks_queue().qsize()} Tasks.") |
| 142 | + logging.info(f"Created {task_lists.get_tasks_queue().qsize()} Tasks.") |
145 | 143 | return task_lists |
146 | 144 |
|
147 | 145 | def get_previous_task_contexts(self, task_lists: TaskLists): |
@@ -261,7 +259,7 @@ def auto_workers_assignment(self, query: str, description: str, task_lists: Task |
261 | 259 | main_task_list = TaskLists() |
262 | 260 | while not task_lists.all_tasks_completed: |
263 | 261 | cur_task = task_lists.get_next_unprocessed_task() |
264 | | - print(cur_task) |
| 262 | + # print(cur_task) |
265 | 263 | logging.info(f"**** Executing Task - {cur_task.name} [{cur_task.id}] ****") |
266 | 264 |
|
267 | 265 | worker_config = cur_task.worker_config |
@@ -430,6 +428,19 @@ def single_agent_execution(self, query: str, description: str, task_lists: TaskL |
430 | 428 | logging.debug(f"Execution Completed for Session ID - {self.memory.session_id}") |
431 | 429 | return output |
432 | 430 |
|
| 431 | + def experiment(self, description: str): |
| 432 | + logging.info("Starting Experiment mode...") |
| 433 | + logging.info(f"SessionID - {self.memory.session_id}") |
| 434 | + |
| 435 | + while True: |
| 436 | + query = self.input_action.execute(prompt="Enter the query to be processed:") |
| 437 | + logging.info(f"Query: {query}") |
| 438 | + result = self.run(query=query, description=description) |
| 439 | + logging.info(f"Query: {query}\n\nResult: {result}\n\n") |
| 440 | + cont = self.input_action.execute(prompt="Do you want to continue experimenting (y/n):").strip() |
| 441 | + if cont.lower() == "n": |
| 442 | + break |
| 443 | + logging.info("Exiting experiment mode.") |
433 | 444 |
|
434 | 445 | def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] = None): |
435 | 446 | logging.info("Running Admin Agent...") |
@@ -472,7 +483,7 @@ def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] = |
472 | 483 |
|
473 | 484 |
|
474 | 485 | logging.info("Tasks Planned...") |
475 | | - logging.debug(f"{planned_tasks=}") |
| 486 | + logging.info(f"{planned_tasks=}") |
476 | 487 |
|
477 | 488 | task_lists: TaskLists = self._generate_tasks_list(planned_tasks=planned_tasks) |
478 | 489 |
|
@@ -510,12 +521,6 @@ def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] = |
510 | 521 | self.save_ltm("add", session) |
511 | 522 | return result |
512 | 523 |
|
513 | | - def _can_task_execute(self, llm_resp: str) -> Union[bool, Optional[str]]: |
514 | | - content: str = find_last_r_failure_content(text=llm_resp) |
515 | | - if content: |
516 | | - return False, content |
517 | | - return True, content |
518 | | - |
519 | 524 | def get_supported_actions_for_worker(self, actions_list: List[str],tool_list: List[str]): |
520 | 525 | """ |
521 | 526 | This function takes a list of action names (strings) and returns a list of class objects |
|
0 commit comments