Class: LlmMemory::Embeddings::Openai
- Inherits:
-
Object
- Object
- LlmMemory::Embeddings::Openai
- Includes:
- LlmMemory::Embedding, Llms::Openai
- Defined in:
- lib/llm_memory/embeddings/openai.rb
Instance Method Summary collapse
- #embed_document(text, model: "text-embedding-ada-002") ⇒ Object
- #embed_documents(texts, model: "text-embedding-ada-002") ⇒ Object
Methods included from Llms::Openai
Methods included from LlmMemory::Embedding
Instance Method Details
#embed_document(text, model: "text-embedding-ada-002") ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/llm_memory/embeddings/openai.rb', line 26 def (text, model: "text-embedding-ada-002") res = client.( parameters: { model: model, input: text } ) res["data"][0]["embedding"] end |
#embed_documents(texts, model: "text-embedding-ada-002") ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/llm_memory/embeddings/openai.rb', line 12 def (texts, model: "text-embedding-ada-002") = [] texts.each do |txt| res = client.( parameters: { model: model, input: txt } ) .push(res["data"][0]["embedding"]) end end |