refactor: tighten backend, flows, frontend, tests; push flows to Langflow
This commit is contained in:
parent
6688fb08c6
commit
06ab25fb47
31 changed files with 783 additions and 358 deletions
|
|
@ -10,21 +10,20 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
def post(api: str, path: str, body: dict) -> dict:
|
||||
request = urllib.request.Request(
|
||||
api.rstrip("/") + path,
|
||||
data=json.dumps(body).encode(),
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="POST",
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(request) as response:
|
||||
return {"status": response.status, "body": json.loads(response.read())}
|
||||
except urllib.error.HTTPError as exc:
|
||||
return {"status": exc.code, "body": exc.read().decode()[:2000]}
|
||||
response = httpx.post(api.rstrip("/") + path, json=body, timeout=60.0)
|
||||
try:
|
||||
payload = response.json()
|
||||
except ValueError:
|
||||
payload = response.text[:2000]
|
||||
return {"status": response.status_code, "body": payload}
|
||||
except httpx.HTTPError as exc:
|
||||
return {"status": 0, "body": str(exc)[:2000]}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue