Skip to content

Commit

Permalink
update Japanese HTP+OODAR example #289
Browse files Browse the repository at this point in the history
  • Loading branch information
yumano15 committed Jun 6, 2024
1 parent c009526 commit 201a057
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions examples/japanese-easy-demo/main.py
Original file line number Diff line number Diff line change
@@ -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}'

Expand All @@ -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)

Expand Down

0 comments on commit 201a057

Please sign in to comment.