Skip to content

Commit

Permalink
Merge pull request #185 from mikepsinn/develop
Browse files Browse the repository at this point in the history
Add copilotkit
  • Loading branch information
mikepsinn authored Apr 23, 2024
2 parents 625f043 + a9840a7 commit 2d12996
Show file tree
Hide file tree
Showing 6 changed files with 760 additions and 42 deletions.
9 changes: 9 additions & 0 deletions apps/nextjs/app/api/copilotkit/openai/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { CopilotBackend, OpenAIAdapter } from "@copilotkit/backend";

export const runtime = "edge";

export async function POST(req: Request): Promise<Response> {
const copilotKit = new CopilotBackend();

return copilotKit.response(req, new OpenAIAdapter());
}
4 changes: 2 additions & 2 deletions apps/nextjs/app/api/dfda/[dfdaPath]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ async function fetchDfdaApi(req: Request, method: 'GET' | 'POST', context: z.inf
const requestBody = await req.json();
init.body = JSON.stringify(requestBody);
}
console.log(`Making ${method} request to ${dfdaUrl} with init:`, init);
console.log(`Making ${method} request to ${dfdaUrl}`); // with init:`, init);
const response = await fetch(dfdaUrl, init);
const data = await response.json();
console.log("Response data:", data);
//console.log("Response data:", data);
return new Response(JSON.stringify(data), { status: 200, headers: { 'Content-Type': 'application/json' } })
} catch (error) {
return handleError(error);
Expand Down
7 changes: 7 additions & 0 deletions apps/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { siteConfig } from "@/config/site"
import { cn } from "@/lib/utils"
import { Toaster } from "@/components/ui/toaster"
import { ThemeProvider } from "@/components/theme-provider"
import { CopilotKit } from "@copilotkit/react-core";
import { CopilotSidebar } from "@copilotkit/react-ui";
//import "@copilotkit/react-ui/styles.css";

const inter = Inter({ subsets: ["latin"] })

Expand Down Expand Up @@ -73,6 +76,8 @@ export default async function RootLayout({ children }: RootLayoutProps) {
<html lang="en" suppressHydrationWarning>
<body className={cn("antialiased", inter.className)}>
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem>
{/*<CopilotKit url="/api/copilotkit/openai">*/}
{/* <CopilotSidebar>*/}
<NextTopLoader color="#DC2645" height={2.5} showSpinner={false} />
<div
vaul-drawer-wrapper=""
Expand All @@ -81,6 +86,8 @@ export default async function RootLayout({ children }: RootLayoutProps) {
{children}
</div>
<Toaster />
{/* </CopilotSidebar>*/}
{/*</CopilotKit>*/}
</ThemeProvider>
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/components/chat-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FullPageChat } from 'flowise-embed-react';
export default function ChatComponent() {
return <FullPageChat
chatflowid="3a94fd29-fbe1-4318-a67b-a3fb5b6f74a8"
apiHost="https://fw.dfda.earth"
apiHost="https://fw.fdai.earth"
theme={{
chatWindow: {
welcomeMessage: "Hello! This is custom welcome message",
welcomeMessage: "How are you?",
backgroundColor: "#ffffff",
height: 700,
width: 400,
Expand Down
3 changes: 3 additions & 0 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"generate:rapini": "npx rapini react-query -p ../../docs/api-reference/openapi.yml"
},
"dependencies": {
"@copilotkit/backend": "^0.8.0",
"@copilotkit/react-core": "^0.24.0",
"@copilotkit/react-ui": "^0.21.0",
"@hookform/resolvers": "^3.3.4",
"@mdx-js/loader": "^3.0.1",
"@mdx-js/react": "^3.0.1",
Expand Down
Loading

0 comments on commit 2d12996

Please sign in to comment.