Skip to content

Commit

Permalink
Update textual. Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yorevs committed Jan 9, 2025
1 parent cf8f80b commit 0911862
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 80 deletions.
4 changes: 2 additions & 2 deletions dependencies.hspd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/* HSPyLib projects */
package: hspylib, version: 1.12.53, mode: ge
package: hspylib-datasource, version: 0.9.82, mode: ge
package: hspylib-clitt, version: 0.9.140, mode: ge
package: hspylib-clitt, version: 0.9.141, mode: ge
package: hspylib-setman, version: 0.10.43, mode: ge

/* General */
Expand Down Expand Up @@ -46,7 +46,7 @@ package: html2text, version: 2024.2.26, mode: eq

/* CLI/TUI */
package: rich, version: 13.9.4, mode: eq
package: textual, version: 0.89.1, mode: eq
package: textual, version: 1.0.0, mode: eq

/* Audio */
package: soundfile, version: 0.12.1, mode: eq
Expand Down
18 changes: 7 additions & 11 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ ext {
reqsFile = "$project.projectDir/src/main/requirements.txt"
os = OperatingSystem.current().getName()
python = detectPython()
space = detectSpace() // the user space to install packages
pyrcc = 'pyrcc5'
deps = [] // List of project dependencies
apps = [] // List of project applications
}

/* Version compatibility mode map */
Expand All @@ -54,18 +57,17 @@ def modesMap = [

/* Detect the package space to install dependencies. */
String detectSpace() {

def output = new ByteArrayOutputStream()
exec {
commandLine 'sh', '-c', "${project.ext.python} -c \"from sys import prefix, base_prefix; print(prefix != base_prefix);\""
project.exec {
commandLine project.ext.python, '-c', "from sys import prefix, base_prefix; print(prefix != base_prefix)"
standardOutput = output
}
def is_venv = Boolean.parseBoolean(output.toString())
def is_venv = Boolean.parseBoolean(output.toString().trim())
println("> Build is" + (is_venv ? ' ' : ' NOT ') + "running under a virtual environment (venv).")

return is_venv ? '--global' : '--user'
}


/* Read .hspd files using the defined HSPD syntax. Added \[\] as valid package names. */
void readDependencies() {
def depsFile = new File(depsFile)
Expand Down Expand Up @@ -115,12 +117,6 @@ void readDependencies() {
}
}

ext {
deps = [] // List of project dependencies
apps = [] // List of project applications
space = detectSpace() // the user space to install packages
}

/* Tasks ------------------------------------------------------------------- */

/* List project dependencies */
Expand Down
9 changes: 6 additions & 3 deletions gradle/pypi-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ String dirName(File file) {
/* Cleanup distribution files from buildDir */
task cleanDist(type: Task) {
group = 'Build'
description = "Cleanup distribution files from buildDir"
description = "Cleanup distribution files from buildDir and sourceRoot"
doLast {
println("Cleanup distribution files \n\t from ${buildDir}")
println("Cleanup distribution files from buildDir and sourceRoot")
delete dirsByPattern("$buildDir", /.*dist$/)
delete dirsByPattern("$buildDir", /.*build$/)
delete dirsByPattern("$buildDir", /.*egg-info$/)
delete dirsByPattern("$buildDir", /.*\.egg-info$/)
delete dirsByPattern("$sourceRoot", /.*dist$/)
delete dirsByPattern("$sourceRoot", /.*build$/)
delete dirsByPattern("$sourceRoot", /.*\.egg-info$/)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/camera_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if __name__ == "__main__":
init_context("camera-demo")
photo: ImageMetadata
while opt := line_input(MENU, placeholder="Select an option"):
while opt := line_input(MENU, placeholder="Select an option", markdown=True):
cursor.writeln()
if opt == "1" and (name := strip_escapes(line_input("Photo name: "))):
pic_file, pic_data = camera.capture(name)
Expand Down
4 changes: 3 additions & 1 deletion src/main/askai/core/model/action_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ def _parse_response(question: str, response: str) -> "ActionPlan":

# fmt: off
if direct and len(direct) > 1:
plan = ActionPlan._direct_answer(question, direct, primary_goal, ModelResult.default())
plan = ActionPlan._direct_answer(question, direct, primary_goal, ModelResult.final_answer())
elif (direct and len(direct) > 1) or len(tasks) == 1:
plan = ActionPlan._direct_task(question, speak, primary_goal, tasks[0], ModelResult.default())
elif tasks:
plan = ActionPlan(question, speak, primary_goal, False, sub_goals, tasks)
elif not speak and not primary_goal:
plan = ActionPlan._direct_task(question, "", "", response, ModelResult.default())
elif speak and primary_goal:
plan = ActionPlan._direct_answer(question, speak, primary_goal, ModelResult.final_answer())
else:
raise InaccurateResponse("AI provided an invalid action plan!")
# fmt: on
Expand Down
22 changes: 17 additions & 5 deletions src/main/askai/core/model/model_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
from dataclasses import dataclass
from functools import lru_cache

from askai.core.enums.response_model import ResponseModel


@dataclass
class ModelResult:
"""Keep track of the model select responses."""
"""Track and store the responses from the selected model. This class is used to encapsulate the model selection
returned by the LLM, including any relevant data associated with the model's response."""

mid: str = None
goal: str = None
Expand All @@ -27,12 +30,21 @@ class ModelResult:
@staticmethod
@lru_cache
def default() -> "ModelResult":
"""Track and store the responses from the selected model.
This class is used to encapsulate the model selection returned by the LLM, including any relevant data
associated with the model's response.
"""Creates and returns the default ModelResult instance.
:return: A default ModelResult instance with predefined values.
"""
return ModelResult(
ResponseModel.NEUTRAL.model, "Default model", "Provide the answer as received by the AI"
)

@staticmethod
@lru_cache
def final_answer() -> "ModelResult":
"""Generates and returns the final answer model result.
:return: An instance of ModelResult representing the final answer model.
"""
return ModelResult(
"ASK_000", "Default model", "Provide the answer as received by the AI"
ResponseModel.FINAL_ANSWER.model, "Final Answer model", "Provide the answer as received by the AI"
)

def __str__(self):
Expand Down
14 changes: 7 additions & 7 deletions src/main/askai/core/processors/splitter/splitter_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def interrupt(self, ev: Event) -> None:
def run(self) -> None:
"""Execute the splitter pipeline."""

try:
with Live(
Spinner("dots", f"[green]{self.pipeline.state}…[/green]", style="green"), console=tf.console
) as live:
with Live(
Spinner("dots", f"[green]{self.pipeline.state}…[/green]", style="green"), console=tf.console
) as live:
try:
while not (self._interrupted or self.pipeline.state == States.COMPLETE):
self.pipeline.track_previous()
if 1 < configs.max_router_retries < 1 + self.pipeline.failures[self.pipeline.state.value]:
Expand Down Expand Up @@ -126,9 +126,9 @@ def run(self) -> None:
self.display(f"[green]{execution_status_str}[/green]")
live.update(Spinner("dots", f"[green]{self.pipeline.state}…[/green]", style="green"))
self.pipeline.iteractions += 1
cursor.erase_line()
except InaccurateResponse:
live.update(Spinner("dots", f"[red]AI failed to respond. Retrying…[/red]", style="green"))
cursor.erase_line()
except InaccurateResponse:
live.update(Spinner("dots", f"[red]AI failed to respond. Retrying…[/red]", style="green"))

final_state: States = self.pipeline.state

Expand Down
50 changes: 0 additions & 50 deletions src/main/requirements.txt

This file was deleted.

0 comments on commit 0911862

Please sign in to comment.