Port a number of commands to use API gateway instead of Pulsar

This commit is contained in:
Cyber MacGeddon 2025-01-02 17:17:38 +00:00
parent 44c0d6f347
commit cb2e8a3724
6 changed files with 112 additions and 81 deletions

View file

@ -8,15 +8,15 @@ and user prompt. Both arguments are required.
import argparse
import os
import json
from trustgraph.clients.llm_client import LlmClient
from trustgraph.api import Api
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def query(pulsar_host, system, prompt):
def query(url, system, prompt):
cli = LlmClient(pulsar_host=pulsar_host)
api = Api(url)
resp = cli.request(system=system, prompt=prompt)
resp = api.text_completion(system=system, prompt=prompt)
print(resp)
@ -28,9 +28,9 @@ def main():
)
parser.add_argument(
'-p', '--pulsar-host',
default=default_pulsar_host,
help=f'Pulsar host (default: {default_pulsar_host})',
'-u', '--url',
default=default_url,
help=f'API URL (default: {default_url})',
)
parser.add_argument(
@ -50,7 +50,7 @@ def main():
try:
query(
pulsar_host=args.pulsar_host,
url=args.url,
system=args.system[0],
prompt=args.prompt[0],
)