nextjs-hackathon-stack 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/template/_env.example
CHANGED
|
@@ -12,8 +12,8 @@ DATABASE_URL=postgresql://postgres:[password]@db.your-project-id.supabase.co:543
|
|
|
12
12
|
# Vercel AI Gateway — https://vercel.com > AI > Gateways
|
|
13
13
|
AI_GATEWAY_API_KEY=your-ai-gateway-api-key
|
|
14
14
|
|
|
15
|
-
# Optional: override the gateway base URL (defaults to https://gateway.
|
|
16
|
-
# AI_GATEWAY_URL=https://gateway.
|
|
15
|
+
# Optional: override the gateway base URL (defaults to https://ai-gateway.vercel.sh/v1)
|
|
16
|
+
# AI_GATEWAY_URL=https://ai-gateway.vercel.sh/v1
|
|
17
17
|
|
|
18
18
|
# =============================================================================
|
|
19
19
|
# OPTIONAL
|
|
@@ -7,19 +7,16 @@ export const runtime = "edge";
|
|
|
7
7
|
export async function POST(req: Request) {
|
|
8
8
|
const { messages } = (await req.json()) as { messages: CoreMessage[] };
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
10
|
+
const result = streamText({
|
|
11
|
+
model: aiModel,
|
|
12
|
+
messages,
|
|
13
|
+
maxTokens: 2048,
|
|
14
|
+
});
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
}
|
|
16
|
+
return result.toDataStreamResponse({
|
|
17
|
+
getErrorMessage: (error) => {
|
|
18
|
+
console.error("[chat] stream error:", error);
|
|
19
|
+
return error instanceof Error ? error.message : "AI request failed";
|
|
20
|
+
},
|
|
21
|
+
});
|
|
25
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
2
|
|
|
3
3
|
const gateway = createOpenAI({
|
|
4
|
-
baseURL: process.env.AI_GATEWAY_URL ?? "https://gateway.
|
|
4
|
+
baseURL: process.env.AI_GATEWAY_URL ?? "https://ai-gateway.vercel.sh/v1",
|
|
5
5
|
apiKey: process.env.AI_GATEWAY_API_KEY ?? "",
|
|
6
6
|
});
|
|
7
7
|
|