From 201a0575d6be3c6e2c3ab5b003e39974f7bfddcd Mon Sep 17 00:00:00 2001 From: Nonaka Date: Thu, 6 Jun 2024 14:06:39 +0900 Subject: [PATCH] update Japanese HTP+OODAR example #289 --- examples/japanese-easy-demo/main.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/examples/japanese-easy-demo/main.py b/examples/japanese-easy-demo/main.py index 330d4cc86..6a6976721 100644 --- a/examples/japanese-easy-demo/main.py +++ b/examples/japanese-easy-demo/main.py @@ -1,31 +1,21 @@ from pathlib import Path from dotenv import load_dotenv -from openssa import OodaSSA, TaskDecompositionHeuristic - +from openssa import Agent, FileResource load_dotenv() - LOCAL_CACHE_DOCS_DIR_PATH: Path = Path(__file__).parent / '.data' -JAPANESE_DEMO_HEURISTICS: str = ( - 'Please answer in Japanese.' - 'Pay attention to the total salt content, calories, and total vegetables.' -) - -def get_or_create_ooda_ssa() -> OodaSSA: - ssa = OodaSSA(task_heuristics=TaskDecompositionHeuristic({}), - highest_priority_heuristic=JAPANESE_DEMO_HEURISTICS, - enable_generative=True) - ssa.activate_resources(LOCAL_CACHE_DOCS_DIR_PATH) - return ssa +def get_or_create_agent() -> Agent: + return Agent( + resources={FileResource(path=LOCAL_CACHE_DOCS_DIR_PATH)} + ) def solve(question) -> str: - ooda_ssa = get_or_create_ooda_ssa() + agent = get_or_create_agent() try: - return ooda_ssa.solve(question) - + return agent.solve(problem=question) except Exception as err: # pylint: disable=broad-exception-caught return f'ERROR: {err}' @@ -35,6 +25,7 @@ def solve(question) -> str: 'Please tell me three dishes you recommend.' 'Please limit the total salt content of the three dishes to less than 21.5g.' 'Also, please make sure that the total amount of vegetables in the three dishes is at least 700g.' + 'Please answer in Japanese.' ) answer = solve(QUESTION)