Skip to content

Commit 6e4b619

Browse files
JordanDaltongithub-actions[bot]
authored andcommitted
Fix styling
1 parent c094c9f commit 6e4b619

13 files changed

+29
-40
lines changed

config/ai.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'max_tokens' => env('ANTHROPIC_MAX_TOKENS', 1000),
1515
'temperature' => env('ANTHROPIC_TEMPERATURE', 0.7),
1616
],
17-
]
17+
],
1818
],
1919

2020
'providers' => [
@@ -27,6 +27,6 @@
2727
'openai' => [
2828
'driver' => 'openai',
2929
'base_url' => env('OPENAI_BASE_URL', 'https://api.openai.com/v1'),
30-
]
31-
]
30+
],
31+
],
3232
];

src/AiManager.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public function getDefaultDriver()
1414

1515
public function createAnthropicDriver(): AnthropicDriver
1616
{
17-
$llm = $this->config->get('ai.llms.claude');
17+
$llm = $this->config->get('ai.llms.claude');
1818
$provider = $this->config->get('ai.providers.anthropic');
1919

2020
return new AnthropicDriver($llm, $provider);
2121
}
22-
}
22+
}

src/AiProviders/Anthropic/Actions/CreateMessage.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
class CreateMessage
99
{
10-
public function __construct(public AnthropicDriver $driver, public array $payload = [])
11-
{
12-
13-
}
10+
public function __construct(public AnthropicDriver $driver, public array $payload = []) {}
1411

1512
public static function make(AnthropicDriver $driver, array $payload = []): CreateMessage
1613
{
@@ -26,7 +23,7 @@ public function model(): string
2623
{
2724
$default = data_get($this->driver->llm, 'model');
2825

29-
return $this->value( 'model', $default);
26+
return $this->value('model', $default);
3027
}
3128

3229
public function value($key, $default = null)
@@ -51,7 +48,7 @@ public function temperature(): float
5148

5249
public function system(): ?string
5350
{
54-
return $this->value( 'system');
51+
return $this->value('system');
5552
}
5653

5754
public function stream(): bool
@@ -61,7 +58,7 @@ public function stream(): bool
6158

6259
public function messages(): array
6360
{
64-
return $this->value( 'messages', []);
61+
return $this->value('messages', []);
6562
}
6663

6764
public function payload(): array
@@ -75,7 +72,7 @@ public function payload(): array
7572
'model' => $this->model(),
7673
'max_tokens' => $this->maxTokens(),
7774
'temperature' => $this->temperature(),
78-
'messages' => $this->messages()
75+
'messages' => $this->messages(),
7976
];
8077

8178
return $required + $optional;
@@ -87,4 +84,4 @@ public function execute(): CreateMessageResponse
8784

8885
return CreateMessageResponse::make($response);
8986
}
90-
}
87+
}

src/AiProviders/Anthropic/AnthropicDriver.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
class AnthropicDriver
1313
{
14-
public function __construct(public array $llm, public array $provider)
15-
{
16-
17-
}
14+
public function __construct(public array $llm, public array $provider) {}
1815

1916
public static function make(array $llm, array $provider)
2017
{
@@ -34,8 +31,8 @@ public function apiVersion(): ?string
3431
public function client(): PendingRequest
3532
{
3633
return Http::acceptJson()->withHeaders([
37-
'x-api-key' => $this->apiKey(),
38-
'anthropic-version' => $this->apiVersion()
34+
'x-api-key' => $this->apiKey(),
35+
'anthropic-version' => $this->apiVersion(),
3936
]);
4037
}
4138

@@ -78,4 +75,4 @@ public function validateInput(string $input, string $prompt): AnthropicResponse
7875

7976
return ValidateRuleResponse::make($response->response());
8077
}
81-
}
78+
}

src/AiProviders/Anthropic/Responses/AnthropicResponse.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace JordanDalton\LaravelAI\AiProviders\Anthropic\Responses;
44

5-
interface AnthropicResponse
6-
{
7-
}
5+
interface AnthropicResponse {}

src/AiProviders/Anthropic/Responses/CreateMessageResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ public function errorMessage(): ?string
8080
{
8181
return $this->error() ? 'AI Provider Error' : null;
8282
}
83-
}
83+
}

src/AiProviders/Anthropic/Responses/ValidateRuleResponse.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace JordanDalton\LaravelAI\AiProviders\Anthropic\Responses;
44

5-
65
class ValidateRuleResponse extends CreateMessageResponse
76
{
87
public function decoded()
@@ -19,4 +18,4 @@ public function errorMessage(): string
1918
{
2019
return $this->decoded()->message;
2120
}
22-
}
21+
}

src/AiServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace JordanDalton\LaravelAI;
44

5+
use JordanDalton\LaravelAI\Commands\SkeletonCommand;
56
use Spatie\LaravelPackageTools\Package;
67
use Spatie\LaravelPackageTools\PackageServiceProvider;
7-
use JordanDalton\LaravelAI\Commands\SkeletonCommand;
88

99
class AiServiceProvider extends PackageServiceProvider
1010
{
1111
public function boot()
1212
{
13-
$this->app->singleton('ai', fn($app) => new AiManager($app));
13+
$this->app->singleton('ai', fn ($app) => new AiManager($app));
1414
}
1515

1616
public function configurePackage(Package $package): void

src/Rules/AiRule.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
2424
{
2525
$validation = $this->driver->validateInput($value, $this->prompt);
2626

27-
if($validation->failed())
28-
{
27+
if ($validation->failed()) {
2928
$fail(":attribute: {$validation->errorMessage()}");
3029
}
3130
}

tests/Drivers/AnthropicDriverTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
use Illuminate\Support\Facades\Http;
44

5-
it('should create message using anthropic driver', function(){
5+
it('should create message using anthropic driver', function () {
66

77
$response = getFixtureAsArray('Anthropic/Messages.Create.Simple.json');
88

99
Http::fake([
10-
'*' => Http::response($response)
10+
'*' => Http::response($response),
1111
]);
1212

1313
$response = app('ai')->driver('anthropic')->createMessage();
@@ -30,4 +30,4 @@
3030
->toBeArray();
3131
//dd($response->json());
3232

33-
});
33+
});

tests/ManagerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
it('resolves default driver out of container', function(){
3+
it('resolves default driver out of container', function () {
44

55
expect(app('ai')->getDefaultDriver())->toBe('anthropic');
66

7-
});
7+
});

tests/Pest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
uses(TestCase::class)->in(__DIR__);
66

7-
87
function getFixture($name): string
98
{
10-
return file_get_contents(__DIR__ . '/Fixtures/' . $name);
9+
return file_get_contents(__DIR__.'/Fixtures/'.$name);
1110
}
1211

1312
function getFixtureAsArray($name): array
1413
{
1514
return json_decode(getFixture($name), true);
16-
}
15+
}

tests/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace JordanDalton\LaravelAI\Tests;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6-
use Orchestra\Testbench\TestCase as Orchestra;
76
use JordanDalton\LaravelAI\AiServiceProvider;
7+
use Orchestra\Testbench\TestCase as Orchestra;
88

99
class TestCase extends Orchestra
1010
{

0 commit comments

Comments
 (0)