Skip to main content

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

The contract between an intersyntactic tool and the host that runs it: a tool's schema and run, and the hooks a call reports through.

example/is_tools_api_example.dart

import 'dart:convert';

import 'package:checked_json/checked_json.dart';
import 'package:is_tools_api/is_tools_api.dart';

final echo = ToolSpec(
  name: 'echo',
  description: 'Say the text back.',
  inputSchema: .of({
    'type': 'object',
    'properties': {
      'text': {'type': 'string'},
    },
    'required': ['text'],
  }),
  run: (input, context) async {
    context.onOutput?.call('echoing');
    return input.string('text');
  },
);

Future<void> main() async {
  // What a host sends the model.
  print(jsonEncode(echo.toJson()));

  // What a host does when the model calls the tool.
  final input = JsonObject.decode('{"text": "hello"}');
  final lines = <String>[];
  final reply = await echo.run(input, ToolContext(onOutput: lines.add));
  print('$reply (output: $lines)');
}
0
likes
0
points
963
downloads

Publisher

verified publisherenspyr.co

Weekly Downloads

The contract between an intersyntactic tool and the host that runs it: a tool's schema and run, and the hooks a call reports through.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

checked_json

More

Packages that depend on is_tools_api