
代理协议是我们尝试规范化用于在生产环境中服务 LLM 代理的框架无关 API。本文档解释了该协议的目的,并阐述了每个端点的必要性。最后,我们列出了未来的一些发展路线。
请参阅完整的 OpenAPI 文档这里[1],以及 JSON 规范这里[2]。
LangGraph 平台[3] 实现了该协议的超集,但我们非常欢迎社区中的其他实现。
如何为 LLM 应用程序在生产环境中提供正确的 API?我们认为,这个 API 围绕三个重要概念展开:
让我们深入探讨每个概念,首先是需求,然后展示符合这些需求的协议端点。
我们需要什么样的 API 来执行一个代理?
基础端点:
便捷端点:
支持多轮交互需要哪些 API?
端点:
代理的记忆 API 需要提供哪些功能?
端点:
POST /threads/{thread_id}/runs/{run_id}/stream 添加一个参数,以便在流式传输新事件之前重放自event-id 以来的事件POST /threads/{thread_id}/runs 添加一个参数,以可选地允许在同一线程上并发运行(当前规格禁止此操作)关注我,与你一起探索 AI 最前沿的技术洞见!您的评论与分享是我创作的动力。
[1]
这里:https://langchain-ai.github.io/agent-protocol/api.html
[2]
这里:https://langchain-ai.github.io/agent-protocol/openapi.json
[3]
LangGraph平台:https://www.langchain.com/pricing-langgraph-platform
[4]
GET /threads/{thread_id}/runs:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/GET/threads/{thread_id}/runs
[5]
POST /threads/{thread_id}/runs:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/POST/threads/{thread_id}/runs
[6]
GET /threads/{thread_id}/runs/{run_id}:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/GET/threads/{thread_id}/runs/{run_id}
[7]
POST /threads/{thread_id}/runs/{run_id}/cancel:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/POST/threads/{thread_id}/runs/{run_id}/cancel
[8]
DELETE /threads/{thread_id}/runs/{run_id}:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/DELETE/threads/{thread_id}/runs/{run_id}
[9]
GET /threads/{thread_id}/runs/{run_id}/wait:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/GET/threads/{thread_id}/runs/{run_id}/wait
[10]
GET /threads/{thread_id}/runs/{run_id}/stream:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/GET/threads/{thread_id}/runs/{run_id}/stream
[11]
POST /threads/{thread_id}/runs/wait:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/POST/threads/{thread_id}/runs/wait
[12]
POST /threads/{thread_id}/runs/stream:https://langchain-ai.github.io/agent-protocol/api.html#tag/runs/POST/threads/{thread_id}/runs/stream
[13]
POST /threads:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/POST/threads
[14]
POST /threads/search:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/POST/threads/search
[15]
GET /threads/{thread_id}:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/GET/threads/{thread_id}
[16]
GET /threads/{thread_id}/state:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/GET/threads/{thread_id}/state
[17]
POST /threads/{thread_id}/state:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/POST/threads/{thread_id}/state
[18]
GET /threads/{thread_id}/history:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/GET/threads/{thread_id}/history
[19]
POST /threads/{thread_id}/copy:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/POST/threads/{thread_id}/copy
[20]
DELETE /threads/{thread_id}:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/DELETE/threads/{thread_id}
[21]
PATCH /threads/{thread_id}:https://langchain-ai.github.io/agent-protocol/api.html#tag/threads/PATCH/threads/{thread_id}
[22]
PUT /store/items:https://langchain-ai.github.io/agent-protocol/api.html#tag/store/PUT/store/items
[23]
DELETE /store/items:https://langchain-ai.github.io/agent-protocol/api.html#tag/store/DELETE/store/items
[24]
GET /store/items:https://langchain-ai.github.io/agent-protocol/api.html#tag/store/GET/store/items
[25]
POST /store/items/search:https://langchain-ai.github.io/agent-protocol/api.html#tag/store/POST/store/items/search
[26]
POST /store/namespaces:https://langchain-ai.github.io/agent-protocol/api.html#tag/store/POST/store/namespaces