feat: form-input library with schema parsing and endpoint
This commit is contained in:
parent
80d81b8022
commit
46ecab00db
13 changed files with 2775 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ from app.settings import settings
|
|||
from app.auth.deps import get_optional_user, resolve_tenant
|
||||
|
||||
from . import runner, store
|
||||
from . import input_schema as form_schema
|
||||
from .deploy import import_from_langflow
|
||||
from .sync import lfx_id_for, sync_from_directory
|
||||
from .langflow_client import (
|
||||
|
|
@ -46,6 +47,7 @@ from .schemas import (
|
|||
FlowImportRequest,
|
||||
FlowVersionCreate,
|
||||
FlowVersionRead,
|
||||
InputSchemaRead,
|
||||
RunRead,
|
||||
RunRequest,
|
||||
SyncReport,
|
||||
|
|
@ -91,6 +93,7 @@ def _read_version(v) -> FlowVersionRead:
|
|||
deployed_at=v.deployed_at,
|
||||
author=v.author,
|
||||
created_at=v.created_at,
|
||||
input_schema=v.input_schema,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -386,6 +389,28 @@ async def import_flow(
|
|||
)
|
||||
|
||||
|
||||
@flows_router.get("/{flow_id}/input-schema", response_model=InputSchemaRead)
|
||||
def get_input_schema(
|
||||
flow_id: UUID,
|
||||
session: Session = Depends(get_db),
|
||||
):
|
||||
"""Form schema of the latest deployed version (404 when none)."""
|
||||
try:
|
||||
version = store.get_latest_deployed_version(session, flow_id)
|
||||
except (store.NotFoundError, store.InvalidError) as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
cached = version.input_schema or form_schema.extract_form_schema(
|
||||
version.langflow_json
|
||||
)
|
||||
return InputSchemaRead(
|
||||
flow_id=flow_id,
|
||||
version_no=version.version_no,
|
||||
json_schema=cached.get("json_schema", {}),
|
||||
ui_schema=cached.get("ui_schema", {}),
|
||||
fallback=cached.get("fallback"),
|
||||
)
|
||||
|
||||
|
||||
@flows_router.get("/runs/{run_id}", response_model=RunRead)
|
||||
def get_run(
|
||||
run_id: UUID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue