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

Commit f21f4ad

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents d752331 + c10b471 commit f21f4ad

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

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
$data = $response->getBody();
204-
while (!$data->eof()) {
204+
while (! $data->eof()) {
205205
$raw = Psr7\Utils::readLine($data);
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
@@ -119,7 +119,7 @@ public function ask(string $prompt, string $user = null, bool $stream = false):
119119
// 流模式下,返回一个生成器
120120
if ($stream) {
121121
$data = $response->getBody();
122-
while (!$data->eof()) {
122+
while (! $data->eof()) {
123123
$raw = Psr7\Utils::readLine($data);
124124
$line = self::formatStreamMessage($raw);
125125
if (self::checkStreamFields($line)) {
@@ -141,7 +141,7 @@ public function ask(string $prompt, string $user = null, bool $stream = false):
141141
throw new Exception('Response is not json');
142142
}
143143

144-
if (!$this->checkFields($data)) {
144+
if (! $this->checkFields($data)) {
145145
throw new Exception('Field missing');
146146
}
147147

tests/V2Test.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
$secretKey = getenv('OPENAI_SECRET_KEY');
66
$chatGPT = new V2($secretKey);
7-
$chatGPT->addMessage('You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.',
8-
'system');
7+
$chatGPT->addMessage(
8+
'You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.',
9+
'system'
10+
);
911

1012
it('should get a new conversation', function () use ($chatGPT) {
1113
$return = $chatGPT->ask('Hello, how are you?');

0 commit comments

Comments
 (0)