Agent
Namespace: Vercel.AI
public sealed class AgentAn agent that calls tools until StopWhen matches. Maps to Agent.
Inheritance: object
Constructors
Section titled “Constructors”Agent(AgentOptions, IAiClient?)
Section titled “Agent(AgentOptions, IAiClient?)”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 |
Properties
Section titled “Properties”Options
Section titled “Options”public AgentOptions Options { get; }Agent options.
Value: AgentOptions
Methods
Section titled “Methods”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>
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
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product