2024-11-20 19:55:40 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
import json
|
|
|
|
|
import sys
|
|
|
|
|
|
2025-04-29 23:34:41 +01:00
|
|
|
url = "http://localhost:8088/api/v1/flow/0000/prompt"
|
2024-11-20 19:55:40 +00:00
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
|
|
input = {
|
|
|
|
|
"id": "question",
|
|
|
|
|
"variables": {
|
|
|
|
|
"question": "Write a joke about llamas."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resp = requests.post(
|
2025-04-29 23:34:41 +01:00
|
|
|
url,
|
2024-11-20 19:55:40 +00:00
|
|
|
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)
|
|
|
|
|
############################################################################
|
|
|
|
|
|