Skip to content

GenerateResult

What generate returns: a whole turn, with the parts it streamed and getters for what callers usually read, as Effect AI’s GenerateTextResponse has for one model response. A turn takes one or more steps, each one response from the model and the tools it called, and the turn’s answer is the text of its last step. generateObject returns GenerateObjectResult, which adds the object that answer decoded to.

Since v0.1.0

What Session.generateObject returns: the turn, and the object its answer decoded to.

Signature

declare class GenerateObjectResult<A> {
constructor(value: A, parts: ReadonlyArray<StreamPart.StreamPart>)
}

Source

Since v0.1.0

The object the turn’s answer decoded to.

Signature

readonly value: A

Source

A whole turn, as Session.generate returns it.

Example (Reading a turn’s answer and what it did)

import { Session } from "@amends-dev/harness"
import { Effect } from "effect"
declare const session: Session.Session
const program = Effect.gen(function* () {
const result = yield* session.generate({
prompt: "Rename the module and update its imports"
})
return {
answer: result.text,
steps: result.steps.length,
changed: result.fileChanges.map((change) => change.path),
reason: result.finishReason
}
})

Signature

declare class GenerateResult {
constructor(parts: ReadonlyArray<StreamPart.StreamPart>)
}

Source

Since v0.1.0

Every part the turn streamed, in order.

Signature

readonly parts: ReadonlyArray<StreamPart.StreamPart>

Source