diff --git a/composer.json b/composer.json index 9833f40..b5b6d79 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,11 @@ { - "name": "sergix44/gradio-client-php", + "name": "doublechen/gradio-client-php", "description": "Gradio client for PHP", "keywords": [ "SergiX44", "gradio-client-php" ], - "homepage": "https://github.com/SergiX44/gradio-client-php", + "homepage": "https://github.com/doublechen/gradio-client-php", "license": "MIT", "authors": [ { diff --git a/src/Client.php b/src/Client.php index a470da8..c900719 100644 --- a/src/Client.php +++ b/src/Client.php @@ -136,7 +136,7 @@ private function preparePayload(array $arguments): array */ private function websocketLoop(Endpoint $endpoint, array $payload): ?Output { - $ws = $this->ws(self::QUEUE_JOIN); + $ws = $this->ws(str_replace('/', '', $this->config->api_prefix).'/'.self::QUEUE_JOIN); while (true) { $data = $ws->receive(); @@ -191,10 +191,10 @@ private function websocketLoop(Endpoint $endpoint, array $payload): ?Output private function sseLoop(Endpoint $endpoint, array $payload, string $protocol, ?int $triggerId): ?Output { if ($protocol === 'sse') { - $getEndpoint = self::QUEUE_JOIN; + $getEndpoint = str_replace('/', '', $this->config->api_prefix).'/'.self::QUEUE_JOIN; } else { - $getEndpoint = self::SSE_QUEUE_DATA; - $response = $this->httpRaw('post', self::QUEUE_JOIN, [ + $getEndpoint = str_replace('/', '', $this->config->api_prefix).'/'.self::SSE_QUEUE_DATA; + $response = $this->httpRaw('post', str_replace('/', '', $this->config->api_prefix).'/'.self::QUEUE_JOIN, [ 'data' => $payload, 'fn_index' => $endpoint->index, 'session_hash' => $this->sessionHash, @@ -239,7 +239,7 @@ private function sseLoop(Endpoint $endpoint, array $payload, string $protocol, ? $message = $this->hydrator->hydrateWithJson(Message::class, $buffer); if ($message instanceof SendData && $protocol === 'sse') { - $sendData = $this->httpRaw('post', self::SSE_QUEUE_DATA, [ + $sendData = $this->httpRaw('post', str_replace('/', '', $this->config->api_prefix).'/'.self::SSE_QUEUE_DATA, [ 'data' => $payload, 'fn_index' => $endpoint->index, 'session_hash' => $this->sessionHash, diff --git a/src/Client/RemoteClient.php b/src/Client/RemoteClient.php index 4a75b1c..e7cf606 100644 --- a/src/Client/RemoteClient.php +++ b/src/Client/RemoteClient.php @@ -43,6 +43,7 @@ public function __construct(string $src, array $httpClientOptions = []) protected function http(string $method, string $uri, array $params = [], array $opt = [], ?string $dto = null) { + $response = $this->httpRaw($method, $uri, $params, $opt); return $this->decodeResponse($response, $dto); diff --git a/src/DTO/Resolvers/MessageResolver.php b/src/DTO/Resolvers/MessageResolver.php index 4eb495c..dc78faa 100644 --- a/src/DTO/Resolvers/MessageResolver.php +++ b/src/DTO/Resolvers/MessageResolver.php @@ -16,7 +16,7 @@ #[\Attribute] class MessageResolver extends ConcreteResolver { - public function concreteFor(array $data): ?string + public function concreteFor(array $data, array $all): ?string { $msg = $data['msg'] ?? throw new InvalidArgumentException('Missing msg key');