Class: SemanticTextChunker::Embedders::Cohere
- Defined in:
- lib/semantic_text_chunker/embedders/cohere.rb
Constant Summary collapse
- BATCH_SIZE =
96- ENDPOINT =
"https://api.cohere.com/v1/embed"
Instance Method Summary collapse
- #embed(texts) ⇒ Object
-
#initialize(api_key:, model: "embed-english-v3.0") ⇒ Cohere
constructor
A new instance of Cohere.
Methods inherited from Base
Constructor Details
#initialize(api_key:, model: "embed-english-v3.0") ⇒ Cohere
Returns a new instance of Cohere.
11 12 13 14 |
# File 'lib/semantic_text_chunker/embedders/cohere.rb', line 11 def initialize(api_key:, model: "embed-english-v3.0") @api_key = api_key @model = model end |
Instance Method Details
#embed(texts) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/semantic_text_chunker/embedders/cohere.rb', line 16 def (texts) texts.each_slice(BATCH_SIZE).flat_map do |batch| response = post(batch) response["embeddings"] || raise(EmbedderError, "No embeddings in response: #{response}") end end |