[GH-ISSUE #7977] Format JSON is used when providing null to format field #5103

Closed
opened 2026-04-12 16:12:05 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @jasonkaplan79 on GitHub (Dec 6, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7977

What is the issue?

I have been running the Ollama application on my Mac to access the API server from my Laravel web application.
I am using this package for Laravel, which isn't actively maintained (and there aren't too many alternatives):
https://github.com/cloudstudio/ollama-laravel/

I updated the Ollama application on my Mac this morning, and something broke. This is my code, which doesn't return any results anymore. It used to work before this Ollama update (also, my code hasn't changed, and neither has ollama-laravel)!

$response = Ollama::stream(false)
            ->agent("You are an expert and have general knowledge on every topic. Respond in markdown format.")
            ->prompt($request->input('prompt'))
            ->model('llama3.2:3b') // 'llama2', 'llama3.1:70b', 'llama3.2:3b'
            ->options(['temperature' => 0.8])
            ->ask()
        ;
        return response()->json(['response' => $response['response']]);

What I tried:

During my debugging, I tried this with ollama serve instead of using the Mac application, and hit this API endpoint: http://127.0.0.1:11434/api/generate
from POSTMAN with the following POST BODY parameters:

{
    "model": "llama3.2:3b",
    "prompt": "Why is the sky blue?",
    "stream": false
}

Hitting this API directly worked fine: screenshot below.

image

Why does this code not work?

https://github.com/cloudstudio/ollama-laravel?tab=readme-ov-file#basic-usage

$response = Ollama::stream(false)
            ->agent("You are an expert and have general knowledge on every topic. Respond in markdown format.")
            ->prompt($request->input('prompt'))
            ->model('llama3.2:3b') // 'llama2', 'llama3.1:70b', 'llama3.2:3b'
            ->options(['temperature' => 0.8])
            ->ask()
        ;
        return response()->json(['response' => $response['response']]);

Note: The ask() function is defined here:
9c44ec6b09/src/Ollama.php (L291)
which in turn calls Ollama's /api/generate/ API.

What in the world is going on?

OS

macOS

GPU

Apple

CPU

No response

Ollama version

0.5.0

Originally created by @jasonkaplan79 on GitHub (Dec 6, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7977 ### What is the issue? I have been running the Ollama application on my Mac to access the API server from my Laravel web application. I am using this package for Laravel, which isn't actively maintained (and there aren't too many alternatives): https://github.com/cloudstudio/ollama-laravel/ I updated the Ollama application on my Mac this morning, and something broke. This is my code, which doesn't return any results anymore. It used to work before this Ollama update (also, my code hasn't changed, and neither has ollama-laravel)! ``` $response = Ollama::stream(false) ->agent("You are an expert and have general knowledge on every topic. Respond in markdown format.") ->prompt($request->input('prompt')) ->model('llama3.2:3b') // 'llama2', 'llama3.1:70b', 'llama3.2:3b' ->options(['temperature' => 0.8]) ->ask() ; return response()->json(['response' => $response['response']]); ``` ### What I tried: During my debugging, I tried this with `ollama serve` instead of using the Mac application, and hit this API endpoint: http://127.0.0.1:11434/api/generate from POSTMAN with the following POST BODY parameters: ``` { "model": "llama3.2:3b", "prompt": "Why is the sky blue?", "stream": false } ``` Hitting this API directly worked fine: screenshot below. <img width="883" alt="image" src="https://github.com/user-attachments/assets/76ab6f4e-fa33-46c0-8ff5-a682b8fa72b5"> ### Why does this code not work? https://github.com/cloudstudio/ollama-laravel?tab=readme-ov-file#basic-usage ``` $response = Ollama::stream(false) ->agent("You are an expert and have general knowledge on every topic. Respond in markdown format.") ->prompt($request->input('prompt')) ->model('llama3.2:3b') // 'llama2', 'llama3.1:70b', 'llama3.2:3b' ->options(['temperature' => 0.8]) ->ask() ; return response()->json(['response' => $response['response']]); ``` Note: The ask() function is defined here: https://github.com/cloudstudio/ollama-laravel/blob/9c44ec6b093c8ddb62398664979a7e0be68d563c/src/Ollama.php#L291 which in turn calls Ollama's /api/generate/ API. What in the world is going on? ### OS macOS ### GPU Apple ### CPU _No response_ ### Ollama version 0.5.0
GiteaMirror added the bug label 2026-04-12 16:12:05 -05:00
Author
Owner

@jasonkaplan79 commented on GitHub (Dec 6, 2024):

@ParthSareen thanks for the quick fix! What's the best way to update ollama with this fix on a mac?

<!-- gh-comment-id:2524601754 --> @jasonkaplan79 commented on GitHub (Dec 6, 2024): @ParthSareen thanks for the quick fix! What's the best way to update ollama with this fix on a mac?
Author
Owner

@ParthSareen commented on GitHub (Dec 6, 2024):

@jasonkaplan79 have builds for release running - hopefully in the next hour or so! Will ping here! You can build from main locally in the meantime as well :)

<!-- gh-comment-id:2524603684 --> @ParthSareen commented on GitHub (Dec 6, 2024): @jasonkaplan79 have builds for release running - hopefully in the next hour or so! Will ping here! You can build from main locally in the meantime as well :)
Author
Owner

@jasonkaplan79 commented on GitHub (Dec 6, 2024):

@ParthSareen thanks! Hopefully an automated test can be added as well to prevent another breakage like this

<!-- gh-comment-id:2524621000 --> @jasonkaplan79 commented on GitHub (Dec 6, 2024): @ParthSareen thanks! Hopefully an automated test can be added as well to prevent another breakage like this
Author
Owner

@ParthSareen commented on GitHub (Dec 6, 2024):

@ParthSareen thanks! Hopefully an automated test can be added as well to prevent another breakage like this

Yeah for sure - sorry for the bug. Going to do a slightly bigger refactor next week around this as well!

<!-- gh-comment-id:2524622852 --> @ParthSareen commented on GitHub (Dec 6, 2024): > @ParthSareen thanks! Hopefully an automated test can be added as well to prevent another breakage like this Yeah for sure - sorry for the bug. Going to do a slightly bigger refactor next week around this as well!
Author
Owner

@jasonkaplan79 commented on GitHub (Dec 6, 2024):

Makes sense, and thanks @ParthSareen

<!-- gh-comment-id:2524625109 --> @jasonkaplan79 commented on GitHub (Dec 6, 2024): Makes sense, and thanks @ParthSareen
Author
Owner

@jasonkaplan79 commented on GitHub (Dec 7, 2024):

@ParthSareen this works now in v 0.5.1

<!-- gh-comment-id:2524805015 --> @jasonkaplan79 commented on GitHub (Dec 7, 2024): @ParthSareen this works now in v 0.5.1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5103