Skip to content

Commit d76f58e

Browse files
committed
feature #73 refactor!: improve types in platform api (chr-hertel)
This PR was merged into the main branch. Discussion ---------- refactor!: improve types in platform api | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Cherry picking php-llm/llm-chain#376 Commits ------- bfa7cd4 refactor!: improve types in platform api (#376)
2 parents cfd74f3 + bfa7cd4 commit d76f58e

File tree

60 files changed

+484
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+484
-246
lines changed

examples/azure/audio-transcript.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434

3535
$response = $platform->request($model, $file);
3636

37-
echo $response->getContent().\PHP_EOL;
37+
echo $response->asText().\PHP_EOL;

examples/azure/embeddings.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use Symfony\AI\Platform\Bridge\Azure\OpenAI\PlatformFactory;
1313
use Symfony\AI\Platform\Bridge\OpenAI\Embeddings;
14-
use Symfony\AI\Platform\Response\VectorResponse;
1514
use Symfony\Component\Dotenv\Dotenv;
1615

1716
require_once dirname(__DIR__).'/vendor/autoload.php';
@@ -37,6 +36,4 @@
3736
country was very peaceful and prosperous. The people lived happily ever after.
3837
TEXT);
3938

40-
assert($response instanceof VectorResponse);
41-
42-
echo 'Dimensions: '.$response->getContent()[0]->getDimensions().\PHP_EOL;
39+
echo 'Dimensions: '.$response->asVectors()[0]->getDimensions().\PHP_EOL;

examples/huggingface/audio-classification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
'task' => Task::AUDIO_CLASSIFICATION,
3232
]);
3333

34-
dump($response->getContent());
34+
dump($response->asObject());

examples/huggingface/automatic-speech-recognition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
'task' => Task::AUTOMATIC_SPEECH_RECOGNITION,
3232
]);
3333

34-
echo $response->getContent().\PHP_EOL;
34+
echo $response->asText().\PHP_EOL;

examples/huggingface/chat-completion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
'task' => Task::CHAT_COMPLETION,
3333
]);
3434

35-
echo $response->getContent().\PHP_EOL;
35+
echo $response->asText().\PHP_EOL;

examples/huggingface/feature-extraction.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory;
1313
use Symfony\AI\Platform\Bridge\HuggingFace\Task;
1414
use Symfony\AI\Platform\Model;
15-
use Symfony\AI\Platform\Response\VectorResponse;
1615
use Symfony\Component\Dotenv\Dotenv;
1716

1817
require_once dirname(__DIR__).'/vendor/autoload.php';
@@ -30,6 +29,4 @@
3029
'task' => Task::FEATURE_EXTRACTION,
3130
]);
3231

33-
assert($response instanceof VectorResponse);
34-
35-
echo 'Dimensions: '.$response->getContent()[0]->getDimensions().\PHP_EOL;
32+
echo 'Dimensions: '.$response->asVectors()[0]->getDimensions().\PHP_EOL;

examples/huggingface/fill-mask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
'task' => Task::FILL_MASK,
3030
]);
3131

32-
dump($response->getContent());
32+
dump($response->asObject());

examples/huggingface/image-classification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
'task' => Task::IMAGE_CLASSIFICATION,
3232
]);
3333

34-
dump($response->getContent());
34+
dump($response->asObject());

examples/huggingface/image-segmentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
'task' => Task::IMAGE_SEGMENTATION,
3232
]);
3333

34-
dump($response->getContent());
34+
dump($response->asObject());

examples/huggingface/image-to-text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
'task' => Task::IMAGE_TO_TEXT,
3232
]);
3333

34-
echo $response->getContent().\PHP_EOL;
34+
echo $response->asText().\PHP_EOL;

0 commit comments

Comments
 (0)