Skip to content

Commit 49b23c6

Browse files
committed
Run formatter
1 parent b76ed2b commit 49b23c6

6 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/Exceptions/LangGraphException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
class LangGraphException extends Exception
1414
{
1515
protected ?ResponseInterface $response = null;
16+
1617
protected array $responseData = [];
18+
1719
protected ?string $errorType = null;
1820

1921
public function __construct(
@@ -59,6 +61,7 @@ public function getErrorType(): ?string
5961
public function setErrorType(?string $errorType): self
6062
{
6163
$this->errorType = $errorType;
64+
6265
return $this;
6366
}
6467

src/Http/Client.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
class Client
2424
{
2525
private GuzzleClient $client;
26+
2627
private array $config;
28+
2729
private int $retryCount = 0;
2830

2931
public function __construct(array $config = [])
@@ -59,7 +61,7 @@ private function createClient(): GuzzleClient
5961
));
6062

6163
return new GuzzleClient([
62-
'base_uri' => rtrim($this->config['base_url'], '/') . '/',
64+
'base_uri' => rtrim($this->config['base_url'], '/').'/',
6365
'timeout' => $this->config['timeout'],
6466
'connect_timeout' => $this->config['connect_timeout'],
6567
'verify' => $this->config['verify_ssl'],
@@ -220,7 +222,7 @@ public function stream(string $path, string $method = 'GET', array $data = [], a
220222
RequestOptions::STREAM => true,
221223
];
222224

223-
if ($method === 'POST' && !empty($data)) {
225+
if ($method === 'POST' && ! empty($data)) {
224226
$options[RequestOptions::JSON] = $data;
225227
}
226228

@@ -240,7 +242,7 @@ private function parseEventStream(StreamInterface $body): \Generator
240242
{
241243
$buffer = '';
242244

243-
while (!$body->eof()) {
245+
while (! $body->eof()) {
244246
$chunk = $body->read(1024);
245247
if ($chunk === '') {
246248
continue;
@@ -261,7 +263,7 @@ private function parseEventStream(StreamInterface $body): \Generator
261263
}
262264

263265
// Process any remaining buffer
264-
if (!empty($buffer)) {
266+
if (! empty($buffer)) {
265267
$event = $this->parseEventStreamLine($buffer);
266268
if ($event !== null) {
267269
yield $event;
@@ -323,7 +325,7 @@ private function parseResponse(ResponseInterface $response): array
323325

324326
if (json_last_error() !== JSON_ERROR_NONE) {
325327
throw new LangGraphException(
326-
'Failed to decode JSON response: ' . json_last_error_msg(),
328+
'Failed to decode JSON response: '.json_last_error_msg(),
327329
$response->getStatusCode(),
328330
null,
329331
$response

src/LanggraphPlatform.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66

77
use LangGraphPlatform\Http\Client as HttpClient;
88
use LangGraphPlatform\Resources\AssistantsClient;
9-
use LangGraphPlatform\Resources\ThreadsClient;
10-
use LangGraphPlatform\Resources\RunsClient;
119
use LangGraphPlatform\Resources\CronsClient;
10+
use LangGraphPlatform\Resources\RunsClient;
1211
use LangGraphPlatform\Resources\StoreClient;
12+
use LangGraphPlatform\Resources\ThreadsClient;
1313

1414
/**
1515
* Main LangGraph Platform SDK client.
1616
*/
1717
class LangGraphPlatform
1818
{
1919
private HttpClient $httpClient;
20+
2021
private AssistantsClient $assistants;
22+
2123
private ThreadsClient $threads;
24+
2225
private RunsClient $runs;
26+
2327
private CronsClient $crons;
28+
2429
private StoreClient $store;
2530

2631
public function __construct(?array $config = null)
@@ -100,6 +105,7 @@ public function getHttpClient(): HttpClient
100105
public function configure(array $config): self
101106
{
102107
$this->httpClient->configure($config);
108+
103109
return $this;
104110
}
105111

src/LanggraphPlatformServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function registeringPackage(): void
2929
{
3030
// Register the main LangGraph Platform client as a singleton
3131
$this->app->singleton(LangGraphPlatform::class, function ($app) {
32-
return new LangGraphPlatform();
32+
return new LangGraphPlatform;
3333
});
3434

3535
// Bind the client to the container using the interface if needed

src/Resources/RunsClient.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public function search(array $params = []): array
8888
public function stream(string $threadId, array $params, ?callable $callback = null): \Generator
8989
{
9090
$streamParams = array_merge($params, ['stream' => true]);
91-
91+
9292
$stream = $this->httpClient->stream("threads/{$threadId}/runs", 'POST', $streamParams);
93-
93+
9494
foreach ($stream as $event) {
9595
if ($callback !== null) {
9696
$callback($event);
@@ -105,9 +105,9 @@ public function stream(string $threadId, array $params, ?callable $callback = nu
105105
public function streamStateless(array $params, ?callable $callback = null): \Generator
106106
{
107107
$streamParams = array_merge($params, ['stream' => true]);
108-
108+
109109
$stream = $this->httpClient->stream('runs', 'POST', $streamParams);
110-
110+
111111
foreach ($stream as $event) {
112112
if ($callback !== null) {
113113
$callback($event);
@@ -126,7 +126,7 @@ public function wait(string $threadId, array $params, int $pollInterval = 1): ar
126126

127127
while (true) {
128128
$currentRun = $this->get($threadId, $runId);
129-
129+
130130
if (in_array($currentRun['status'], ['success', 'error', 'cancelled', 'failed'])) {
131131
return $currentRun;
132132
}
@@ -146,7 +146,7 @@ public function waitStateless(array $params, int $pollInterval = 1): array
146146
while (true) {
147147
// For stateless runs, we need to check via a different endpoint
148148
$currentRun = $this->getStateless($runId);
149-
149+
150150
if (in_array($currentRun['status'], ['success', 'error', 'cancelled', 'failed'])) {
151151
return $currentRun;
152152
}
@@ -177,12 +177,12 @@ public function join(string $threadId, string $runId): array
177177
public function joinStream(string $threadId, string $runId, ?callable $callback = null): \Generator
178178
{
179179
$stream = $this->httpClient->stream("threads/{$threadId}/runs/{$runId}/stream", 'GET');
180-
180+
181181
foreach ($stream as $event) {
182182
if ($callback !== null) {
183183
$callback($event);
184184
}
185185
yield $event;
186186
}
187187
}
188-
}
188+
}

src/Resources/StoreClient.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function exists(string $namespace, string $key): bool
137137
{
138138
try {
139139
$this->get($namespace, $key);
140+
140141
return true;
141142
} catch (\Exception $e) {
142143
return false;
@@ -156,6 +157,7 @@ public function getMultiple(string $namespace, array $keys): array
156157
$items[$key] = null;
157158
}
158159
}
160+
159161
return $items;
160162
}
161163

@@ -168,6 +170,7 @@ public function putMultiple(string $namespace, array $items): array
168170
foreach ($items as $key => $value) {
169171
$results[$key] = $this->put($namespace, $key, $value);
170172
}
173+
171174
return $results;
172175
}
173176
}

0 commit comments

Comments
 (0)