is_tools_api 0.2.1
is_tools_api: ^0.2.1 copied to clipboard
An intersyntactic tool's definition, as a host offers it to a model: its name, description, input and output, and the types of what a call takes and returns.
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<String, String>(
name: 'echo',
description: 'Say the text back.',
input: .field(Field('text', .string(), description: 'What to say back.')),
output: .text,
);
void main() {
// What a host sends the model, and what it costs in a request.
print(jsonEncode(echo.toJson()));
print('${echo.wireBytes} bytes');
// What the model sent, read as the String the tool takes.
print(echo.input.read(JsonObject.decode('{"text": "hello"}')));
}