Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ function CustomApp({
/>
),
},
{
name: 'Search',
id: '10',
isSelected: router.pathname === '/search',
href: '/search',
renderItem: () => (
<WfoMenuItemLink
path={'/search'}
translationString="Search"
isSelected={router.pathname === '/search'}
/>
),
},
{
name: 'Agent',
id: '10',
isSelected: router.pathname === '/agent',
href: '/agent',
renderItem: () => (
<WfoMenuItemLink
path={'/agent'}
translationString="Agent"
isSelected={router.pathname === '/agent'}
/>
),
},
];

const errorMonitoringHandler: WfoErrorMonitoring | undefined = {
Expand Down
11 changes: 11 additions & 0 deletions pages/agent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { CopilotKit } from '@copilotkit/react-core';
import '@copilotkit/react-ui/styles.css';
import { WfoAgent } from '@orchestrator-ui/orchestrator-ui-components';

export default function SearchPage() {
return (
<CopilotKit runtimeUrl="/api/copilotkit" agent="query_agent">
<WfoAgent />
</CopilotKit>
);
}
47 changes: 47 additions & 0 deletions pages/api/copilotkit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getServerSession } from 'next-auth';

import { HttpAgent } from '@ag-ui/client';
import {
CopilotRuntime,
ExperimentalEmptyAdapter,
copilotRuntimeNextJSPagesRouterEndpoint,
} from '@copilotkit/runtime';
import { WfoSession } from '@orchestrator-ui/orchestrator-ui-components';

import { authOptions } from './auth/[...nextauth]';

const serviceAdapter = new ExperimentalEmptyAdapter();

export default async function copilotHandler(
req: NextApiRequest,
res: NextApiResponse,
) {
const session = (await getServerSession(
req,
res,
authOptions,
)) as WfoSession;

const headers: Record<string, string> = {};
if (session?.accessToken) {
headers['Authorization'] = `Bearer ${session.accessToken}`;
}

const runtime = new CopilotRuntime({
agents: {
query_agent: new HttpAgent({
url: process.env.AGENT_URL || 'http://localhost:8080/agent/',
headers,
}),
},
});

const handler = copilotRuntimeNextJSPagesRouterEndpoint({
runtime,
serviceAdapter,
endpoint: '/api/copilotkit',
});

return handler(req, res);
}
7 changes: 7 additions & 0 deletions pages/search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

import { WfoSearch } from '@orchestrator-ui/orchestrator-ui-components';

export default function SearchPage() {
return <WfoSearch />;
}