Class: Deepsearch::Engine::Steps::Rag::Values::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/deepsearch/engine/steps/rag/values/query.rb

Overview

Represents a user query that has been prepared for the RAG process. It enriches the original query text with LLM-generated tags to improve embedding quality and then computes the embedding vector.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:) ⇒ Query

Returns a new instance of Query.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/deepsearch/engine/steps/rag/values/query.rb', line 14

def initialize(text:)
  raise ArgumentError, "Query text cannot be blank" if text.to_s.strip.empty?

  @text = text
  enriched_text = enrich_query_with_tags(text)
  @embedding = RubyLLM.embed(enriched_text).vectors
end

Instance Attribute Details

#embeddingObject (readonly)

Returns the value of attribute embedding.



12
13
14
# File 'lib/deepsearch/engine/steps/rag/values/query.rb', line 12

def embedding
  @embedding
end

#textObject (readonly)

Returns the value of attribute text.



12
13
14
# File 'lib/deepsearch/engine/steps/rag/values/query.rb', line 12

def text
  @text
end