29 lines
585 B
Python
29 lines
585 B
Python
from __future__ import annotations
|
|
|
|
import subprocess
|
|
|
|
from .config import Settings
|
|
|
|
|
|
def build_cli_command(text: str, settings: Settings) -> list[str]:
|
|
return [
|
|
settings.hermes_command,
|
|
"chat",
|
|
"-q",
|
|
text,
|
|
"--source",
|
|
settings.hermes_source,
|
|
]
|
|
|
|
|
|
def ask_hermes(text: str, settings: Settings) -> str:
|
|
command = build_cli_command(text, settings)
|
|
completed = subprocess.run(
|
|
command,
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=300,
|
|
)
|
|
return completed.stdout.strip()
|