Skip to content

Agent

Namespace: Vercel.AI

public sealed class Agent

An agent that calls tools until StopWhen matches. Maps to Agent.

Inheritance: object

View source

public Agent(AgentOptions options, IAiClient? client = null)

Creates an agent. The default stop condition is 10 steps.

Parameters

Name Type Description
options AgentOptions
client IAiClient

View source

public AgentOptions Options { get; }

Agent options.

Value: AgentOptions

View source

GenerateAsync(string, CancellationToken, TimeoutConfiguration?)

Section titled “GenerateAsync(string, CancellationToken, TimeoutConfiguration?)”
public Task<GenerateTextResult> GenerateAsync(string prompt, CancellationToken cancellationToken = default, TimeoutConfiguration? timeout = null)

Generates a reply to <code class=“paramref”>prompt</code>. <code class=“paramref”>timeout</code> replaces Timeout and the timeout that PrepareCall returns for this call. Maps to timeout of generate.

Parameters

Name Type Description
prompt string
cancellationToken CancellationToken
timeout TimeoutConfiguration

Returns: Task<GenerateTextResult>

View source

Stream(string, CancellationToken, AbortSignal?, TimeoutConfiguration?)

Section titled “Stream(string, CancellationToken, AbortSignal?, TimeoutConfiguration?)”
public StreamTextResult Stream(string prompt, CancellationToken cancellationToken = default, AbortSignal? abortSignal = null, TimeoutConfiguration? timeout = null)

Streams a reply to <code class=“paramref”>prompt</code>. <code class=“paramref”>abortSignal</code> aborts the stream and carries the reason. <code class=“paramref”>timeout</code> replaces Timeout and the timeout that PrepareCall returns for this call. Maps to timeout of stream.

Parameters

Name Type Description
prompt string
cancellationToken CancellationToken
abortSignal AbortSignal
timeout TimeoutConfiguration

Returns: StreamTextResult

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product