mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 03:31:02 +02:00
Bare bones API gateway
This commit is contained in:
parent
f2c78b701e
commit
a8e37037d2
3 changed files with 265 additions and 0 deletions
57
test-api
Executable file
57
test-api
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
url = "http://localhost:8088/api/v1/"
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"system": "Respond in French. Use long word, form of numbers, no digits",
|
||||
# "prompt": "Add 2 and 12"
|
||||
"prompt": "Add 12 and 14, and then make a poem about llamas which incorporates that number. Then write a joke about llamas"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}text-completion",
|
||||
json=input,
|
||||
)
|
||||
|
||||
print(resp.json()["response"])
|
||||
sys.exit(0)
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"id": "question",
|
||||
"variables": {
|
||||
"question": "Add 12 and 14, and then make a poem about llamas which incorporates that number. Then write a joke about llamas."
|
||||
}
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}prompt",
|
||||
json=input,
|
||||
)
|
||||
|
||||
print(resp.json()["text"])
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"id": "extract-definitions",
|
||||
"variables": {
|
||||
"text": "A cat is a large mammal."
|
||||
}
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}prompt",
|
||||
json=input,
|
||||
)
|
||||
|
||||
print(json.dumps(resp.json()["object"], indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue