RagSearchTool.fromCollection constructor

RagSearchTool.fromCollection(
  1. String collectionId, {
  2. String name = defaultName,
  3. String description = defaultDescription,
  4. int defaultTopK = 5,
  5. int maxTopK = 10,
  6. int tokenBudget = 1500,
})

Like RagSearchTool.fromMobileRag, scoped to the collection collectionId.

The collection is looked up on MobileRag.instance for every call, because a CollectionRag keeps the engine it was created with.

Implementation

factory RagSearchTool.fromCollection(
  String collectionId, {
  String name = defaultName,
  String description = defaultDescription,
  int defaultTopK = 5,
  int maxTopK = 10,
  int tokenBudget = 1500,
}) => RagSearchTool(
  search: (query, topK) => MobileRag.instance
      .inCollection(collectionId)
      .searchHybridWithContext(query, topK: topK, tokenBudget: tokenBudget),
  listSources: () =>
      MobileRag.instance.inCollection(collectionId).listSources(),
  name: name,
  description: description,
  defaultTopK: defaultTopK,
  maxTopK: maxTopK,
);