Skip to content

Commit e7be456

Browse files
committed
feature #547 [Store] Support \Stringable in VectorizerInterface::vectorize (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [Store] Support `\Stringable` in `VectorizerInterface::vectorize` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | -- | License | MIT Allow string|\Stringable parameter type for the vectorize method to support objects implementing Stringable interface. Commits ------- 6e1894b [Store] Support `\Stringable` in `VectorizerInterface::vectorize`
2 parents c85a4bc + 6e1894b commit e7be456

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/store/src/Document/Vectorizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public function vectorizeTextDocuments(array $documents): array
6767
return $vectorDocuments;
6868
}
6969

70-
public function vectorize(string $string): Vector
70+
public function vectorize(string|\Stringable $string): Vector
7171
{
72-
$this->logger->debug('Vectorizing string', ['string' => $string]);
72+
$this->logger->debug('Vectorizing string', ['string' => (string) $string]);
7373

74-
$result = $this->platform->invoke($this->model, $string);
74+
$result = $this->platform->invoke($this->model, (string) $string);
7575
$vectors = $result->asVectors();
7676

7777
if (!isset($vectors[0])) {

src/store/src/Document/VectorizerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface VectorizerInterface
2929
public function vectorizeTextDocuments(array $documents): array;
3030

3131
/**
32-
* Vectorizes a single string into a Vector.
32+
* Vectorizes a single string or Stringable object into a Vector.
3333
*/
34-
public function vectorize(string $string): Vector;
34+
public function vectorize(string|\Stringable $string): Vector;
3535
}

0 commit comments

Comments
 (0)