Method: Langchain::Vectorsearch::Milvus#ask
- Defined in:
- lib/langchain/vectorsearch/milvus.rb
#ask(question:, k: 4) {|String| ... } ⇒ String
Ask a question and return the answer
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/langchain/vectorsearch/milvus.rb', line 144 def ask(question:, k: 4, &block) search_results = similarity_search(query: question, k: k) content_data = search_results.dig("data").map { |result| result.dig("content") } context = content_data.join("\n---\n") prompt = generate_rag_prompt(question: question, context: context) = [{role: "user", content: prompt}] response = llm.chat(messages: , &block) response.context = context response end |