Skip to content

Commit 722ffbe

Browse files
Flexibility to add already planned task (aiplanethub#54)
* flexibility to the add the already planned task. Limit max_iterations = 20 * avoid ddgs max_results to exceed 15 --------- Co-authored-by: lucifertrj <[email protected]>
1 parent f8dae73 commit 722ffbe

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/openagi/actions/tools/ddg_search.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from openagi.actions.base import BaseAction
44
from pydantic import Field
55
from duckduckgo_search import DDGS
6-
6+
import logging
77

88
class DuckDuckGoSearch(BaseAction):
99
"""Use this Action to search DuckDuckGo for a query."""
@@ -31,6 +31,10 @@ def _get_ddgs(self):
3131
return DDGS()
3232

3333
def execute(self):
34+
if self.max_results > 15:
35+
logging.info("Over threshold value... Limiting the Max results to 15")
36+
self.max_results = 15
37+
3438
result = self._get_ddgs().text(
3539
self.query,
3640
max_results=self.max_results,

src/openagi/agent.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Admin(BaseModel):
4545
description="Actions that the Agent supports", default_factory=list
4646
)
4747
max_iterations: int = Field(
48-
default=20, description="Maximum number of steps to achieve the objective."
48+
default=15, description="Maximum number of steps to achieve the objective."
4949
)
5050
output_format: OutputFormat = Field(
5151
default=OutputFormat.markdown,
@@ -420,11 +420,12 @@ def single_agent_execution(self, query: str, description: str, task_lists: TaskL
420420
logging.debug(f"Execution Completed for Session ID - {self.memory.session_id}")
421421
return output
422422

423-
def run(self, query: str, description: str):
423+
def run(self, query: str, description: str,planned_tasks: Optional[List[Dict]] = None):
424424
logging.info("Running Admin Agent...")
425425
logging.info(f"SessionID - {self.memory.session_id}")
426426

427-
planned_tasks = self.run_planner(query=query, descripton=description)
427+
if planned_tasks is None:
428+
planned_tasks = self.run_planner(query=query, descripton=description)
428429

429430
logging.info("Tasks Planned...")
430431
logging.debug(f"{planned_tasks=}")

0 commit comments

Comments
 (0)