mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 03:31:02 +02:00
Put API tests in a subdir
This commit is contained in:
parent
1c4ec3d361
commit
30dc2a66b8
8 changed files with 0 additions and 68 deletions
38
test-api/test-prompt-api
Executable file
38
test-api/test-prompt-api
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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()
|
||||
|
||||
print(resp)
|
||||
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)
|
||||
############################################################################
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue