Skip to content

PromptInput

Namespace: Vercel.AI.Prompt

public sealed class PromptInput

The prompt of a call: a user string or a list of messages. Maps to prompt: string | ModelMessage[].

Inheritance: object

View source

public IReadOnlyList<ModelMessage>? Messages { get; }

The messages, when the prompt is a message list.

Value: IReadOnlyList<ModelMessage>

View source

public string? Text { get; }

The user text, when the prompt is a string.

Value: string

View source

public static PromptInput From(IReadOnlyList<ModelMessage> messages)

Creates a prompt from a message list.

Parameters

Name Type Description
messages IReadOnlyList<ModelMessage>

Returns: PromptInput

View source

public static PromptInput From(string text)

Creates a prompt from a user string.

Parameters

Name Type Description
text string

Returns: PromptInput

View source

public static implicit operator PromptInput(string text)

Converts a string to a prompt.

Parameters

Name Type Description
text string

Returns: PromptInput

View source

implicit operator PromptInput(ModelMessage[])

Section titled “implicit operator PromptInput(ModelMessage[])”
public static implicit operator PromptInput(ModelMessage[] messages)

Converts an array of messages to a prompt.

Parameters

Name Type Description
messages ModelMessage\[\]

Returns: PromptInput

View source

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