Skip to main content

監控端點

/monitor 端點用於內部 AgentBuilder 功能,主要與在 Playground 中執行FLOW、儲存聊天歷史記錄和生成FLOW日誌相關。

此資訊主要適用於那些正在建構自訂Components或以需要呼叫或理解這些端點的方式貢獻 AgentBuilder 程式碼庫的人。

對於使用 AgentBuilder 的典型應用程式開發,有更適當的選項用於監控、除錯和記憶體管理。 有關更多資訊,請參閱以下內容:

  • 日誌:AgentBuilder 日誌儲存位置、自訂選項,以及在視覺編輯器中查看日誌的位置
  • 在 Playground 中測試FLOW:執行FLOW並檢查訊息歷史記錄
  • 記憶體管理選項:AgentBuilder 儲存位置和選項,包括資料庫、快取和聊天歷史記錄

頂點建構

頂點建構端點 (/monitor/builds) 專門用於 Playground 功能。

當您在 Playground 中執行FLOW時,AgentBuilder 會呼叫 chat.py 中的 /build/$FLOW_ID/flow 端點。此呼叫會檢索FLOW資料、建構圖形並執行圖形。當每個Components(或節點)被執行時,build_vertex 函數會呼叫 build_and_run,這可能會呼叫個別Components的 def_build 方法(如果存在)。如果Components沒有 def_build 函數,建構仍然會返回Components。

build 函數允許Components在執行時執行邏輯。例如,Recursive Character Text Splitter ComponentsLCTextSplitterComponent 類別的子類別。當需要處理文字時,會呼叫父類別的 build 方法,這會建立一個 RecursiveCharacterTextSplitter 物件並使用它根據定義的參數分割文字。分割的文字然後被傳遞到下一個Components。這一切都發生在Components被建構時。

獲取頂點建構

