Files
llm-tools-tricu-bridge/llm_tools_tricu_bridge.py
James Eversole 720ed05912 We're working!
2025-06-04 10:17:44 -05:00

31 lines
762 B
Python

import resource
import subprocess
import time
import llm
TRICU_PATH = "/usr/local/bin/tricu"
def tricubridge(input: str) -> str:
try:
result = subprocess.run(
[TRICU_PATH, "eval", "+RTS", "-M250M", "-RTS"],
input=input,
capture_output=True,
text=True,
check=True,
)
if len(result.stdout) > 2000:
return "Output too large; limited to 2000 chars."
else:
return result.stdout.strip()
except subprocess.CalledProcessError as e:
return f"Error executing Tricu code: {e.stderr or str(e)}"
except Exception as e:
return f"Unexpected error: {str(e)}"
@llm.hookimpl
def register_tools(register):
register(tricubridge)