Class: SemanticTextChunker::Embedders::OpenRouter
- Defined in:
- lib/semantic_text_chunker/embedders/open_router.rb
Constant Summary collapse
- BATCH_SIZE =
100- ENDPOINT =
"https://openrouter.ai/api/v1/embeddings"
Instance Method Summary collapse
- #embed(texts) ⇒ Object
-
#initialize(api_key:, model: "openai/text-embedding-3-small", site_url: nil, site_name: nil) ⇒ OpenRouter
constructor
A new instance of OpenRouter.
Methods inherited from Base
Constructor Details
#initialize(api_key:, model: "openai/text-embedding-3-small", site_url: nil, site_name: nil) ⇒ OpenRouter
Returns a new instance of OpenRouter.
11 12 13 14 15 16 |
# File 'lib/semantic_text_chunker/embedders/open_router.rb', line 11 def initialize(api_key:, model: "openai/text-embedding-3-small", site_url: nil, site_name: nil) @api_key = api_key @model = model @site_url = site_url || "https://github.com/VladTZY/semantic_text_chunker" @site_name = site_name || "semantic_text_chunker" end |
Instance Method Details
#embed(texts) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/semantic_text_chunker/embedders/open_router.rb', line 18 def (texts) texts.each_slice(BATCH_SIZE).flat_map do |batch| response = post(batch) response["data"].map { |d| d["embedding"] } end end |