Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/platform/src/Bridge/Voyage/ResultConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public function convert(RawResultInterface $result, array $options = []): Result
throw new RuntimeException('Response does not contain embedding data.');
}

$vectors = array_map(fn (array $data) => new Vector($data['embedding']), $result['data']);

return new VectorResult($vectors[0]);
return new VectorResult(
...array_map(
static fn (array $data) => new Vector($data['embedding']),
$result['data'],
),
);
}
}
3 changes: 2 additions & 1 deletion src/platform/tests/Bridge/Voyage/ResultConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public function testItConvertsMultipleEmbeddings()
$vectorResult = $converter->convert(new RawHttpResult($result));

$this->assertInstanceOf(VectorResult::class, $vectorResult);
// The converter returns only the first vector
$this->assertCount(2, $vectorResult->getContent());
$this->assertSame([0.1, 0.2, 0.3], $vectorResult->getContent()[0]->getData());
$this->assertSame([0.4, 0.5, 0.6], $vectorResult->getContent()[1]->getData());
}

public function testItThrowsExceptionWhenResponseDoesNotContainData()
Expand Down