Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Nov 20, 2024
1 parent 739eb79 commit 454ce84
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 82 deletions.
7 changes: 3 additions & 4 deletions apps/www/public/r/styles/default/api-ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
"@ai-sdk/openai",
"ai"
],
"description": "",
"files": [
{
"content": "import type { NextRequest } from 'next/server';\n\nimport { createOpenAI } from '@ai-sdk/openai';\nimport { convertToCoreMessages, streamText } from 'ai';\nimport { NextResponse } from 'next/server';\n\nexport async function POST(req: NextRequest) {\n const {\n apiKey: key,\n messages,\n model = 'gpt-4o-mini',\n system,\n } = await req.json();\n\n const apiKey = key || process.env.OPENAI_API_KEY;\n\n if (!apiKey) {\n return NextResponse.json(\n { error: 'Missing OpenAI API key.' },\n { status: 401 }\n );\n }\n\n const openai = createOpenAI({ apiKey });\n\n try {\n const result = await streamText({\n maxTokens: 2048,\n messages: convertToCoreMessages(messages),\n model: openai(model),\n system: system,\n });\n\n return result.toDataStreamResponse();\n } catch {\n return NextResponse.json(\n { error: 'Failed to process AI request' },\n { status: 500 }\n );\n }\n}\n",
"path": "app/api/ai/command/route.ts",
"target": "app/api/ai/command/route.ts",
"type": "registry:block"
"type": "registry:lib"
},
{
"content": "import type { NextRequest } from 'next/server';\n\nimport { createOpenAI } from '@ai-sdk/openai';\nimport { generateText } from 'ai';\nimport { NextResponse } from 'next/server';\n\nexport async function POST(req: NextRequest) {\n const {\n apiKey: key,\n model = 'gpt-4o-mini',\n prompt,\n system,\n } = await req.json();\n\n const apiKey = key || process.env.OPENAI_API_KEY;\n\n if (!apiKey) {\n return NextResponse.json(\n { error: 'Missing OpenAI API key.' },\n { status: 401 }\n );\n }\n\n const openai = createOpenAI({ apiKey });\n\n try {\n const result = await generateText({\n abortSignal: req.signal,\n maxTokens: 50,\n model: openai(model),\n prompt: prompt,\n system,\n temperature: 0.7,\n });\n\n return NextResponse.json(result);\n } catch (error: any) {\n if (error.name === 'AbortError') {\n return NextResponse.json(null, { status: 408 });\n }\n\n return NextResponse.json(\n { error: 'Failed to process AI request' },\n { status: 500 }\n );\n }\n}\n",
"path": "app/api/ai/copilot/route.ts",
"target": "app/api/ai/copilot/route.ts",
"type": "registry:block"
"type": "registry:lib"
}
],
"name": "api-ai",
"registryDependencies": [
"use-chat"
],
"type": "registry:block"
"type": "registry:lib"
}
5 changes: 2 additions & 3 deletions apps/www/public/r/styles/default/api-uploadthing.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
"dependencies": [
"[email protected]"
],
"description": "",
"files": [
{
"content": "import type { FileRouter } from 'uploadthing/next';\n\nimport { createRouteHandler, createUploadthing } from 'uploadthing/next';\n\nconst f = createUploadthing();\n\nconst ourFileRouter = {\n editorUploader: f(['image', 'text', 'blob', 'pdf', 'video', 'audio'])\n .middleware(() => {\n return {};\n })\n .onUploadComplete(({ file }) => {\n return { file };\n }),\n} satisfies FileRouter;\n\nexport type OurFileRouter = typeof ourFileRouter;\n\nexport const { GET, POST } = createRouteHandler({\n router: ourFileRouter,\n});\n",
"path": "app/api/uploadthing/route.ts",
"target": "app/api/uploadthing/route.ts",
"type": "registry:block"
"type": "registry:lib"
}
],
"name": "api-uploadthing",
"registryDependencies": [],
"type": "registry:block"
"type": "registry:lib"
}
5 changes: 2 additions & 3 deletions apps/www/scripts/build-registry.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { fixImport } from "./fix-import.mts"
const REGISTRY_PATH = path.join(process.cwd(), "public/r")

const REGISTRY_INDEX_WHITELIST: z.infer<typeof registryItemTypeSchema>[] = [
"registry:app",
"registry:ui",
"registry:lib",
"registry:hook",
Expand Down Expand Up @@ -291,7 +290,7 @@ export const Index: Record<string, any> = {
type: "${item.type}",
registryDependencies: ${JSON.stringify(item.registryDependencies)},
files: [${resolveFiles.map((file) => `"${file}"`)}],
${item.type !== "registry:app" ? `component: ${componentImport},` : ""}
component: ${componentImport},
source: "${sourceFilename}",
category: "${item.category ?? ''}",
subcategory: "${item.subcategory ?? ''}",
Expand Down Expand Up @@ -413,7 +412,7 @@ async function buildStyles(registry: Registry) {
if (!target || target === "") {
const fileName = file.path.split("/").pop()

if (file.type === "registry:component" || file.type === "registry:app") {
if (file.type === "registry:component") {
target = file.path
}
if (
Expand Down
41 changes: 0 additions & 41 deletions apps/www/src/__registry__/default/app/api/ai/command/route.ts

This file was deleted.

21 changes: 0 additions & 21 deletions apps/www/src/__registry__/default/app/api/uploadthing/route.ts

This file was deleted.

8 changes: 4 additions & 4 deletions apps/www/src/__registry__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2324,23 +2324,23 @@ export const Index: Record<string, any> = {
"api-ai": {
name: "api-ai",
description: "",
type: "registry:block",
type: "registry:lib",
registryDependencies: ["use-chat"],
files: ["registry/default/app/api/ai/command/route.ts","registry/default/app/api/ai/copilot/route.ts"],
component: React.lazy(() => import("@/registry/default/app/api/ai/command/route.ts")),
source: "src/__registry__/default/app/api/ai/command/route.ts",
source: "",
category: "",
subcategory: "",
chunks: []
},
"api-uploadthing": {
name: "api-uploadthing",
description: "",
type: "registry:block",
type: "registry:lib",
registryDependencies: [],
files: ["registry/default/app/api/uploadthing/route.ts"],
component: React.lazy(() => import("@/registry/default/app/api/uploadthing/route.ts")),
source: "src/__registry__/default/app/api/uploadthing/route.ts",
source: "",
category: "",
subcategory: "",
chunks: []
Expand Down
10 changes: 5 additions & 5 deletions apps/www/src/registry/registry-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ export const registryApp: Registry = [
{
path: 'app/api/ai/command/route.ts',
target: 'app/api/ai/command/route.ts',
type: 'registry:block',
type: 'registry:lib',
},
{
path: 'app/api/ai/copilot/route.ts',
target: 'app/api/ai/copilot/route.ts',
type: 'registry:block',
type: 'registry:lib',
},
],
name: 'api-ai',
registryDependencies: ['use-chat'],
type: 'registry:block',
type: 'registry:lib',
},
{
dependencies: ['[email protected]'],
files: [
{
path: 'app/api/uploadthing/route.ts',
target: 'app/api/uploadthing/route.ts',
type: 'registry:block',
type: 'registry:lib',
},
],
name: 'api-uploadthing',
registryDependencies: [],
type: 'registry:block',
type: 'registry:lib',
},
];
1 change: 0 additions & 1 deletion apps/www/src/registry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const blockChunkSchema = z.object({

export const registryItemTypeSchema = z.enum([
'registry:pro',
'registry:app',
'registry:style',
'registry:lib',
'registry:example',
Expand Down

0 comments on commit 454ce84

Please sign in to comment.