Skip to content

Commit

Permalink
Bugfixes - part1
Browse files Browse the repository at this point in the history
  • Loading branch information
yorevs committed Sep 26, 2024
1 parent 5228bae commit 31a16ba
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
25 changes: 15 additions & 10 deletions src/main/askai/core/askai.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
Copyright (c) 2024, HomeSetup
"""
import logging as log
import os
import re
import sys
from enum import Enum
from pathlib import Path
from typing import List, Optional, TypeAlias

from askai.__classpath__ import classpath
from askai.core.askai_configs import configs
from askai.core.askai_events import events
Expand All @@ -26,23 +34,20 @@
from askai.core.support.chat_context import ChatContext
from askai.core.support.shared_instances import shared
from askai.core.support.utilities import read_stdin
from askai.exception.exceptions import (ImpossibleQuery, InaccurateResponse, IntelligibleAudioError,
MaxInteractionsReached, TerminatingQuery)
from askai.exception.exceptions import (
ImpossibleQuery,
InaccurateResponse,
IntelligibleAudioError,
MaxInteractionsReached,
TerminatingQuery,
)
from askai.tui.app_icons import AppIcons
from click import UsageError
from enum import Enum
from hspylib.core.enums.charset import Charset
from hspylib.core.tools.commons import file_is_not_empty, is_debugging
from hspylib.core.zoned_datetime import DATE_FORMAT, now, TIME_FORMAT
from hspylib.modules.application.exit_status import ExitStatus
from openai import RateLimitError
from pathlib import Path
from typing import List, Optional, TypeAlias

import logging as log
import os
import re
import sys

QueryString: TypeAlias = str | List[str] | None

Expand Down
3 changes: 0 additions & 3 deletions src/main/askai/core/askai_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ def no_caption(self) -> str:
def no_good_result(self) -> str:
return "The search did not bring any good result"

def consider_done(self) -> str:
return "Sure! Consider it done."

# Warnings and alerts

def no_output(self, source: str) -> str:
Expand Down
7 changes: 4 additions & 3 deletions src/main/askai/core/model/action_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from dataclasses import dataclass, field
from types import SimpleNamespace

from askai.core.askai_messages import msg
from askai.core.model.model_result import ModelResult
from hspylib.core.preconditions import check_state
from langchain_core.messages import AIMessage
Expand Down Expand Up @@ -109,8 +108,9 @@ def _direct_answer(question: str, response: str, model: ModelResult) -> "ActionP
:return: An instance of ActionPlan created from the direct response.
"""
flags: int = re.IGNORECASE | re.MULTILINE | re.DOTALL
speak: str = re.sub(r"\*\*Direct:\*\*(.+?)", "\1", response, flags)

return ActionPlan(question, re.sub(r"\*\*Direct:\*\*(.+?)", "\1", response, flags), "N/A", [], [], model)
return ActionPlan(question, speak, "N/A", [], [], model)

@staticmethod
def _direct_task(question: str, response: str, model: ModelResult) -> "ActionPlan":
Expand All @@ -120,8 +120,9 @@ def _direct_task(question: str, response: str, model: ModelResult) -> "ActionPla
:param model: The result model.
:return: An instance of ActionPlan created from the direct response.
"""
tasks: list[SimpleNamespace] = [SimpleNamespace(id="1", task=response)]

return ActionPlan(question, msg.consider_done(), "N/A", [], [SimpleNamespace(id="1", task=response)], model)
return ActionPlan(question, "", "N/A", [], tasks, model)

def __str__(self):
sub_goals: str = " ".join(f"{i + 1}. {g}" for i, g in enumerate(self.sub_goals)) if self.sub_goals else "N/A"
Expand Down
16 changes: 8 additions & 8 deletions src/main/askai/resources/prompts/task-splitter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ The following examples can be used to help your decisions (note that it is not a
The response should follow this format:


@thought: <your thoughts>
@observation: <your observations>
@criticism: <your criticism>
@check_history: <thoughts about the conversation history; if applicable>
@thought: "<your thoughts>"
@observation: "<your observations>"
@criticism: "<your criticism>"
@check_history: "<quietly review the conversation history>"
... (repeat thought/observation/criticism/check_history N times)
@thought: Everything is looking good.
@conclusion: I know what to respond.
@primary_goal: <identified primary goal>
@thought: "Everything is looking good."
@conclusion: "I know what to respond."
@primary_goal: "<identified primary goal>"
@sub_goals: [
{{{{ "id": "<num>", "sub_goal": "<identified sub-goal>" }}}},
... (repeat N times)
Expand All @@ -130,7 +130,7 @@ The response should follow this format:

<<IMPORTANT>>

Always remember to include at least @primary_goal, @sub_goals, @speak, and @tasks. Ensure that @sub_goals and @tasks are parseable by ast.literal_eval, so make sure to include the '[..]' brackets around them. Retain all '@' symbols and avoid reformatting '@words', as altering them will cause the parser to fail.
Always remember to include at least @primary_goal, @sub_goals, @speak, and @tasks. Ensure that @sub_goals and @tasks are parseable by ast.literal_eval, so make sure to include the '[..]' brackets around them. Retain all '@' and '"' symbols and avoid reformatting '@words', as altering them will cause the parser to fail.


Begin!

0 comments on commit 31a16ba

Please sign in to comment.