Skip to content

Commit c31246c

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

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

supabase/functions/ollama-test/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ Deno.serve(async (req: Request) => {
66
const prompt = params.get("prompt") ?? "";
77

88
// Get the output as a stream
9-
const output = await session.run(prompt, { stream: true });
9+
const output =
10+
(await session.run(prompt, { stream: true })) as AsyncGenerator<
11+
{ response: string | null },
12+
never,
13+
void
14+
>;
1015

1116
const headers = new Headers({
1217
"Content-Type": "text/event-stream",

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

Lines changed: 10 additions & 7 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;
@@ -31,14 +29,19 @@ Deno.serve(async (req: Request) => {
3129
console.log(json);
3230
const { messages, previewToken } = json;
3331
const prompt =
34-
`You're a friendly support assistant. Given the following message history between a user and you, the assistant, answer the user's most recent question taking into consideration on all the context provided in the messages.
32+
`You're a friendly support assistant. Given the following message history between a user and you, the assistant, answer the user's most recent question taking into consideration all the context provided in the messages.
3533
3634
Messages:
3735
${JSON.stringify(messages)}
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)