Files
chainlit--chainlit/backend/chainlit/langflow/__init__.py
T
wehub-resource-sync b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:48:47 +08:00

26 lines
740 B
Python

from chainlit.utils import check_module_version
if not check_module_version("langflow", "0.1.4"):
raise ValueError(
"Expected Langflow version >= 0.1.4. Run `pip install langflow --upgrade`"
)
from typing import Dict, Optional, Union
import httpx
async def load_flow(schema: Union[Dict, str], tweaks: Optional[Dict] = None):
from langflow import load_flow_from_json
if isinstance(schema, str):
async with httpx.AsyncClient() as client:
response = await client.get(schema)
if response.status_code != 200:
raise ValueError(f"Error: {response.text}")
schema = response.json()
flow = load_flow_from_json(flow=schema, tweaks=tweaks)
return flow