fix builds
This commit is contained in:
@@ -17,8 +17,10 @@ app = FastAPI(title="Cavepedia Agent")
|
||||
|
||||
|
||||
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", [])
|
||||
|
||||
return [
|
||||
LangGraphAgent(
|
||||
name="vpi_1000",
|
||||
|
||||
@@ -5,36 +5,18 @@ import {
|
||||
} from "@copilotkit/runtime";
|
||||
|
||||
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();
|
||||
|
||||
// 3. Build a Next.js API route that handles the CopilotKit runtime requests.
|
||||
export const POST = async (req: NextRequest) => {
|
||||
// Get Auth0 session
|
||||
const session = await auth0.getSession();
|
||||
|
||||
// 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,
|
||||
const runtime = new CopilotRuntime({
|
||||
remoteEndpoints: [
|
||||
{
|
||||
url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`,
|
||||
},
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
export const POST = async (req: NextRequest) => {
|
||||
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
|
||||
runtime,
|
||||
serviceAdapter,
|
||||
|
||||
Referens i nytt ärende
Block a user