Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit 93695ea

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 82b1f9b + 789fab4 commit 93695ea

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `chatgpt-php` will be documented in this file.
44

5+
## 2.0.0 - 2023-03-31
6+
7+
1. Update stream mode return.
8+
59
## 1.8.0 - 2023-03-26
610

711
Update V1 API and change error thrown.

src/V1.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function ask(
201201
// 流模式下,返回一个生成器
202202
if ($stream) {
203203
$answer = $response->getBody();
204-
while (!$answer->eof()) {
204+
while (! $answer->eof()) {
205205
$raw = Psr7\Utils::readLine($answer);
206206
$line = self::formatStreamMessage($raw);
207207
if (self::checkFields($line)) {
@@ -232,7 +232,7 @@ public function ask(
232232

233233
$line = $this->formatStreamMessage($line);
234234

235-
if (!$this->checkFields($line)) {
235+
if (! $this->checkFields($line)) {
236236
if (isset($line["detail"]) && $line["detail"] === "Too many requests in 1 hour. Try again later.") {
237237
throw new Exception("Rate limit exceeded");
238238
}
@@ -311,7 +311,7 @@ public function getConversations(int $offset = 0, int $limit = 20, $account = 0)
311311
throw new Exception('Response is not json');
312312
}
313313

314-
if (!isset($data['items'])) {
314+
if (! isset($data['items'])) {
315315
throw new Exception('Field missing');
316316
}
317317

src/V2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function ask(string $prompt, string $user = null, bool $stream = false)
117117
// 流模式下,返回一个生成器
118118
if ($stream) {
119119
$answer = $response->getBody();
120-
while (!$answer->eof()) {
120+
while (! $answer->eof()) {
121121
$raw = Psr7\Utils::readLine($answer);
122122
$line = self::formatStreamMessage($raw);
123123
if (self::checkStreamFields($line)) {
@@ -139,7 +139,7 @@ public function ask(string $prompt, string $user = null, bool $stream = false)
139139
throw new Exception('Response is not json');
140140
}
141141

142-
if (!$this->checkFields($data)) {
142+
if (! $this->checkFields($data)) {
143143
throw new Exception('Field missing');
144144
}
145145

0 commit comments

Comments
 (0)