Class: Responder

Inherits:
Object
  • Object
show all
Defined in:
lib/responder.rb

Instance Method Summary collapse

Constructor Details

#initialize(vector_store:, llm: MistralAPI.new, file:, embedding_creator: MistralEmbeddingCreator.new) ⇒ Responder

Returns a new instance of Responder.



14
15
16
17
18
19
# File 'lib/responder.rb', line 14

def initialize(vector_store:, llm: MistralAPI.new, file:, embedding_creator: MistralEmbeddingCreator.new)
  @vector_store = vector_store
  @llm = llm
  @file = file
  @embedding_creator = embedding_creator
end

Instance Method Details

#call(question, top_k = 10) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/responder.rb', line 21

def call(question, top_k=10)
  embedding = text_to_embedding(question)
  results = process_similarity(question, top_k)
  context = fetch_context(embedding, top_k)
  merged_text = merge_texts(results, context)
  prompt = construct_prompt(question, merged_text)
  generate_response(prompt)
end