flutter_ai_tools 0.1.0 copy "flutter_ai_tools: ^0.1.0" to clipboard
flutter_ai_tools: ^0.1.0 copied to clipboard

Provider-neutral tool calling for flutter_ai: declare tools with executors, run tool calls into results, and expose web search as a tool — all in pure Dart with no Flutter dependency.

flutter_ai_tools #

Tool calls Confirmation card

Provider-neutral tool calling for the flutter_ai family. Pure Dart, no Flutter dependency.

What it does #

  • ToolSpec — declare a tool (name, description, JSON-Schema parameters) and an optional client-side executor.
  • ToolRegistry — collect tools, hand their definitions to a provider, and run a ToolCallPart into a ToolResultPart. Unknown tools and thrown executors become error results, never crashes.
  • Web searchwebSearchTool(adapter) turns any WebSearchAdapter (Tavily, Brave, SerpAPI, custom) into a callable tool returning SearchResults.

Usage #

final tools = ToolRegistry([
  ToolSpec(
    name: 'get_weather',
    description: 'Get the weather for a city',
    parametersSchema: const {
      'type': 'object',
      'properties': {'city': {'type': 'string'}},
      'required': ['city'],
    },
    execute: (args) => weatherApi.fetch(args['city']! as String),
  ),
]);

// Advertise to a provider:
controller.setTools(tools.definitions);

// Fulfill a call the model made:
final result = await tools.run(toolCallPart); // -> ToolResultPart
final tools = ToolRegistry([webSearchTool(MyTavilyAdapter())]);
class MyTavilyAdapter implements WebSearchAdapter {
  @override
  Future<List<SearchResult>> search(String query, {int? maxResults}) async {
    // call your search backend, map hits into SearchResult
  }
}

Status #

0.1.0. Published on pub.dev; depends on flutter_ai_core. See example/.

0
likes
0
points
289
downloads

Publisher

unverified uploader

Weekly Downloads

Provider-neutral tool calling for flutter_ai: declare tools with executors, run tool calls into results, and expose web search as a tool — all in pure Dart with no Flutter dependency.

Homepage
Repository (GitHub)
View/report issues

Topics

#ai #llm #tool-calling #chat #flutter

License

unknown (license)

Dependencies

flutter_ai_core

More

Packages that depend on flutter_ai_tools