mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Problem Fixes #54190 The Running AI Models page has an example that runs Llamafile through the OpenAI Deno SDK. The function reads the prompt with `await req.json()`. The curl command on the same tab sends a GET request with the prompt in the query string, so there is no body. `req.json()` throws `SyntaxError: Unexpected end of JSON input` and the function fails before it reaches Llamafile. ## Solution Read the prompt from the URL, with the same two lines the Ollama tab and the other Llamafile tab on this page already use. Tested: - Ran the handler in Deno 2.9.8 and called it with the curl command from the page. The handler ran without the `withSupabase` wrapper, which does not read the request body, and the OpenAI call was replaced with an echo, since the error happens first. The old code threw `Unexpected end of JSON input`. The new code returned the prompt. - `oxfmt --check` (version 0.79.0, from the repo catalog) passes on the changed file. Not tested: a real Llamafile server and the docs site build. ## Review instructions 1. Open [Running AI Models](https://supabase.com/docs/guides/functions/ai-models) and go to **Running locally** > **Mozilla Llamafile** > **OpenAI Deno SDK**. 2. Compare the function code with the curl command in "Execute the function". The curl command sends a GET request with no body. 3. In the diff, see that the function now reads `prompt` from the query string, like the other two tabs. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) Co-authored-by: Nik Richers <nrichers@gmail.com>