15,048
edits
No edit summary |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 19: | Line 19: | ||
Root Cause: Incorrect `messages` format. The API expects an array format, but a single object was being sent. | Root Cause: Incorrect `messages` format. The API expects an array format, but a single object was being sent. | ||
Incorrect Format: ❌ This is an object | Incorrect Format in PHP: ❌ This is an object | ||
<pre> | <pre> | ||
'messages' => ['role' => 'user', 'content' => $message] | 'messages' => ['role' => 'user', 'content' => $message] | ||
</pre> | </pre> | ||
Correct Format: ✅ This is an array containing an object | Correct Format in PHP: ✅ This is an array containing an object | ||
<pre> | <pre> | ||
'messages' => [['role' => 'user', 'content' => $message]] | 'messages' => [['role' => 'user', 'content' => $message]] | ||
| Line 33: | Line 33: | ||
This fix resolves the `"cannot unmarshal object into Go struct field ChatRequest.messages"` error. | This fix resolves the `"cannot unmarshal object into Go struct field ChatRequest.messages"` error. | ||
== Related links == | |||
* Forum: [https://www.reddit.com/r/ollama/ ollama] | |||
[[Category: Tools]] | [[Category: Tools]] | ||