-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Matvey-Kuk/better-demo-alerts
- Loading branch information
Showing
15 changed files
with
124 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NextRequest } from "next/server"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export async function POST(request: NextRequest) { | ||
try { | ||
// In App Router, we need to parse the request body manually | ||
const body = await request.json(); | ||
|
||
const token = body["x-amzn-marketplace-token"]; | ||
const offerType = body["x-amzn-marketplace-offer-type"]; | ||
|
||
// Base64 encode the token | ||
const base64EncodedToken = encodeURIComponent(btoa(token)); | ||
|
||
// In App Router, we use the redirect function for redirects | ||
return redirect(`/signin?amt=${base64EncodedToken}`); | ||
} catch (error) { | ||
console.error("Error processing request:", error); | ||
return new Response("Bad Request", { status: 400 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
CopilotRuntime, | ||
OpenAIAdapter, | ||
copilotRuntimeNextJSAppRouterEndpoint, | ||
} from "@copilotkit/runtime"; | ||
import OpenAI, { OpenAIError } from "openai"; | ||
import { NextRequest } from "next/server"; | ||
|
||
function initializeCopilotRuntime() { | ||
try { | ||
const openai = new OpenAI({ | ||
organization: process.env.OPEN_AI_ORGANIZATION_ID, | ||
apiKey: process.env.OPEN_AI_API_KEY, | ||
}); | ||
const serviceAdapter = new OpenAIAdapter({ openai }); | ||
const runtime = new CopilotRuntime(); | ||
return { runtime, serviceAdapter }; | ||
} catch (error) { | ||
if (error instanceof OpenAIError) { | ||
console.log("Error connecting to OpenAI", error); | ||
} else { | ||
console.error("Error initializing Copilot Runtime", error); | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
const runtimeOptions = initializeCopilotRuntime(); | ||
|
||
export const POST = async (req: NextRequest) => { | ||
if (!runtimeOptions) { | ||
return new Response("Error initializing Copilot Runtime", { status: 500 }); | ||
} | ||
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({ | ||
runtime: runtimeOptions.runtime, | ||
serviceAdapter: runtimeOptions.serviceAdapter, | ||
endpoint: "/api/copilotkit", | ||
}); | ||
|
||
return handleRequest(req); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Card } from "@tremor/react"; | ||
import { CircleStackIcon } from "@heroicons/react/24/outline"; | ||
import clsx from "clsx"; | ||
|
||
export function EmptyStateCard({ | ||
title, | ||
icon, | ||
description, | ||
className, | ||
children, | ||
}: { | ||
icon?: React.ElementType; | ||
title: string; | ||
description: string; | ||
className?: string; | ||
children?: React.ReactNode; | ||
}) { | ||
const Icon = icon || CircleStackIcon; | ||
return ( | ||
<Card className={clsx("sm:mx-auto w-full max-w-5xl", className)}> | ||
<div className="text-center"> | ||
<Icon | ||
className="mx-auto h-7 w-7 text-tremor-content-subtle dark:text-dark-tremor-content-subtle" | ||
aria-hidden={true} | ||
/> | ||
<p className="mt-2 text-tremor-default font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong"> | ||
{title} | ||
</p> | ||
<p className="text-tremor-default text-tremor-content dark:text-dark-tremor-content"> | ||
{description} | ||
</p> | ||
{children} | ||
</div> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EmptyStateCard } from "./EmptyStateCard"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters