RagSearchTool class
A search tool an LLM can call, described in a provider-neutral shape.
definition is {name, description, parameters}, where parameters is a
JSON Schema object. It is the shape OpenAI's function and Gemini's
function declarations take as is; Anthropic expects the same schema under
input_schema. Pass the model's tool-call arguments to call (decoded) or
callJson (raw string) and send the result back as the tool result.
Citation ids keep counting across calls on one tool, so passages from several searches in a conversation never share an id. Create a new tool for a new conversation.
final tool = RagSearchTool.fromMobileRag(MobileRag.instance);
// Register tool.definition with your LLM client, then on a tool call:
final output = await tool.callJson(toolCall.arguments);
Constructors
-
RagSearchTool({required RagToolSearch search, Future<
List< listSources()?, String name = defaultName, String description = defaultDescription, int defaultTopK = 5, int maxTopK = 10})SourceEntry> > - RagSearchTool.fromCollection(String collectionId, {String name = defaultName, String description = defaultDescription, int defaultTopK = 5, int maxTopK = 10, int tokenBudget = 1500})
-
Like RagSearchTool.fromMobileRag, scoped to the collection
collectionId.factory - RagSearchTool.fromMobileRag(MobileRag rag, {String name = defaultName, String description = defaultDescription, int defaultTopK = 5, int maxTopK = 10, int tokenBudget = 1500})
-
Searches
ragwith hybrid (vector + keyword) search, keeping the returned passages withintokenBudgetengine tokens.factory
Properties
- defaultTopK → int
-
top_kused when the model leaves it out.final -
definition
→ Map<
String, Object?> -
Provider-neutral tool definition:
{name, description, parameters}.no setter - description → String
-
Tells the model when to use the tool.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxTopK → int
-
Largest
top_kthe schema allows; larger requests are clamped to it.final - name → String
-
Tool name the model calls.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Map< String, Object?> arguments) → Future<Map< String, Object?> > -
Runs the search for decoded tool-call
arguments. -
callJson(
String arguments) → Future< String> -
Runs the search for raw JSON
argumentsand returns the JSON result. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultDescription → const String
- defaultName → const String