Skip to content

CREATORS-INDUSTRIES/driver-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crtrs_driver

Dart client for Driver.

dependencies:
  crtrs_driver: ^0.1.0
import 'package:crtrs_driver/crtrs_driver.dart';

final driver = Driver(apiKey: 'dr_...'); // or DRIVER_API_KEY

driver.on('action').listen((ev) => print(ev.tool));

final done = await driver.run('what is https://creators.industries about?');
print(done?.result);

Events: plan, plan_item_start, action, done, fatal. They surface as typed AgentEvents on driver.events (firehose), driver.on(kind) (per-kind stream), and the onEvent callback of run. run completes with the final done event; a fatal event throws a DriverException whose message is the error category only.

Tools

Register local tools the agent can call. The agent runs in the cloud, but the tool runs on your machine — when the agent needs it, the client runs your function locally and sends the result back, then the run continues.

import 'package:crtrs_driver/crtrs_driver.dart';

final weather = defineTool(
  name: 'get_weather',
  description: 'Get the current weather for a city.',
  params: [
    Param('city', type: 'string', description: "city name, e.g. 'Barcelona'"),
    Param('units', type: 'string', description: "'celsius' or 'fahrenheit'"),
  ],
  call: (String city, String units) => fetchWeather(city, units),
);

final driver = Driver(tools: [weather]);
final done = await driver.run('what should I wear in Barcelona today?');

params order is the positional arg order applied to call (its arity should match; defaulted parameters are fine). Subclass Tool instead of defineTool for full control. See example/tool.dart.

MIT

About

Dart library for the Driver API.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages