From bad9a4e54718d7fc6a26e0813b9b0cfdd305644e Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Sat, 13 Dec 2025 01:04:28 +0100 Subject: [PATCH] revert some stuff --- web/agent/pyproject.toml | 1 + web/agent/server.py | 23 +++++++++++------------ web/src/app/api/copilotkit/route.ts | 13 ++++++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/web/agent/pyproject.toml b/web/agent/pyproject.toml index d12980c..39d5173 100644 --- a/web/agent/pyproject.toml +++ b/web/agent/pyproject.toml @@ -16,4 +16,5 @@ dependencies = [ "docstring-parser>=0.17.0", "jsonschema>=4.25.1", "copilotkit>=0.1.0", + "ag-ui-langgraph>=0.0.4", ] diff --git a/web/agent/server.py b/web/agent/server.py index bdcb7d0..66d1f65 100644 --- a/web/agent/server.py +++ b/web/agent/server.py @@ -1,5 +1,5 @@ """ -Self-hosted LangGraph agent server using CopilotKit remote endpoint protocol. +Self-hosted LangGraph agent server using AG-UI protocol. """ import os @@ -7,24 +7,23 @@ from fastapi import FastAPI import uvicorn from dotenv import load_dotenv -from copilotkit import CopilotKitRemoteEndpoint, LangGraphAgent -from copilotkit.integrations.fastapi import add_fastapi_endpoint +from copilotkit import LangGraphAGUIAgent +from ag_ui_langgraph import add_langgraph_fastapi_endpoint from main import graph load_dotenv() app = FastAPI(title="Cavepedia Agent") -sdk = CopilotKitRemoteEndpoint( - agents=[ - LangGraphAgent( - name="vpi_1000", - description="AI assistant with access to cave-related information through the Cavepedia MCP server", - graph=graph, - ) - ] +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="/", ) -add_fastapi_endpoint(app, sdk, "/copilotkit") @app.get("/health") diff --git a/web/src/app/api/copilotkit/route.ts b/web/src/app/api/copilotkit/route.ts index 9fe666d..21a6635 100644 --- a/web/src/app/api/copilotkit/route.ts +++ b/web/src/app/api/copilotkit/route.ts @@ -4,16 +4,19 @@ import { copilotRuntimeNextJSAppRouterEndpoint, } from "@copilotkit/runtime"; +import { LangGraphAgent } from "@ag-ui/langgraph"; import { NextRequest } from "next/server"; const serviceAdapter = new ExperimentalEmptyAdapter(); const runtime = new CopilotRuntime({ - remoteEndpoints: [ - { - url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`, - }, - ], + agents: { + vpi_1000: new LangGraphAgent({ + deploymentUrl: process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000", + graphId: "vpi_1000", + langsmithApiKey: process.env.LANGSMITH_API_KEY || "", + }), + }, }); export const POST = async (req: NextRequest) => {