Skip to content

Commit 117aea9

Browse files
committed
bug #360 [Platform][Voyage] Include all returned vectors rather than just the first (natewiebe13)
This PR was squashed before being merged into the main branch. Discussion ---------- [Platform][Voyage] Include all returned vectors rather than just the first | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | License | MIT When indexing multiple documents, only the first vector was returned, leading to an undefined array key error Commits ------- c8dd053 [Platform][Voyage] Include all returned vectors rather than just the first
2 parents e7bec23 + c8dd053 commit 117aea9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/platform/src/Bridge/Voyage/ResultConverter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ public function convert(RawResultInterface $result, array $options = []): Result
3737
throw new RuntimeException('Response does not contain embedding data.');
3838
}
3939

40-
$vectors = array_map(fn (array $data) => new Vector($data['embedding']), $result['data']);
41-
42-
return new VectorResult($vectors[0]);
40+
return new VectorResult(
41+
...array_map(
42+
static fn (array $data) => new Vector($data['embedding']),
43+
$result['data'],
44+
),
45+
);
4346
}
4447
}

src/platform/tests/Bridge/Voyage/ResultConverterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ public function testItConvertsMultipleEmbeddings()
7474
$vectorResult = $converter->convert(new RawHttpResult($result));
7575

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

8182
public function testItThrowsExceptionWhenResponseDoesNotContainData()

0 commit comments

Comments
 (0)