prepareAsk method

Future<RagAskPrompt> prepareAsk(
  1. String question, {
  2. int topK = 5,
  3. int tokenBudget = 1500,
  4. double? vectorWeight,
  5. double? bm25Weight,
  6. PromptTokenCounter? promptTokenCounter,
  7. RagPromptBuilder buildPrompt = defaultAskPrompt,
})

Searches for question and builds the prompt for an LLM, without calling one. Use it to stream the answer with your own SDK, then pass the complete answer to RagAskPrompt.answer.

Searches like searchHybridWithContext for topK passages within tokenBudget tokens, with the same vectorWeight / bm25Weight as searchHybrid. Citation ids start at 1 for every question. The prompt is empty when nothing was found.

Without promptTokenCounter, tokenBudget counts tokens of the embedding model's tokenizer, not the LLM's. Pass your LLM's token count as promptTokenCounter to count passage texts in its tokens instead; the most relevant passages that fit are kept whole.

Implementation

Future<RagAskPrompt> prepareAsk(
  String question, {
  int topK = 5,
  int tokenBudget = 1500,
  double? vectorWeight,
  double? bm25Weight,
  PromptTokenCounter? promptTokenCounter,
  RagPromptBuilder buildPrompt = defaultAskPrompt,
}) => prepareAskWith(
  _askTool(topK, tokenBudget, vectorWeight, bm25Weight, promptTokenCounter),
  question,
  buildPrompt: buildPrompt,
);