fix builds
All checks were successful
Build and Push Agent Docker Image / build (push) Successful in 55s
Build and Push Web Docker Image / build (push) Successful in 3m35s

This commit is contained in:
2025-12-13 00:18:50 +01:00
parent 17802994a5
commit 4fd346cb20
2 changed files with 10 additions and 26 deletions

View File

@@ -17,8 +17,10 @@ app = FastAPI(title="Cavepedia Agent")
def build_agents(context): def build_agents(context):
"""Build agents with auth context from frontend.""" """Build agents with auth context from properties."""
# Get user roles from frontend properties
user_roles = context.get("properties", {}).get("auth0_user_roles", []) user_roles = context.get("properties", {}).get("auth0_user_roles", [])
return [ return [
LangGraphAgent( LangGraphAgent(
name="vpi_1000", name="vpi_1000",

View File

@@ -5,36 +5,18 @@ import {
} from "@copilotkit/runtime"; } from "@copilotkit/runtime";
import { NextRequest } from "next/server"; import { NextRequest } from "next/server";
import { auth0 } from "@/lib/auth0";
// 1. You can use any service adapter here for multi-agent support. We use
// the empty adapter since we're only using one agent.
const serviceAdapter = new ExperimentalEmptyAdapter(); const serviceAdapter = new ExperimentalEmptyAdapter();
// 3. Build a Next.js API route that handles the CopilotKit runtime requests. const runtime = new CopilotRuntime({
export const POST = async (req: NextRequest) => { remoteEndpoints: [
// Get Auth0 session {
const session = await auth0.getSession(); url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`,
// Extract roles from session
const userRoles = session?.user?.roles || [];
console.log("[copilotkit] session exists:", !!session);
console.log("[copilotkit] userRoles:", userRoles);
// 2. Create the CopilotRuntime instance with remote endpoint
const runtime = new CopilotRuntime({
remoteEndpoints: [
{
url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`,
},
],
// Pass auth context as properties to the remote endpoint
properties: {
auth0_user_roles: userRoles,
}, },
}); ],
});
export const POST = async (req: NextRequest) => {
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({ const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime, runtime,
serviceAdapter, serviceAdapter,