From 4b5e04a0b256563bdc69f744508ca21324ebd68e Mon Sep 17 00:00:00 2001 From: Hugo Saporetti Junior Date: Tue, 8 Oct 2024 21:01:13 -0300 Subject: [PATCH] Fix the history issue: draft --- src/main/askai/core/model/acc_response.py | 9 +++++---- src/main/askai/core/model/action_plan.py | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/askai/core/model/acc_response.py b/src/main/askai/core/model/acc_response.py index bc0cf7b7..cc773218 100644 --- a/src/main/askai/core/model/acc_response.py +++ b/src/main/askai/core/model/acc_response.py @@ -12,13 +12,13 @@ Copyright (c) 2024, HomeSetup """ -from askai.core.enums.acc_color import AccColor, AccuracyColors -from askai.core.support.llm_parser import parse_field from dataclasses import dataclass +from pathlib import Path + from hspylib.core.tools.text_tools import ensure_endswith -from os.path import expandvars -import os +from askai.core.enums.acc_color import AccColor, AccuracyColors +from askai.core.support.llm_parser import parse_field @dataclass(frozen=True) @@ -38,6 +38,7 @@ def parse_response(cls, response: str) -> "AccResponse": :param response: The LLM response. :return: An instance of AccResponse created from the parsed response. """ + Path(Path.home() / 'acc-resp.txt').write_text(response) acc_color: AccColor = AccColor.of_color(parse_field("@color", response)) accuracy: float = float(parse_field("@accuracy", response).strip("%")) diff --git a/src/main/askai/core/model/action_plan.py b/src/main/askai/core/model/action_plan.py index 1b439b8b..d15fd9f8 100644 --- a/src/main/askai/core/model/action_plan.py +++ b/src/main/askai/core/model/action_plan.py @@ -13,6 +13,7 @@ Copyright (c) 2024, HomeSetup """ from dataclasses import dataclass, field +from pathlib import Path from types import SimpleNamespace from typing import Any @@ -60,6 +61,7 @@ def _parse_response(question: str, response: str) -> "ActionPlan": :param response: The router's response. :return: An instance of ActionPlan created from the parsed response. """ + Path(Path.home() / 'splitter-resp.txt').write_text(response) speak: str = parse_field("@speak", response) primary_goal: str = parse_field("@primary_goal", response) @@ -88,7 +90,10 @@ def _direct_answer(question: str, answer: str, goal: str, model: ModelResult) -> :param model: The result model. :return: An instance of ActionPlan created from the direct response. """ - speak: str = answer.split(',')[0].strip("'\"") + if answer: + speak: str = answer.split(',')[0].strip("'\"") + else: + speak: str = answer return ActionPlan(question, speak, goal, True, [], [], model)