Skip to content

Commit

Permalink
Exceptional case error in task-splitter. Need the test
Browse files Browse the repository at this point in the history
  • Loading branch information
yorevs committed Sep 27, 2024
1 parent c2a7666 commit 0c0149b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/main/askai/core/askai_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _input(self) -> Optional[str]:
"""Read the user input from stdin.
:return: The user's input as a string, or None if no input is provided.
"""
return shared.input_text(f"{shared.username}", f"Message {self.engine.nickname()}")
return shared.input_text(f"{shared.username}", f"{msg.t('Message')} {self.engine.nickname()}")

def _cb_reply_event(self, ev: Event) -> None:
"""Callback to handle reply events.
Expand Down Expand Up @@ -188,21 +188,21 @@ def _startup(self) -> None:
if configs.is_interactive:
splash_thread: Thread = Thread(daemon=True, target=self._splash)
splash_thread.start()
task = self._progress.add_task("[green]Starting up...", total=len(tasks))
task = self._progress.add_task(f'[green] {msg.t("Starting up...")}', total=len(tasks))
with self._progress:
os.chdir(Path.home())
self._progress.update(task, advance=1, description="[green]Downloading nltk data")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Downloading nltk data")}')
nltk.download("averaged_perceptron_tagger", quiet=True, download_dir=CACHE_DIR)
cache.cache_enable = configs.is_cache
self._progress.update(task, advance=1, description="[green]Loading input history")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Loading input history")}')
KeyboardInput.preload_history(cache.load_input_history(commands()))
self._progress.update(task, advance=1, description="[green]Starting scheduler")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Starting scheduler")}')
scheduler.start()
self._progress.update(task, advance=1, description="[green]Setting up recorder")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Setting up recorder")}')
recorder.setup()
self._progress.update(task, advance=1, description="[green]Starting player delay")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Starting player delay")}')
player.start_delay()
self._progress.update(task, advance=1, description="[green]Finalizing startup")
self._progress.update(task, advance=1, description=f'[green] {msg.t("Finalizing startup")}')
pause.seconds(1)
self._ready = True
splash_thread.join()
Expand Down
13 changes: 6 additions & 7 deletions src/main/askai/core/askai_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
Copyright (c) 2024, HomeSetup
"""
import os
from shutil import which

from hspylib.core.enums.charset import Charset
from hspylib.core.metaclass.singleton import Singleton

from askai.__classpath__ import classpath
from askai.core.askai_settings import settings
from askai.core.enums.verbosity import Verbosity
from askai.language.language import Language
from hspylib.core.enums.charset import Charset
from hspylib.core.metaclass.singleton import Singleton
from shutil import which

import locale
import os


class AskAiConfigs(metaclass=Singleton):
Expand Down Expand Up @@ -124,7 +124,6 @@ def language(self) -> Language:
"""Lookup order: Settings -> Locale -> Environment."""
return Language.of_locale(
settings.get("askai.preferred.language")
or locale.getlocale(locale.LC_ALL)
or os.getenv("LC_ALL", os.getenv("LC_TYPE", os.getenv("LANG")))
or Language.EN_US.idiom
)
Expand Down
7 changes: 7 additions & 0 deletions src/main/askai/core/askai_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def translate(self, text: AnyStr) -> str:
return text
return self.translator.translate(str(text))

def t(self, text: AnyStr) -> str:
"""Wrapper to translate.
:param text: The text to be translated.
:return: The translated text.
"""
return self.translate(text)

# Informational

def welcome(self, username: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/main/askai/core/support/shared_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def input_text(self, input_prompt: str, placeholder: str | None = None) -> Optio
"""
ret = None
while ret is None:
if (ret := line_input(input_prompt, placeholder)) == Keyboard.VK_CTRL_L: # Use STT as input method.
if (ret := line_input(input_prompt, placeholder)) == Keyboard.VK_CTRL_L: # Use voice input.
terminal.cursor.erase_line()
if spoken_text := self.engine.speech_to_text():
display_text(f"{self.username}: {spoken_text}")
Expand Down
1 change: 1 addition & 0 deletions src/main/askai/resources/rag/task-splitter.csv
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ Who is Hugo Saporetti Junior;I'm unable to provide real-time information about i
Open Hugo Saporetti junior's linkedin page;The user requests that I open the LinkedIn page of 'Hugo Saporetti Junior', therefore, I need to search for it and open it if found.;N/A;[{{1. Search google for: site:linkedin.com/in "Hugo Saporetti Junior" linkedIn }}, {{2. Open the URL if found}}]
Open the official wikipedia website;The user wants me to open the official wikipedia website, which is a widely known URL.;Direct: Open the URL https://www.wikipedia.org;N/A
Open yorevs github page;The user wants me to open the official github website of a specific user.;Direct: Open the URL https://github.com/yorevs;N/A
Check at flamengo.com what was the score of the Flamengo's match today;The user wants me to check the final score of today's Flamengo match utilizing today's date.;N/A;[{{1. Search google for: "Flamengo Match" final site:'flamengo.com' + score September 27, 2024}}, {{2. Identify the final score of the match if found}}]
20 changes: 20 additions & 0 deletions src/test/core/model/resources/llm-responses/task-splitter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@
@tasks:
{ "id": "1", "task": "List the contents of the downloads folder", "path": "/Users/hjunior/Downloads" }
{ "id": "2", "task": "Identify image files in the downloads folder", "path": "/Users/hjunior/Downloads" }
---
**Group 0. Chat History and Context**
The user requested to know what images are present in their downloads folder.

**Primary Goal:**
Identify and list the image files in the user's downloads folder.

**Sub-goals:**
1. List the contents of the user's downloads folder.
2. Identify image files from the list.

@thought: The user is interested in knowing the image files present in their downloads folder.
@observation: The user's query is straightforward and can be addressed by listing the contents of the downloads folder and then identifying the image files.
@conclusion: I will proceed with listing the contents of the downloads folder and then identifying the image files present.

@speak: "I will list the contents of your downloads folder and identify the image files within it."

@tasks:
1. List the contents of the user's downloads folder. Path: /Users/hjunior/Downloads
2. Identify image files from the list.

0 comments on commit 0c0149b

Please sign in to comment.