mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
Migrate cli utils to REST API (#239)
* Port a number of commands to use API gateway instead of Pulsar * Ported tg-invoke-agent to websockets API * Rename the 2 RAG commands: tg-query-... to tg-invoke-...
This commit is contained in:
parent
44c0d6f347
commit
44f8ce8834
10 changed files with 223 additions and 277 deletions
|
|
@ -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],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue