🔧 chore(chat.py): update init_build endpoint to include flow_id as a path parameter
The unnecessary imports have been removed from the chat.py file to improve code cleanliness and readability. The init_build endpoint in the chat.py file has been updated to include the flow_id as a path parameter instead of extracting it from the graph_data dictionary. This change allows for a more explicit and consistent API design.
🔧 chore(chat.py): remove unnecessary imports and reformat code for better readability
This commit is contained in:
parent
48d40bfdd3
commit
85b7ff1d31
2 changed files with 8 additions and 12 deletions
|
|
@ -1,10 +1,4 @@
|
||||||
from fastapi import (
|
from fastapi import APIRouter, HTTPException, WebSocket, WebSocketException, status
|
||||||
APIRouter,
|
|
||||||
HTTPException,
|
|
||||||
WebSocket,
|
|
||||||
WebSocketException,
|
|
||||||
status,
|
|
||||||
)
|
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from langflow.api.v1.schemas import BuildStatus, BuiltResponse, InitResponse, StreamData
|
from langflow.api.v1.schemas import BuildStatus, BuiltResponse, InitResponse, StreamData
|
||||||
|
|
||||||
|
|
@ -32,16 +26,18 @@ async def chat(client_id: str, websocket: WebSocket):
|
||||||
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
||||||
|
|
||||||
|
|
||||||
@router.post("/build/init", response_model=InitResponse, status_code=201)
|
@router.post("/build/init/{flow_id}", response_model=InitResponse, status_code=201)
|
||||||
async def init_build(graph_data: dict):
|
async def init_build(graph_data: dict, flow_id: str):
|
||||||
"""Initialize the build by storing graph data and returning a unique session ID."""
|
"""Initialize the build by storing graph data and returning a unique session ID."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flow_id = graph_data.get("id")
|
|
||||||
if flow_id is None:
|
if flow_id is None:
|
||||||
raise ValueError("No ID provided")
|
raise ValueError("No ID provided")
|
||||||
# Check if already building
|
# Check if already building
|
||||||
if flow_id in flow_data_store and flow_data_store[flow_id].get("building"):
|
if (
|
||||||
|
flow_id in flow_data_store
|
||||||
|
and flow_data_store[flow_id]["status"] == BuildStatus.IN_PROGRESS
|
||||||
|
):
|
||||||
return InitResponse(flowId=flow_id)
|
return InitResponse(flowId=flow_id)
|
||||||
|
|
||||||
# Delete from cache if already exists
|
# Delete from cache if already exists
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,7 @@ export async function getBuildStatus(
|
||||||
export async function postBuildInit(
|
export async function postBuildInit(
|
||||||
flow: FlowType
|
flow: FlowType
|
||||||
): Promise<AxiosResponse<InitTypeAPI>> {
|
): Promise<AxiosResponse<InitTypeAPI>> {
|
||||||
return await axios.post(`/api/v1/build/init`, flow);
|
return await axios.post(`/api/v1/build/init/${flow.id}`, flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch(`/upload/${id}`, {
|
// fetch(`/upload/${id}`, {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue