mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 16:36:21 +02:00
API-side support for Wikipedia, DBpedia and internet search functions This incorporates a refactor of the API code to break it up, separate classes for endpoints to reduce duplication
37 lines
633 B
Python
Executable file
37 lines
633 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import requests
|
|
import json
|
|
import sys
|
|
|
|
url = "http://localhost:8088/api/v1/"
|
|
|
|
############################################################################
|
|
|
|
input = {
|
|
"id": "question",
|
|
"variables": {
|
|
"question": "Write a joke about llamas."
|
|
}
|
|
}
|
|
|
|
resp = requests.post(
|
|
f"{url}prompt",
|
|
json=input,
|
|
)
|
|
|
|
resp = resp.json()
|
|
|
|
if "error" in resp:
|
|
print(f"Error: {resp['error']}")
|
|
sys.exit(1)
|
|
|
|
if "object" in resp:
|
|
print(f"Object: {resp['object']}")
|
|
sys.exit(1)
|
|
|
|
print(resp["text"])
|
|
|
|
sys.exit(0)
|
|
############################################################################
|
|
|