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
40
backend/scripts/push_flows_to_langflow.py
Normal file
40
backend/scripts/push_flows_to_langflow.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"""Push canonical backend/flows/*.json into Langflow via API (no restart)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from app.flows.langflow_client import LangflowClient, LangflowError
|
||||
from app.settings import settings
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
base = os.environ.get("LANGFLOW_URL", "http://localhost:7860")
|
||||
key = settings.langflow_api_key or os.environ.get("LANGFLOW_API_KEY", "")
|
||||
print(f"Langflow: {base} key_len={len(key)}")
|
||||
client = LangflowClient(base, api_key=key)
|
||||
try:
|
||||
flows = await client.list_flows()
|
||||
print(f"existing: {len(flows)} flows")
|
||||
for f in flows[:20]:
|
||||
print(" -", f.get("name"), f.get("id"))
|
||||
except LangflowError as exc:
|
||||
print(f"list failed: {exc}")
|
||||
return
|
||||
flows_dir = Path(settings.flows_dir)
|
||||
for path in sorted(flows_dir.glob("*.json")):
|
||||
if path.name.startswith("."):
|
||||
continue
|
||||
doc = json.loads(path.read_text(encoding="utf-8"))
|
||||
try:
|
||||
result = await client.upsert_flow(doc)
|
||||
print(f"pushed {path.name} id={result.get('id', 'ok')}")
|
||||
except LangflowError as exc:
|
||||
print(f"push {path.name} failed: {exc}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue