basic-tools-exp

command
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This sample is basic-tools, written against the in-preview tools API in genkit/exp. It is slated to replace the one basic-tools uses in the next major version, so the two are worth reading side by side: same rollout, same flow, same chart, and the differences are all API.

The tool function takes a plain context.Context rather than *ai.ToolContext, and the runtime helpers in ai/exp/tool do the rest:

  • tool.AttachParts attaches the chart, so the tool returns a plain *Rollout instead of an *ai.MultipartToolResponse. The signature stops having to announce that the tool sometimes has more to say.
  • tool.SendPartial streams structured progress while the rollout runs, so a slow tool does not look like a hang.
  • tool.SendChunk streams a chunk the tool builds itself, for an update that is a line of prose rather than a value.

The two streaming helpers are best-effort: with a caller that is not streaming they are no-ops, so the tool still works when nobody is listening, and the returned *Rollout is always the authoritative answer. Neither is written to history, since progress is for showing, not for the model to read.

Run it:

go run .

Or with the Dev UI, which renders the attached chart and keeps a trace of the whole rollout at http://localhost:4000/traces:

curl -sL cli.genkit.dev | bash    # install the Genkit CLI, once
genkit start -- go run .

Or over HTTP. Streaming needs ?stream=true, otherwise the progress goes nowhere and only the final report comes back:

curl -N -X POST 'http://localhost:8080/deployFlow?stream=true' \
  -H "Content-Type: application/json" \
  -d '{"data": {"request": "Ship checkout-api to production."}}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL