Class: Appwrite::Embeddings

Inherits:
Service
  • Object
show all
Defined in:
lib/appwrite/services/embeddings.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Embeddings

Returns a new instance of Embeddings.



6
7
8
# File 'lib/appwrite/services/embeddings.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create_text_embeddings(texts:, model: nil) ⇒ EmbeddingList

Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections.

Parameters:

  • texts (Array)

    Array of text to generate embeddings.

  • model (EmbeddingModel) (defaults to: nil)

    The embedding model to use for generating vector embeddings.

Returns:

  • (EmbeddingList)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/appwrite/services/embeddings.rb', line 19

def create_text_embeddings(texts:, model: nil)
    api_path = '/embeddings/text'

    if texts.nil?
      raise Appwrite::Exception.new('Missing required parameter: "texts"')
    end

    api_params = {
        texts: texts,
        model: model,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::EmbeddingList
    )

end