Skip to content

Commit 0e1fa49

Browse files
authored
Merge pull request #1 from 5am-code/analysis-e0QjGa
Apply fixes from StyleCI
2 parents 055ab6a + 37ecfc1 commit 0e1fa49

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

database/migrations/2024_04_17_162758_activate_pgvector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44

5-
return new class extends Migration
6-
{
5+
return new class() extends Migration {
76
/**
87
* Run the migrations.
98
*/

database/migrations/2024_04_18_162859_create_embeddings_table.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration
8-
{
7+
return new class() extends Migration {
98
/**
109
* Run the migrations.
1110
*/

src/AdaServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function register()
4343
], 'ada-views');
4444

4545
$this->app->singleton('ada', function () {
46-
return new Ada;
46+
return new Ada();
4747
});
4848

4949
$this->validateIndexClass();
@@ -62,7 +62,7 @@ protected function validateIndexClass()
6262
$indexClass = config('ada.index_class', \Ada\Index\DefaultIndex::class);
6363
$reflection = new \ReflectionClass($indexClass);
6464

65-
if (! $reflection->isSubclassOf(Index::class)) {
65+
if (!$reflection->isSubclassOf(Index::class)) {
6666
throw new Exception("Index class has to implement \Ada\Index\Index.");
6767
}
6868
}

src/Engine/OpenAI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function generate(Prompt $prompt, string $model = 'gpt-3.5-turbo', int $t
4040
{
4141
try {
4242
$result = $this->client->chat()->create([
43-
'model' => $model,
44-
'messages' => $prompt->toArray(),
43+
'model' => $model,
44+
'messages' => $prompt->toArray(),
4545
'temperature' => $temperature,
4646
...$options,
4747
]);

src/Models/Embedding.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function embeddable()
2828
}
2929

3030
/**
31-
* @param string $query The query to lookup.
32-
* @param Prompt|null $contextPrompt The prompt to use for the context, in case a custom template is necessary.
33-
* @param Closure|null $additionalConstraints Limit the lookup by providing a query.
31+
* @param string $query The query to lookup.
32+
* @param Prompt|null $contextPrompt The prompt to use for the context, in case a custom template is necessary.
33+
* @param Closure|null $additionalConstraints Limit the lookup by providing a query.
3434
*
3535
* @throws \Illuminate\Contracts\Container\BindingResolutionException
3636
*/
@@ -65,8 +65,8 @@ public static function lookup(string $query, ?Prompt $contextPrompt = null, ?Clo
6565
}
6666

6767
/**
68-
* @param Vector $vector The vector to compare to
69-
* @param Closure|null $additionalConstraints Limit the search further by providing a query.
68+
* @param Vector $vector The vector to compare to
69+
* @param Closure|null $additionalConstraints Limit the search further by providing a query.
7070
*/
7171
public static function getNearestNeighbor(Vector $vector, ?Closure $additionalConstraints = null): ?Embedding
7272
{

src/Tools/Prompts/OpenAIPrompt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public function toArray(): array
88
{
99
return [
1010
[
11-
'role' => 'system',
11+
'role' => 'system',
1212
'content' => $this->template,
1313
],
1414
[
15-
'role' => 'user',
15+
'role' => 'user',
1616
'content' => $this->query,
1717
],
1818
];

tests/OpenAIEngineTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
->and($response->getContent())->toBe(json_encode([-0.025455512, 0.004357308, -0.023832073]))
2828
->and($response->tokenUsage)->toBe([
2929
'prompt_tokens' => 41,
30-
'total_tokens' => 41,
30+
'total_tokens' => 41,
3131
]);
3232
});
3333

34-
3534
it('creates an GeneratedResponse from a Open AI JSON chat response', function () {
3635
$response = json_decode(file_get_contents('tests/fixtures/openai_200_query.json'), true);
3736

@@ -46,14 +45,13 @@
4645
->and($response->model)->toBe('gpt-3.5-turbo-0125')
4746
->and($response->getContent())->toStartWith("The habitat of the PHP Elephant is referred to as 'Silicon Forests'.")
4847
->and($response->tokenUsage)->toBe([
49-
'prompt_tokens' => 13,
48+
'prompt_tokens' => 13,
5049
'completion_tokens' => 9,
51-
'total_tokens' => 22,
50+
'total_tokens' => 22,
5251
]);
5352
});
5453

5554
it('creates an ErrorResponse from a failed Open AI request', function () {
56-
5755
$exceptionContent = json_decode(file_get_contents('tests/fixtures/openai_failed.json'), true);
5856
$exception = new \OpenAI\Exceptions\ErrorException($exceptionContent, 500);
5957

@@ -63,6 +61,4 @@
6361
->and($response->engine)->toBe(\Ada\Engine\OpenAI::class)
6462
->and($response->success)->toBeFalse()
6563
->and($response->getContent())->toStartWith('Error: Incorrect API key provided: abc.');
66-
67-
6864
});

0 commit comments

Comments
 (0)