建構端點
info
/build 端點由 AgentBuilder 的前端視覺編輯器程式碼使用。
這些端點是 AgentBuilder 內部程式碼庫的一部分。
不要使用這些端點在應用程式中執行 Flow,這些應用程式使用您的 AgentBuilder Flow。 要在您的應用程式中執行 Flow,請參閱 Flow觸發端點。
/build 端點支援 AgentBuilder 前端程式碼在 AgentBuilder 視覺編輯器中建構 Flow。
您可以使用這些端點建構頂點和 Flow,以及執行具有串流事件回應的 Flow。
當貢獻 AgentBuilder 程式碼庫時,您可能需要使用或理解這些端點。
建構 Flow並串流事件
此端點建構並執行 Flow,返回一個工作 ID,可用於串流執行事件。
-
發送 POST 請求到
/build/$FLOW_ID/flow端點:_10curl -X POST \_10"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY" \_10-d '{_10"inputs": {_10"input_value": "Tell me a story"_10}_10}'Result
_10{_10"job_id": "123e4567-e89b-12d3-a456-426614174000"_10} -
在從建構端點接收工作 ID 後,使用
/build/$JOB_ID/events端點來串流執行結果:_10curl -X GET \_10"$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY"Result
_10{"event": "vertices_sorted", "data": {"ids": ["ChatInput-XtBLx"], "to_run": ["Prompt-x74Ze", "ChatOutput-ylMzN", "ChatInput-XtBLx", "OpenAIModel-d1wOZ"]}}_10_10{"event": "add_message", "data": {"timestamp": "2025-03-03T17:42:23", "sender": "User", "sender_name": "User", "session_id": "d2bbd92b-187e-4c84-b2d4-5df365704201", "text": "Tell me a story", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": null, "display_name": null, "source": null}, "icon": "", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "28879bd8-6a68-4dd5-b658-74d643a4dd92", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}_10_10// ... Additional events as the flow executes ..._10_10{"event": "end", "data": {}}
/build/$FLOW_ID/events 端點有一個 stream 查詢參數,預設為 true。
要停用串流並一次獲取所有事件,請設定 ?stream=false。
_10curl -X GET \_10 "$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events?stream=false" \_10 -H "accept: application/json" \_10 -H "x-api-key: $LANGFLOW_API_KEY"