trustgraph/test-api/test-llm-api
cybermaggedon fd3db3c925
Feature/tidy kg load save (#198)
* Clean exit on ctrl-C
* More functionality in dump
* Dump some metadata
2024-12-06 15:16:09 +00:00

34 lines
788 B
Python
Executable file

#!/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,
)
if resp.status_code != 200:
raise RuntimeError(f"Status code: {resp.status_code}")
resp = resp.json()
if "error" in resp:
print(f"Error: {resp['error']}")
sys.exit(1)
print(resp["response"])
############################################################################