Skip to content

Commit c978583

Browse files
Merge pull request #33 from utopia-php/appwrite-embedding-adapter
added agent interface
2 parents 47fb628 + d7ff1c7 commit c978583

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/Agents/Agent.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,25 @@ public function embed(string $text): array
131131

132132
return $this->adapter->embed($text);
133133
}
134+
135+
/**
136+
* Get embeddings for a batch of input texts using underlying adapter (if supported)
137+
*
138+
* @param array<int, string> $texts
139+
* @return array{
140+
* embeddings: array<int, array<int, float>>,
141+
* tokensProcessed: int|null,
142+
* totalDuration: int|null,
143+
* }
144+
*
145+
* @throws \Exception
146+
*/
147+
public function bulkEmbed(array $texts): array
148+
{
149+
if (! $this->adapter->getSupportForEmbeddings()) {
150+
throw new \Exception('This adapter does not support embedding/embedding API.');
151+
}
152+
153+
return $this->adapter->bulkEmbed($texts);
154+
}
134155
}

0 commit comments

Comments
 (0)