|
18 | 18 | <a href="https://github.com/deepseek-php/deepseek-php-client/stargazers">
|
19 | 19 | <img src="https://img.shields.io/github/stars/deepseek-php/deepseek-php-client?style=social" alt="GitHub Stars">
|
20 | 20 | </a>
|
21 |
| - |
22 |
| -[AR](README-AR.md) | [CN](README-CN.md) |
| 21 | + </p> |
23 | 22 |
|
24 |
| -</p> |
| 23 | +[AR](README-AR.md) | [CN](README-CN.md) |
25 | 24 |
|
26 | 25 | ## Table of Contents
|
27 | 26 | - [✨ Features](#-features)
|
28 | 27 | - [📦 Installation](#-installation)
|
29 | 28 | - [🚀 Quick Start](#-quick-start)
|
30 | 29 | - [Basic Usage](#basic-usage)
|
31 | 30 | - [Advanced Configuration](#advanced-configuration)
|
| 31 | + - [important warning with json mode](#-deepseek-json-mode-requirement) |
32 | 32 | - [Use with Symfony HttpClient](#use-with-symfony-httpclient)
|
33 | 33 | - [Get Models List](#get-models-list)
|
34 | 34 | - [Function Calling](#function-calling)
|
@@ -100,12 +100,47 @@ $response = $client
|
100 | 100 | ->withStream()
|
101 | 101 | ->setTemperature(1.2)
|
102 | 102 | ->setMaxTokens(8192)
|
| 103 | + ->setResponseFormat('text') // or "json_object" with careful . |
103 | 104 | ->query('Explain quantum computing in simple terms')
|
104 | 105 | ->run();
|
105 | 106 |
|
106 | 107 | echo 'API Response:'.$response;
|
107 | 108 | ```
|
108 | 109 |
|
| 110 | +## ⚠️ DeepSeek JSON Mode Requirement |
| 111 | + |
| 112 | +When using: |
| 113 | + |
| 114 | +```php |
| 115 | +->setResponseFormat('json_object') |
| 116 | +``` |
| 117 | + |
| 118 | +Your prompt **must contain the word `"json"`** in some form. Otherwise, the API will reject the request with the following error: |
| 119 | + |
| 120 | +> `"Prompt must contain the word 'json' in some form to use 'response_format' of type 'json_object'"` |
| 121 | +
|
| 122 | +--- |
| 123 | + |
| 124 | +### 🚫 Incorrect Usage |
| 125 | + |
| 126 | +```php |
| 127 | +->setResponseFormat('json_object') |
| 128 | +->query('Explain quantum computing in simple terms') |
| 129 | +``` |
| 130 | + |
| 131 | +### ✅ Correct Usage |
| 132 | + |
| 133 | +```php |
| 134 | +->setResponseFormat('json_object') |
| 135 | +->query('Respond in valid JSON format. Explain quantum computing in simple terms.') |
| 136 | +``` |
| 137 | + |
| 138 | +> ✅ **Tip**: For best results, also provide a JSON example or explicitly say: |
| 139 | +> *"Respond only in valid JSON."* |
| 140 | +
|
| 141 | + |
| 142 | +--- |
| 143 | + |
109 | 144 | ### Use with Symfony HttpClient
|
110 | 145 | the package already built with `symfony Http client`, if you need to use package with `symfony` Http Client , it is easy to achieve that, just pass `clientType:'symfony'` with `build` function.
|
111 | 146 |
|
|
0 commit comments