self-host langgraph
This commit is contained in:
@@ -16,5 +16,4 @@ dependencies = [
|
||||
"docstring-parser>=0.17.0",
|
||||
"jsonschema>=4.25.1",
|
||||
"copilotkit>=0.1.0",
|
||||
"ag-ui-langgraph>=0.0.4",
|
||||
]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Self-hosted LangGraph agent server using CopilotKit's AG-UI protocol.
|
||||
Self-hosted LangGraph agent server using CopilotKit.
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -7,23 +7,36 @@ from fastapi import FastAPI
|
||||
import uvicorn
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from copilotkit import LangGraphAGUIAgent
|
||||
from ag_ui_langgraph import add_langgraph_fastapi_endpoint
|
||||
from copilotkit import CopilotKitRemoteEndpoint, LangGraphAgent
|
||||
from copilotkit.integrations.fastapi import add_fastapi_endpoint
|
||||
from main import graph
|
||||
|
||||
load_dotenv()
|
||||
|
||||
app = FastAPI(title="Cavepedia Agent")
|
||||
|
||||
add_langgraph_fastapi_endpoint(
|
||||
app=app,
|
||||
agent=LangGraphAGUIAgent(
|
||||
name="vpi_1000",
|
||||
description="AI assistant with access to cave-related information through the Cavepedia MCP server",
|
||||
graph=graph,
|
||||
),
|
||||
path="/",
|
||||
)
|
||||
|
||||
def build_agents(context):
|
||||
"""Build agents with auth context from frontend."""
|
||||
user_roles = context.get("properties", {}).get("auth0_user_roles", [])
|
||||
return [
|
||||
LangGraphAgent(
|
||||
name="vpi_1000",
|
||||
description="AI assistant with access to cave-related information through the Cavepedia MCP server",
|
||||
graph=graph,
|
||||
langgraph_config={
|
||||
"configurable": {
|
||||
"context": {
|
||||
"auth0_user_roles": user_roles,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
sdk = CopilotKitRemoteEndpoint(agents=build_agents)
|
||||
add_fastapi_endpoint(app, sdk, "/copilotkit")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
|
||||
2
web/agent/uv.lock
generated
2
web/agent/uv.lock
generated
@@ -1006,7 +1006,6 @@ name = "vpi-1000"
|
||||
version = "1.0.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "ag-ui-langgraph" },
|
||||
{ name = "anthropic" },
|
||||
{ name = "copilotkit" },
|
||||
{ name = "docstring-parser" },
|
||||
@@ -1023,7 +1022,6 @@ dependencies = [
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "ag-ui-langgraph", specifier = ">=0.0.4" },
|
||||
{ name = "anthropic", specifier = ">=0.40.0" },
|
||||
{ name = "copilotkit", specifier = ">=0.1.0" },
|
||||
{ name = "docstring-parser", specifier = ">=0.17.0" },
|
||||
|
||||
Reference in New Issue
Block a user