liagent 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.py +39 -5
- package/package.json +1 -1
package/agent.py
CHANGED
|
@@ -59,7 +59,7 @@ from rich.table import Table
|
|
|
59
59
|
from rich.text import Text
|
|
60
60
|
|
|
61
61
|
NAME = "liagent"
|
|
62
|
-
VERSION = "0.9.
|
|
62
|
+
VERSION = "0.9.2"
|
|
63
63
|
APP = "deck-agent" # config folder name — kept stable so the saved key survives renames
|
|
64
64
|
IS_WIN = sys.platform == "win32"
|
|
65
65
|
if IS_WIN:
|
|
@@ -696,6 +696,35 @@ def prompt_key(cfg, provider):
|
|
|
696
696
|
return True
|
|
697
697
|
|
|
698
698
|
|
|
699
|
+
def pick_provider(cfg, name=None):
|
|
700
|
+
"""Choose a provider (a menu, unless named), ask for its key or URL, and make it the active one.
|
|
701
|
+
Returns the provider name, or None if cancelled."""
|
|
702
|
+
names = list(PROVIDERS)
|
|
703
|
+
if name is None:
|
|
704
|
+
keys = cfg.get("keys", {})
|
|
705
|
+
cur = cfg.get("provider", "groq")
|
|
706
|
+
c = choose([f"{n:<13} {PROVIDERS[n]['about']}" + (" ✓ key" if keys.get(n) else "") for n in names],
|
|
707
|
+
title="Provider · free: groq, cerebras, gemini, mistral, coarena · offline: ollama",
|
|
708
|
+
start=names.index(cur) if cur in names else 0)
|
|
709
|
+
if c is None:
|
|
710
|
+
return None
|
|
711
|
+
name = names[c]
|
|
712
|
+
if name == "custom":
|
|
713
|
+
url = text_input("base URL (e.g. http://host:8000/v1)", default=cfg.get("base_urls", {}).get("custom", ""))
|
|
714
|
+
if not url:
|
|
715
|
+
return None
|
|
716
|
+
cfg.setdefault("base_urls", {})["custom"] = url
|
|
717
|
+
if PROVIDERS[name]["env_key"] and not prompt_key(cfg, name) and name != "custom":
|
|
718
|
+
return None
|
|
719
|
+
if name == "ollama":
|
|
720
|
+
tool_out("needs Ollama running on this machine: curl -fsSL https://ollama.com/install.sh | sh "
|
|
721
|
+
"&& ollama pull qwen2.5:3b")
|
|
722
|
+
cfg["provider"] = name
|
|
723
|
+
save_config(cfg)
|
|
724
|
+
tool_line("provider", f"{name} is active · change any time with /provider", mark="✓", style="green")
|
|
725
|
+
return name
|
|
726
|
+
|
|
727
|
+
|
|
699
728
|
# ───────────────────────────── helpers ─────────────────────────────
|
|
700
729
|
|
|
701
730
|
def clip(text, limit=MAX_TOOL_OUTPUT):
|
|
@@ -2504,7 +2533,10 @@ class Agent:
|
|
|
2504
2533
|
if self.provider not in PROVIDERS:
|
|
2505
2534
|
self.cfg["provider"] = "groq"
|
|
2506
2535
|
if not self.api_key() and self.provider != "custom":
|
|
2507
|
-
self.
|
|
2536
|
+
if not self.cfg.get("keys") and sys.stdin.isatty(): # first run: pick any provider, not just Groq
|
|
2537
|
+
pick_provider(self.cfg)
|
|
2538
|
+
else:
|
|
2539
|
+
self.ask_key()
|
|
2508
2540
|
self.client = LLM(self.base_url or "http://localhost", self.api_key() or "none")
|
|
2509
2541
|
|
|
2510
2542
|
def setup_provider(self, name=None):
|
|
@@ -5091,7 +5123,7 @@ def main():
|
|
|
5091
5123
|
args = sys.argv[1:]
|
|
5092
5124
|
if args and args[0] in ("-h", "--help"):
|
|
5093
5125
|
console.print("liagent start the chat\n"
|
|
5094
|
-
"liagent --key [name]
|
|
5126
|
+
"liagent --key [name] pick a provider (menu) or name one, and set its key\n"
|
|
5095
5127
|
"liagent --web [port] web UI for your phone (default port 8765)\n"
|
|
5096
5128
|
"liagent --discord Discord bot (first run asks for the token; 'reset' for a new one)\n"
|
|
5097
5129
|
"liagent --serve [port] web UI + Discord + devices (if set up), no chat in the terminal\n"
|
|
@@ -5100,8 +5132,10 @@ def main():
|
|
|
5100
5132
|
return
|
|
5101
5133
|
if args and args[0] == "--key":
|
|
5102
5134
|
cfg = load_config()
|
|
5103
|
-
|
|
5104
|
-
|
|
5135
|
+
if len(args) > 1 and args[1] not in PROVIDERS:
|
|
5136
|
+
console.print(f"unknown provider '{args[1]}'. Providers: {', '.join(PROVIDERS)}", markup=False)
|
|
5137
|
+
return
|
|
5138
|
+
pick_provider(cfg, args[1] if len(args) > 1 else None)
|
|
5105
5139
|
return
|
|
5106
5140
|
if args and args[0] == "--service":
|
|
5107
5141
|
install_service(args[1:])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Tiny terminal AI agent for Raspberry Pi cyberdecks: shell, files, GPIO, voice, web UI, Discord bot, calculators/LoRa/SMS. One Python file, ~240 KB.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"liagent": "bin/liagent.js"
|