ask method

Future<RagAnswer> ask(
  1. String question, {
  2. int? k,
  3. Filter? filter,
  4. List<ChatMessage> history = const [],
  5. int? maxTokens,
})

Answers question from the most relevant chunks.

Implementation

Future<RagAnswer> ask(
  String question, {
  int? k,
  Filter? filter,
  List<ChatMessage> history = const [],
  int? maxTokens,
}) async {
  final sources = await retrieve(question, k: k, filter: filter);
  final included = <RagSource>[];
  final response = await chat.complete(
    buildMessages(question, sources, history: history, included: included),
    system: systemPrompt,
    maxTokens: maxTokens,
  );
  return RagAnswer(response.text, included, response: response);
}