The unit of composition: something that answers a program.
Both methods must be implemented, so an executor can be used in a streaming and a non-streaming request alike.
const executor: Executor = { async execute(request, ctx) { return ctx.invoke(upstream, prependSystemPrompt(request, system())); }, async *stream(request, ctx) { yield* ctx.invokeStream(upstream, prependSystemPrompt(request, system())); },}; Copy
const executor: Executor = { async execute(request, ctx) { return ctx.invoke(upstream, prependSystemPrompt(request, system())); }, async *stream(request, ctx) { yield* ctx.invokeStream(upstream, prependSystemPrompt(request, system())); },};
Answers a request in one shot.
Program to answer.
Runtime services and execution identity.
The response program.
Answers a request as a chunk stream.
The response chunks.
The unit of composition: something that answers a program.
Both methods must be implemented, so an executor can be used in a streaming and a non-streaming request alike.
Example