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

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi authored and github-actions[bot] committed Jul 17, 2023
1 parent cdce23a commit b6ceff8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/V1.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ public function ask(
string $prompt,
string $conversationId = null,
string $parentId = null,
$account = null,
$account = null,
bool $stream = false
): Generator
{
): Generator {
// 如果账号为空,则随机选择一个账号
if ($account === null) {
$account = array_rand($this->accounts);
Expand Down Expand Up @@ -220,7 +219,7 @@ public function ask(
// 流模式下,返回一个生成器
if ($stream) {
$data = $response->getBody();
while (!$data->eof()) {
while (! $data->eof()) {
$raw = Psr7\Utils::readLine($data);
$line = self::formatStreamMessage($raw);
if (self::checkFields($line)) {
Expand Down Expand Up @@ -259,7 +258,7 @@ public function ask(

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

if (!$this->checkFields($line)) {
if (! $this->checkFields($line)) {
if (isset($line["detail"]) && $line["detail"] === "Too many requests in 1 hour. Try again later.") {
throw new Exception("Rate limit exceeded");
}
Expand Down Expand Up @@ -322,10 +321,9 @@ public function continueWrite(
string $prompt,
string $conversationId = null,
string $parentId = null,
$account = null,
$account = null,
bool $stream = false
): Generator
{
): Generator {
if ($account === null) {
throw new Exception("Continue write must set account");
} else {
Expand Down Expand Up @@ -383,7 +381,7 @@ public function continueWrite(
// 流模式下,返回一个生成器
if ($stream) {
$data = $response->getBody();
while (!$data->eof()) {
while (! $data->eof()) {
$raw = Psr7\Utils::readLine($data);
$line = self::formatStreamMessage($raw);
if (self::checkFields($line)) {
Expand Down Expand Up @@ -422,7 +420,7 @@ public function continueWrite(

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

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

if (!isset($data['items'])) {
if (! isset($data['items'])) {
throw new Exception('Field missing');
}

Expand Down Expand Up @@ -873,7 +871,7 @@ public function setChatHistoryAndTraining(bool $save, $account = 0): bool
'Referer' => 'https://chat.openai.com/chat',
],
'query' => [
'history_and_training_disabled' => !$save,
'history_and_training_disabled' => ! $save,
],
])->getBody()->getContents();
} catch (GuzzleException $e) {
Expand Down Expand Up @@ -977,7 +975,7 @@ public function getArkoseToken(): string
throw new Exception('Request arkose response is not json');
}

if (!isset($data['token'])) {
if (! isset($data['token'])) {
throw new Exception('Request arkose token failed');
}

Expand Down

0 comments on commit b6ceff8

Please sign in to comment.