fix web errors
All checks were successful
Build and Push Agent Docker Image / build (push) Successful in 52s
Build and Push Web Docker Image / build (push) Successful in 3m28s

This commit is contained in:
2025-12-13 00:35:38 +01:00
parent 754a65e1d7
commit 74e63a6b9a
3 changed files with 18 additions and 33 deletions

View File

@@ -16,4 +16,5 @@ dependencies = [
"docstring-parser>=0.17.0", "docstring-parser>=0.17.0",
"jsonschema>=4.25.1", "jsonschema>=4.25.1",
"copilotkit>=0.1.0", "copilotkit>=0.1.0",
"ag-ui-langgraph>=0.0.4",
] ]

View File

@@ -1,5 +1,5 @@
""" """
Self-hosted LangGraph agent server using CopilotKit. Self-hosted LangGraph agent server using CopilotKit AG-UI protocol.
""" """
import os import os
@@ -7,38 +7,23 @@ from fastapi import FastAPI
import uvicorn import uvicorn
from dotenv import load_dotenv from dotenv import load_dotenv
from copilotkit import CopilotKitRemoteEndpoint, LangGraphAgent from copilotkit import LangGraphAGUIAgent
from copilotkit.integrations.fastapi import add_fastapi_endpoint from ag_ui_langgraph import add_langgraph_fastapi_endpoint
from main import graph from main import graph
load_dotenv() load_dotenv()
app = FastAPI(title="Cavepedia Agent") app = FastAPI(title="Cavepedia Agent")
add_langgraph_fastapi_endpoint(
def build_agents(context): app=app,
"""Build agents with auth context from properties.""" agent=LangGraphAGUIAgent(
# Get user roles from frontend properties name="vpi_1000",
user_roles = context.get("properties", {}).get("auth0_user_roles", []) description="AI assistant with access to cave-related information through the Cavepedia MCP server",
graph=graph,
return [ ),
LangGraphAgent( path="/",
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") @app.get("/health")

View File

@@ -2,7 +2,6 @@ import {
CopilotRuntime, CopilotRuntime,
ExperimentalEmptyAdapter, ExperimentalEmptyAdapter,
copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSAppRouterEndpoint,
LangGraphHttpAgent,
} from "@copilotkit/runtime"; } from "@copilotkit/runtime";
import { NextRequest } from "next/server"; import { NextRequest } from "next/server";
@@ -10,11 +9,11 @@ import { NextRequest } from "next/server";
const serviceAdapter = new ExperimentalEmptyAdapter(); const serviceAdapter = new ExperimentalEmptyAdapter();
const runtime = new CopilotRuntime({ const runtime = new CopilotRuntime({
agents: { remoteEndpoints: [
vpi_1000: new LangGraphHttpAgent({ {
url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`, url: process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000",
}), },
}, ],
}); });
export const POST = async (req: NextRequest) => { export const POST = async (req: NextRequest) => {