Skip to content

Commit 622bf33

Browse files
author
thorwebdev
committed
chore: type AsyncGenerator.
1 parent 798c0ea commit 622bf33

File tree

1 file changed

+9
-6
lines changed
  • supabase/functions/vercel-ai-chat

1 file changed

+9
-6
lines changed

supabase/functions/vercel-ai-chat/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
2-
import { createClient } from "https://esm.sh/@supabase/[email protected].5";
1+
/// <reference types="https://esm.sh/v135/@supabase/functions-js@2.3.1/src/edge-runtime.d.ts" />
2+
import { createClient } from "https://esm.sh/@supabase/[email protected].7";
33
import { corsHeaders } from "../_shared/cors.ts";
44

55
const session = new Supabase.ai.Session("llama3");
@@ -18,9 +18,7 @@ Deno.serve(async (req: Request) => {
1818
{ global: { headers: { Authorization: authHeader } } },
1919
);
2020
// Get user
21-
const { data: { user }, error } = await supabase.auth.getUser(
22-
authHeader.split("Bearer ")[1],
23-
);
21+
const { data: { user }, error } = await supabase.auth.getUser();
2422
if (error) throw error;
2523
if (!user) throw new Error("no user");
2624
const userId = user.id;
@@ -38,7 +36,12 @@ Deno.serve(async (req: Request) => {
3836
`.trim();
3937

4038
// Get the output as a stream
41-
const output = await session.run(prompt, { stream: true });
39+
const output =
40+
(await session.run(prompt, { stream: true })) as AsyncGenerator<
41+
{ response: string | null },
42+
never,
43+
void
44+
>;
4245

4346
// Create a stream
4447
const stream = new ReadableStream({

0 commit comments

Comments
 (0)