salior/plugins/llm_batcher/run.py

25 lines
729 B
Python

"""LLM batcher plugin — aggregate multiple LLM calls into one request."""
import sys
import yaml
import json
def main() -> None:
"""Entry point: read method name from args, dispatch."""
if len(sys.argv) < 2:
print(yaml.dump({"error": "no method specified"}))
return
method = sys.argv[1]
params = yaml.safe_load(sys.stdin.read()) if not sys.stdin.isatty() else {}
if method == "batch":
calls = params.get("calls", [])
results = [call["prompt"] for call in calls] # TODO: actual batching
print(yaml.dump({"results": results, "count": len(results)}))
else:
print(yaml.dump({"error": f"unknown method: {method}"}))
if __name__ == "__main__":
main()