added Perl port, updated readme
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# Bantam agent, tiny, powerful, DIY. Public domain. Created by Luxferre in 2026.
|
||||
# Bantam agent: tiny, powerful, DIY
|
||||
# Created by Luxferre in 2026, released into the public domain
|
||||
|
||||
import sys, os, json, time, subprocess, urllib.request
|
||||
try: import readline
|
||||
@@ -25,7 +26,7 @@ def col(cfg):
|
||||
except Exception: return False
|
||||
|
||||
def get_cfg(path="model.cfg"):
|
||||
d = {"endpoint": "https://opencode.ai/zen/v1", "model": "big-pickle", "temperature": "0.7", "api_key": "-", "timeout": "60", "shell_timeout": "120", "max_al_iterations": "1000", "stream": "true", "color": "auto"}
|
||||
d = {"endpoint": "https://opencode.ai/zen/v1", "model": "big-pickle", "temperature": "0.7", "api_key": "-", "timeout": "300", "shell_timeout": "120", "max_al_iterations": "1000", "stream": "true", "color": "auto"}
|
||||
if os.path.exists(path):
|
||||
for ln in open(path, encoding="utf-8"):
|
||||
ln = ln.strip()
|
||||
@@ -86,7 +87,7 @@ def llm(cfg, msgs, tools):
|
||||
if _COL: sys.stdout.write("\r" + pend); sys.stdout.flush()
|
||||
else: sys.stdout.write(pend + "\n"); sys.stdout.flush()
|
||||
req = urllib.request.Request(url, data=json.dumps(p).encode(), headers=h, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=num(cfg, "timeout", 60)) as r:
|
||||
with urllib.request.urlopen(req, timeout=num(cfg, "timeout", 300)) as r:
|
||||
if not st:
|
||||
msg = json.loads(r.read().decode())["choices"][0]["message"]
|
||||
if _COL: sys.stdout.write("\r\033[K"); sys.stdout.flush()
|
||||
@@ -259,6 +260,7 @@ def main():
|
||||
except OSError: pass
|
||||
sys.exit(0)
|
||||
print(c("Bantam Agent ready", 1, 32) + c(" (Ctrl+J = new line)", 2))
|
||||
print(c(f"endpoint: {cfg['endpoint']} model: {cfg['model']} temp: {cfg.get('temperature', '0.7')}", 2))
|
||||
while True:
|
||||
try: u = input(cp("> ", 1, 36)).strip()
|
||||
except (EOFError, KeyboardInterrupt): print(); break
|
||||
|
||||
Reference in New Issue
Block a user