Files
Markus Ecker 082db7a996 Add CrewAI support (#1308)
Co-authored-by: Suhas Deshpande <suhasdeshpande@users.noreply.github.com>
Co-authored-by: Ariel Weinberger <Weinberger.Ariel@gmail.com>
Co-authored-by: Suhas Deshpande <suhas2u@gmail.com>
2025-02-28 12:21:54 +01:00

49 lines
1.3 KiB
TypeScript

"use client";
import { CopilotKit } from "@copilotkit/react-core";
import { Greeter } from "./Greeter";
import "@copilotkit/react-ui/styles.css";
import {
ModelSelectorProvider,
useModelSelectorContext,
} from "@/lib/model-selector-provider";
import { ModelSelector } from "@/components/ModelSelector";
import { useSearchParams } from "next/navigation";
import { Suspense } from "react";
export default function ModelSelectorWrapper() {
return (
<main className="flex flex-col items-center justify-between">
<ModelSelectorProvider>
<Suspense>
<Home />
</Suspense>
<ModelSelector />
</ModelSelectorProvider>
</main>
);
}
function Home() {
const { lgcDeploymentUrl, agent } = useModelSelectorContext();
const searchParams = useSearchParams();
const runtimeUrl = searchParams.get("runtimeUrl")
? (searchParams.get("runtimeUrl") as string)
: `/api/copilotkit?lgcDeploymentUrl=${lgcDeploymentUrl ?? ""}`;
const publicApiKey = searchParams.get("publicApiKey");
const copilotKitProps: Partial<React.ComponentProps<typeof CopilotKit>> = {
runtimeUrl,
publicApiKey: publicApiKey || undefined,
showDevConsole: false,
agent,
};
return (
<CopilotKit {...copilotKitProps}>
<Greeter />
</CopilotKit>
);
}