Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use unifyAI for demo purposes #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OPENAI_API_KEY=xxxxxxx
OPENAI_MODEL=gpt-4-1106-preview
TAVILY_API_KEY=xxxxxxx
UNIFY_API_KEY=xxxxxxx
9 changes: 5 additions & 4 deletions src/app/api/copilotkit/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
import {
CopilotRuntime,
copilotRuntimeNextJSAppRouterEndpoint,
OpenAIAdapter,
UnifyAdapter,
} from "@copilotkit/runtime";

const UNSPLASH_ACCESS_KEY_ENV = "UNSPLASH_ACCESS_KEY";
Expand Down Expand Up @@ -72,13 +72,14 @@ export const POST = async (req: NextRequest) => {
actions.push(researchAction);
}

const openaiModel = process.env["OPENAI_MODEL"];

console.log("ENV.COPILOT_CLOUD_API_KEY", process.env.COPILOT_CLOUD_API_KEY);

const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime: new CopilotRuntime({ actions }),
serviceAdapter: new OpenAIAdapter({ model: openaiModel }),
serviceAdapter: new UnifyAdapter({
apiKey: process.env.UNIFY_API_KEY,
model: "router@q:0.5|c:0.013|models:gpt-4o,gpt-3.5-turbo|providers:openai"
}),
endpoint: req.nextUrl.pathname,
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function AIPresentation() {

return (
<CopilotKit
publicApiKey={process.env.NEXT_PUBLIC_COPILOT_CLOUD_API_KEY}
// publicApiKey={process.env.NEXT_PUBLIC_COPILOT_CLOUD_API_KEY}
// Alternatively, you can use runtimeUrl to host your own CopilotKit Runtime
runtimeUrl="/api/copilotkit"
transcribeAudioUrl="/api/transcribe"
Expand Down