Skip to content

Commit d9c05b1

Browse files
added experiment chat mode for experimenting in the same session
1 parent b97d092 commit d9c05b1

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

src/openagi/actions/obs_rag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class MemoryRagAction(BaseAction):
2121

2222
def execute(self):
2323
resp = self.memory.search(query=self.query, n_results=self.max_results or 10)
24-
logging.debug(f"Retreived MEMORY DATA - {resp}")
24+
logging.info(f"Retreived MEMORY DATA - {resp}")
2525
return resp

src/openagi/actions/tools/ddg_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DuckDuckGoSearch(BaseAction):
2323
)
2424

2525
max_results: int = Field(
26-
default=10,
26+
default=5,
2727
description="Total results, in int, to be executed from the search. Defaults to 10.",
2828
)
2929

src/openagi/agent.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from enum import Enum
33
from textwrap import dedent
4-
from typing import Any, Dict, List, Optional, Union, Tuple
4+
from typing import Any, Dict, List, Optional, Tuple, Union
55
from pydantic import BaseModel, Field, field_validator
66

77
from openagi.actions.base import BaseAction
@@ -16,9 +16,7 @@
1616
from openagi.prompts.worker_task_execution import WorkerAgentTaskExecution
1717
from openagi.tasks.lists import TaskLists
1818
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,
2220
)
2321
from openagi.utils.helper import get_default_llm
2422
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):
141139
def _generate_tasks_list(self, planned_tasks):
142140
task_lists = TaskLists()
143141
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.")
145143
return task_lists
146144

147145
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
261259
main_task_list = TaskLists()
262260
while not task_lists.all_tasks_completed:
263261
cur_task = task_lists.get_next_unprocessed_task()
264-
print(cur_task)
262+
# print(cur_task)
265263
logging.info(f"**** Executing Task - {cur_task.name} [{cur_task.id}] ****")
266264

267265
worker_config = cur_task.worker_config
@@ -430,6 +428,19 @@ def single_agent_execution(self, query: str, description: str, task_lists: TaskL
430428
logging.debug(f"Execution Completed for Session ID - {self.memory.session_id}")
431429
return output
432430

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.")
433444

434445
def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] = None):
435446
logging.info("Running Admin Agent...")
@@ -472,7 +483,7 @@ def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] =
472483

473484

474485
logging.info("Tasks Planned...")
475-
logging.debug(f"{planned_tasks=}")
486+
logging.info(f"{planned_tasks=}")
476487

477488
task_lists: TaskLists = self._generate_tasks_list(planned_tasks=planned_tasks)
478489

@@ -510,12 +521,6 @@ def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] =
510521
self.save_ltm("add", session)
511522
return result
512523

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-
519524
def get_supported_actions_for_worker(self, actions_list: List[str],tool_list: List[str]):
520525
"""
521526
This function takes a list of action names (strings) and returns a list of class objects

src/openagi/memory/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, **data: Any):
5050
collection_name="long_term_memory",
5151
persist_path=self.long_term_dir
5252
)
53-
assert 1 >= self.ltm_threshold >= 0.6, "Semantic similarity threshold should be between 0.6 and 1"
53+
assert 1 >= self.ltm_threshold >= 0.7, "Semantic similarity threshold should be between 0.7 and 1"
5454

5555
logging.info(f"Session ID initialized: {self.session_id}")
5656
if self.long_term:
@@ -114,7 +114,7 @@ def save_task(self, task: Task) -> None:
114114
)
115115
logging.info(f"Task saved: {task.id}")
116116

117-
def save_planned_tasks(self, tasks: TaskLists) -> None:
117+
def save_planned_tasks(self, tasks: List[Task]) -> None:
118118
"""
119119
Save a list of planned tasks into Memory.
120120

src/openagi/planner/task_decomposer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def plan(
202202
if not tasks:
203203
raise LLMResponseError("Note: This not a error => No tasks was planned in the Planner response. Tweak the prompt and actions, then try again")
204204

205-
print(f"\n\nTasks: {tasks}\n\n")
205+
# print(f"\n\nTasks: {tasks}\n\n")
206206
return tasks
207207

208208
def _extract_task_with_retry(self, llm_response: str, prompt: str) -> Dict:

0 commit comments

Comments
 (0)