Files
llm-tools-tricu-bridge/llm_tools_tricu_bridge.py
2025-06-04 10:28:57 -05:00

27 lines
711 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,
)
output = result.stdout.strip()
return output[:500] + ('...' if len(output) > 500 else '')
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)