Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 5471c77

Browse files
committed
refactor!: improve types in platform api
1 parent b75ec68 commit 5471c77

Some content is hidden

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

59 files changed

+428
-225
lines changed

examples/azure/audio-transcript.php

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

2626
$response = $platform->request($model, $file);
2727

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

examples/azure/embeddings.php

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

33
use PhpLlm\LlmChain\Platform\Bridge\Azure\OpenAI\PlatformFactory;
44
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\Embeddings;
5-
use PhpLlm\LlmChain\Platform\Response\VectorResponse;
65
use Symfony\Component\Dotenv\Dotenv;
76

87
require_once dirname(__DIR__, 2).'/vendor/autoload.php';
@@ -28,6 +27,4 @@
2827
country was very peaceful and prosperous. The people lived happily ever after.
2928
TEXT);
3029

31-
assert($response instanceof VectorResponse);
32-
33-
echo 'Dimensions: '.$response->getContent()[0]->getDimensions().\PHP_EOL;
30+
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
@@ -22,4 +22,4 @@
2222
'task' => Task::AUDIO_CLASSIFICATION,
2323
]);
2424

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

examples/huggingface/automatic-speech-recognition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
'task' => Task::AUTOMATIC_SPEECH_RECOGNITION,
2323
]);
2424

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

examples/huggingface/chat-completion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
'task' => Task::CHAT_COMPLETION,
2424
]);
2525

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

examples/huggingface/feature-extraction.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use PhpLlm\LlmChain\Platform\Bridge\HuggingFace\PlatformFactory;
44
use PhpLlm\LlmChain\Platform\Bridge\HuggingFace\Task;
55
use PhpLlm\LlmChain\Platform\Model;
6-
use PhpLlm\LlmChain\Platform\Response\VectorResponse;
76
use Symfony\Component\Dotenv\Dotenv;
87

98
require_once dirname(__DIR__, 2).'/vendor/autoload.php';
@@ -21,6 +20,4 @@
2120
'task' => Task::FEATURE_EXTRACTION,
2221
]);
2322

24-
assert($response instanceof VectorResponse);
25-
26-
echo 'Dimensions: '.$response->getContent()[0]->getDimensions().\PHP_EOL;
23+
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
@@ -20,4 +20,4 @@
2020
'task' => Task::FILL_MASK,
2121
]);
2222

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

examples/huggingface/image-classification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
'task' => Task::IMAGE_CLASSIFICATION,
2323
]);
2424

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

examples/huggingface/image-segmentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
'task' => Task::IMAGE_SEGMENTATION,
2323
]);
2424

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

examples/huggingface/image-to-text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
'task' => Task::IMAGE_TO_TEXT,
2323
]);
2424

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

0 commit comments

Comments
 (0)