Class: Ruby::OpenaiPinecone::Embeddings

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/openai_pinecone/embeddings.rb

Class Method Summary collapse

Class Method Details

.generate(text, model: "text-embedding-ada-002") ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby/openai_pinecone/embeddings.rb', line 8

def self.generate(text, model: "text-embedding-ada-002")
  client = ::OpenAI::Client.new(
    access_token: Ruby::OpenaiPinecone.configuration.openai_api_key,
  )

  response = client.embeddings(
    parameters: {
      input: text,
      model: model
    }
  )

  response["data"][0]["embedding"]
end