Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix numbering in ai model guide (#22801)

Inian3fc049bac571
diff --git a/apps/docs/content/guides/functions/ai-models.mdx b/apps/docs/content/guides/functions/ai-models.mdx
index 4a3415ae3be..e895bb5568e 100644
--- a/apps/docs/content/guides/functions/ai-models.mdx
+++ b/apps/docs/content/guides/functions/ai-models.mdx
@@ -72,75 +72,75 @@ Inference via larger models is supported via [Ollama](https://ollama.com/). In t
1. Install Ollama and pull the Mistral model
-```
-ollama pull mistral
-```
-
-2. Run the Ollama server locally
-
-```
-ollama serve
-```
-
-3. Set a function secret called AI_INFERENCE_API_HOST to point to the Ollama server
-
-```
-echo "AI_INFERENCE_API_HOST=http://host.docker.internal:11434/api/generate" >> supabase/functions/.env
-```
-
-4. Create a new function with the following code
-
-```
-supabase functions new ollama-test
-```
-
-```ts
-/// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
-const session = new Supabase.ai.Session('mistral')
-
-Deno.serve(async (req: Request) => {
- const params = new URL(req.url).searchParams
- const prompt = params.get('prompt') ?? ''
-
- // Get the output as a stream
- const output = await session.run(prompt, { stream: true })
-
- const headers = new Headers({
- 'Content-Type': 'text/event-stream',
- Connection: 'keep-alive',
- })
-
- // Create a stream
- const stream = new ReadableStream({
- async start(controller) {
- const encoder = new TextEncoder()
-
- try {
- for await (const chunk of output) {
- controller.enqueue(encoder.encode(chunk.response ?? ''))
- }
- } catch (err) {
- console.error('Stream error:', err)
- } finally {
- controller.close()
- }
- },
- })
-
- // Return the stream to the user
- return new Response(stream, {
- headers,
- })
-})
-```
-
-5. Execute the function
-
-```
-curl --get "http://localhost:54321/functions/v1/ollama-test" \
---data-urlencode "prompt=write a short rap song about Supabase, the Postgres Developer platform, as sung by Nicki Minaj" \
--H "Authorization: $ANON_KEY"
-```
+ ```
+ ollama pull mistral
+ ```
+
+1. Run the Ollama server locally
+
+ ```
+ ollama serve
+ ```
+
+1. Set a function secret called AI_INFERENCE_API_HOST to point to the Ollama server
+
+ ```
+ echo "AI_INFERENCE_API_HOST=http://host.docker.internal:11434/api/generate" >> supabase/functions/.env
+ ```
+
+1. Create a new function with the following code
+
+ ```
+ supabase functions new ollama-test
+ ```
+
+ ```ts
+ /// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
+ const session = new Supabase.ai.Session('mistral')
+
+ Deno.serve(async (req: Request) => {
+ const params = new URL(req.url).searchParams
+ const prompt = params.get('prompt') ?? ''
+
+ // Get the output as a stream
+ const output = await session.run(prompt, { stream: true })
+
+ const headers = new Headers({
+ 'Content-Type': 'text/event-stream',
+ Connection: 'keep-alive',
+ })
+
+ // Create a stream
+ const stream = new ReadableStream({
+ async start(controller) {
+ const encoder = new TextEncoder()
+
+ try {
+ for await (const chunk of output) {
+ controller.enqueue(encoder.encode(chunk.response ?? ''))
+ }
+ } catch (err) {
+ console.error('Stream error:', err)
+ } finally {
+ controller.close()
+ }
+ },
+ })
+
+ // Return the stream to the user
+ return new Response(stream, {
+ headers,
+ })
+ })
+ ```
+
+1. Execute the function
+
+ ```
+ curl --get "http://localhost:54321/functions/v1/ollama-test" \
+ --data-urlencode "prompt=write a short rap song about Supabase, the Postgres Developer platform, as sung by Nicki Minaj" \
+ -H "Authorization: $ANON_KEY"
+ ```
### Deploying to production
@@ -148,23 +148,23 @@ Once the function is working locally, it's time to deploy to production.
1. Deploy a Ollama server and set a function secret called `AI_INFERENCE_API_HOST` to point to the deployed Ollama server
-```
-supabase secrets set AI_INFERENCE_API_HOST=https://path-to-your-ollama-server/
-```
+ ```
+ supabase secrets set AI_INFERENCE_API_HOST=https://path-to-your-ollama-server/
+ ```
2. Deploy the Supabase function
-```
-supabase functions deploy ollama-test
-```
+ ```
+ supabase functions deploy ollama-test
+ ```
3. Execute the function
-```
-curl --get "https://project-ref.supabase.co/functions/v1/ollama-test" \
---data-urlencode "prompt=write a short rap song about Supabase, the Postgres Developer platform, as sung by Nicki Minaj" \
--H "Authorization: $ANON_KEY"
-```
+ ```
+ curl --get "https://project-ref.supabase.co/functions/v1/ollama-test" \
+ --data-urlencode "prompt=write a short rap song about Supabase, the Postgres Developer platform, as sung by Nicki Minaj" \
+ -H "Authorization: $ANON_KEY"
+ ```
As demonstrated in the video above, running Ollama locally is typically slower than running it in on a server with dedicated GPUs. We are collaborating with the Ollama team to improve local performance.