檢索特定FLOW的頂點建構。


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_357
{
_357
"vertex_builds": {
_357
"ChatInput-NCmix": [
_357
{
_357
"data": {
_357
"results": {
_357
"message": {
_357
"text_key": "text",
_357
"data": {
_357
"timestamp": "2024-12-23 19:10:57",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"text": "Hello",
_357
"files": [],
_357
"error": "False",
_357
"edit": "False",
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": "False",
_357
"source": {
_357
"id": "None",
_357
"display_name": "None",
_357
"source": "None"
_357
},
_357
"icon": "",
_357
"allow_markdown": "False",
_357
"positive_feedback": "None",
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": [],
_357
"id": "c95bed34-f906-4aa6-84e4-68553f6db772",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
},
_357
"default_value": "",
_357
"text": "Hello",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"files": [],
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"timestamp": "2024-12-23 19:10:57+00:00",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"error": "False",
_357
"edit": "False",
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": "False",
_357
"source": {
_357
"id": "None",
_357
"display_name": "None",
_357
"source": "None"
_357
},
_357
"icon": "",
_357
"allow_markdown": "False",
_357
"positive_feedback": "None",
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": []
_357
}
_357
},
_357
"outputs": {
_357
"message": {
_357
"message": {
_357
"timestamp": "2024-12-23T19:10:57",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"text": "Hello",
_357
"files": [],
_357
"error": false,
_357
"edit": false,
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": false,
_357
"source": {
_357
"id": null,
_357
"display_name": null,
_357
"source": null
_357
},
_357
"icon": "",
_357
"allow_markdown": false,
_357
"positive_feedback": null,
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": [],
_357
"id": "c95bed34-f906-4aa6-84e4-68553f6db772",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
},
_357
"type": "object"
_357
}
_357
},
_357
"logs": { "message": [] },
_357
"message": {
_357
"message": "Hello",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"artifacts": {
_357
"message": "Hello",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"timedelta": 0.015060124918818474,
_357
"duration": "15 ms",
_357
"used_frozen_result": false
_357
},
_357
"artifacts": {
_357
"message": "Hello",
_357
"sender": "User",
_357
"sender_name": "User",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"params": "- Files: []\n Message: Hello\n Sender: User\n Sender Name: User\n Type: object\n",
_357
"valid": true,
_357
"build_id": "40aa200e-74db-4651-b698-f80301d2b26b",
_357
"id": "ChatInput-NCmix",
_357
"timestamp": "2024-12-23T19:10:58.772766Z",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
}
_357
],
_357
"Prompt-BEn9c": [
_357
{
_357
"data": {
_357
"results": {},
_357
"outputs": {
_357
"prompt": {
_357
"message": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"type": "text"
_357
}
_357
},
_357
"logs": { "prompt": [] },
_357
"message": {
_357
"prompt": {
_357
"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"type": "text"
_357
}
_357
},
_357
"artifacts": {
_357
"prompt": {
_357
"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"type": "text"
_357
}
_357
},
_357
"timedelta": 0.0057758750626817346,
_357
"duration": "6 ms",
_357
"used_frozen_result": false
_357
},
_357
"artifacts": {
_357
"prompt": {
_357
"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",
_357
"type": "text"
_357
}
_357
},
_357
"params": "None",
_357
"valid": true,
_357
"build_id": "39bbbfde-97fd-42a5-a9ed-d42a5c5d532b",
_357
"id": "Prompt-BEn9c",
_357
"timestamp": "2024-12-23T19:10:58.781019Z",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
}
_357
],
_357
"OpenAIModel-7AjrN": [
_357
{
_357
"data": {
_357
"results": {},
_357
"outputs": {
_357
"text_output": {
_357
"message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"type": "text"
_357
},
_357
"model_output": { "message": "", "type": "unknown" }
_357
},
_357
"logs": { "text_output": [] },
_357
"message": {
_357
"text_output": {
_357
"repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"type": "text"
_357
}
_357
},
_357
"artifacts": {
_357
"text_output": {
_357
"repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"type": "text"
_357
}
_357
},
_357
"timedelta": 1.034765167045407,
_357
"duration": "1.03 seconds",
_357
"used_frozen_result": false
_357
},
_357
"artifacts": {
_357
"text_output": {
_357
"repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"type": "text"
_357
}
_357
},
_357
"params": "None",
_357
"valid": true,
_357
"build_id": "4f0ae730-a266-4d35-b89f-7b825c620a0f",
_357
"id": "OpenAIModel-7AjrN",
_357
"timestamp": "2024-12-23T19:10:58.790484Z",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
}
_357
],
_357
"ChatOutput-sfUhT": [
_357
{
_357
"data": {
_357
"results": {
_357
"message": {
_357
"text_key": "text",
_357
"data": {
_357
"timestamp": "2024-12-23 19:10:58",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"files": [],
_357
"error": "False",
_357
"edit": "False",
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": "False",
_357
"source": {
_357
"id": "OpenAIModel-7AjrN",
_357
"display_name": "OpenAI",
_357
"source": "gpt-4o-mini"
_357
},
_357
"icon": "OpenAI",
_357
"allow_markdown": "False",
_357
"positive_feedback": "None",
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": [],
_357
"id": "5688356d-9f30-40ca-9907-79a7a2fc16fd",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
},
_357
"default_value": "",
_357
"text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"files": [],
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"timestamp": "2024-12-23 19:10:58+00:00",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"error": "False",
_357
"edit": "False",
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": "False",
_357
"source": {
_357
"id": "OpenAIModel-7AjrN",
_357
"display_name": "OpenAI",
_357
"source": "gpt-4o-mini"
_357
},
_357
"icon": "OpenAI",
_357
"allow_markdown": "False",
_357
"positive_feedback": "None",
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": []
_357
}
_357
},
_357
"outputs": {
_357
"message": {
_357
"message": {
_357
"timestamp": "2024-12-23T19:10:58",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_357
"text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"files": [],
_357
"error": false,
_357
"edit": false,
_357
"properties": {
_357
"text_color": "",
_357
"background_color": "",
_357
"edited": false,
_357
"source": {
_357
"id": "OpenAIModel-7AjrN",
_357
"display_name": "OpenAI",
_357
"source": "gpt-4o-mini"
_357
},
_357
"icon": "OpenAI",
_357
"allow_markdown": false,
_357
"positive_feedback": null,
_357
"state": "complete",
_357
"targets": []
_357
},
_357
"category": "message",
_357
"content_blocks": [],
_357
"id": "5688356d-9f30-40ca-9907-79a7a2fc16fd",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
},
_357
"type": "object"
_357
}
_357
},
_357
"logs": { "message": [] },
_357
"message": {
_357
"message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"artifacts": {
_357
"message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"timedelta": 0.017838125000707805,
_357
"duration": "18 ms",
_357
"used_frozen_result": false
_357
},
_357
"artifacts": {
_357
"message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!",
_357
"sender": "Machine",
_357
"sender_name": "AI",
_357
"files": [],
_357
"type": "object"
_357
},
_357
"params": "- Files: []\n Message: Hello! 🌟 I'm excited to help you get started on your journey to building\n something fresh! What do you have in mind? Whether it's a project, an idea, or\n a concept, let's dive in and make it happen!\n Sender: Machine\n Sender Name: AI\n Type: object\n",
_357
"valid": true,
_357
"build_id": "1e8b908b-aba7-403b-9e9b-eca92bb78668",
_357
"id": "ChatOutput-sfUhT",
_357
"timestamp": "2024-12-23T19:10:58.813268Z",
_357
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_357
}
_357
]
_357
}
_357
}

刪除頂點建構

刪除特定FLOW的頂點建構。


_10
curl -X DELETE \
_10
"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \
_10
-H "accept: */*" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_10
204 No Content

訊息端點

/monitor/messages 端點在 langflow.db 的訊息表中儲存、檢索、編輯和刪除記錄。 通常,當運行產生訊息歷史的FLOW時,或檢查和修改 Playground 記憶體時,會隱式調用這些端點。

獲取訊息

檢索所有訊息的列表:


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/monitor/messages" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

要過濾訊息,請使用 flow_idsession_idsendersender_name 查詢參數。

要排序結果,請使用 order_by 查詢參數。

此示例檢索給定聊天會話 (session_id) 中由 MachineAI 發送的訊息,並按時間戳排序訊息。


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/monitor/messages?flow_id=$FLOW_ID&session_id=01ce083d-748b-4b8d-97b6-33adbb6a528a&sender=Machine&sender_name=AI&order_by=timestamp" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_30
[
_30
{
_30
"id": "1c1d6134-9b8b-4079-931c-84dcaddf19ba",
_30
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_30
"timestamp": "2024-12-23 19:20:11 UTC",
_30
"sender": "Machine",
_30
"sender_name": "AI",
_30
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_30
"text": "Hello! It's great to see you here! What exciting project or idea are you thinking about diving into today? Whether it's something fresh and innovative or a classic concept with a twist, I'm here to help you get started! Let's brainstorm together!",
_30
"files": "[]",
_30
"edit": false,
_30
"properties": {
_30
"text_color": "",
_30
"background_color": "",
_30
"edited": false,
_30
"source": {
_30
"id": "OpenAIModel-7AjrN",
_30
"display_name": "OpenAI",
_30
"source": "gpt-4o-mini"
_30
},
_30
"icon": "OpenAI",
_30
"allow_markdown": false,
_30
"positive_feedback": null,
_30
"state": "complete",
_30
"targets": []
_30
},
_30
"category": "message",
_30
"content_blocks": []
_30
}
_30
]

刪除訊息

按其 ID 刪除特定訊息。

此示例刪除上一個 GET /messages 示例中檢索到的訊息。


_10
curl -v -X DELETE \
_10
"$LANGFLOW_URL/api/v1/monitor/messages" \
_10
-H "accept: */*" \
_10
-H "Content-Type: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '["MESSAGE_ID_1", "MESSAGE_ID_2"]'

Result

_10
204 No Content

更新訊息

按其 ID 更新特定訊息。

此示例更新訊息 3ab66cc6-c048-48f8-ab07-570f5af7b160text 值。


_10
curl -X PUT \
_10
"$LANGFLOW_URL/api/v1/monitor/messages/3ab66cc6-c048-48f8-ab07-570f5af7b160" \
_10
-H "accept: application/json" \
_10
-H "Content-Type: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{
_10
"text": "testing 1234"
_10
}'

Result

_25
{
_25
"timestamp": "2024-12-23T18:49:06",
_25
"sender": "string",
_25
"sender_name": "string",
_25
"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_25
"text": "testing 1234",
_25
"files": ["string"],
_25
"error": true,
_25
"edit": true,
_25
"properties": {
_25
"text_color": "string",
_25
"background_color": "string",
_25
"edited": false,
_25
"source": { "id": "string", "display_name": "string", "source": "string" },
_25
"icon": "string",
_25
"allow_markdown": false,
_25
"positive_feedback": true,
_25
"state": "complete",
_25
"targets": []
_25
},
_25
"category": "message",
_25
"content_blocks": [],
_25
"id": "3ab66cc6-c048-48f8-ab07-570f5af7b160",
_25
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"
_25
}

更新會話 ID

更新訊息的會話 ID。

此示例將 session_ID01ce083d-748b-4b8d-97b6-33adbb6a528a 更新為 different_session_id


_10
curl -X PATCH \
_10
"$LANGFLOW_URL/api/v1/monitor/messages/session/01ce083d-748b-4b8d-97b6-33adbb6a528a?new_session_id=different_session_id" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_30
[
_30
{
_30
"id": "8dd7f064-e63a-4773-b472-ca0475249dfd",
_30
"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
_30
"timestamp": "2024-12-23 18:49:55 UTC",
_30
"sender": "User",
_30
"sender_name": "User",
_30
"session_id": "different_session_id",
_30
"text": "message",
_30
"files": "[]",
_30
"edit": false,
_30
"properties": {
_30
"text_color": "",
_30
"background_color": "",
_30
"edited": false,
_30
"source": {
_30
"id": null,
_30
"display_name": null,
_30
"source": null
_30
},
_30
"icon": "",
_30
"allow_markdown": false,
_30
"positive_feedback": null,
_30
"state": "complete",
_30
"targets": []
_30
},
_30
"category": "message",
_30
"content_blocks": []
_30
}
_30
]

按會話刪除訊息

刪除特定會話的所有訊息。


_10
curl -X DELETE \
_10
"$LANGFLOW_URL/api/v1/monitor/messages/session/different_session_id_2" \
_10
-H "accept: */*" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_10
HTTP/1.1 204 No Content

獲取交易

檢索特定FLOW的所有交易,即Components之間的互動。 此資訊也可在 FLOW日誌 中獲得。


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/monitor/transactions?flow_id=$FLOW_ID&page=1&size=50" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_19
{
_19
"items": [
_19
{
_19
"timestamp": "2024-12-23T20:05:01.061Z",
_19
"vertex_id": "string",
_19
"target_id": "string",
_19
"inputs": {},
_19
"outputs": {},
_19
"status": "string",
_19
"error": "string",
_19
"flow_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_19
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
_19
}
_19
],
_19
"total": 0,
_19
"page": 1,
_19
"size": 1,
_19
"pages": 0
_19
}

另請參閱

Search