File tree 1 file changed +9
-6
lines changed
supabase/functions/vercel-ai-chat
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 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 " ;
3
3
import { corsHeaders } from "../_shared/cors.ts" ;
4
4
5
5
const session = new Supabase . ai . Session ( "llama3" ) ;
@@ -18,9 +18,7 @@ Deno.serve(async (req: Request) => {
18
18
{ global : { headers : { Authorization : authHeader } } } ,
19
19
) ;
20
20
// 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 ( ) ;
24
22
if ( error ) throw error ;
25
23
if ( ! user ) throw new Error ( "no user" ) ;
26
24
const userId = user . id ;
@@ -38,7 +36,12 @@ Deno.serve(async (req: Request) => {
38
36
` . trim ( ) ;
39
37
40
38
// 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
+ > ;
42
45
43
46
// Create a stream
44
47
const stream = new ReadableStream ( {
You can’t perform that action at this time.
0 commit comments