Struct ChatMessagePart
One piece of a multi-part message.
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public readonly struct ChatMessagePart
Remarks
Use the factory methods rather than the constructor: they name the fields each kind actually uses, and leave the rest at their neutral values.
Constructors
ChatMessagePart(ChatMessagePartKind, string, string, string, object, bool, int)
Constructs a part. Prefer the factory methods.
Declaration
public ChatMessagePart(ChatMessagePartKind kind, string text = null, string toolCallId = null, string toolName = null, object result = null, bool pending = false, int elapsedMs = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| ChatMessagePartKind | kind | What the piece carries. |
| string | text | The piece's text. |
| string | toolCallId | Identifier joining a call to its result. |
| string | toolName | The tool's name. |
| object | result | What the tool returned. |
| bool | pending | Whether the call is still running. |
| int | elapsedMs | Duration in milliseconds, or a negative value if unmeasured. |
Properties
elapsedMs
Wall-clock duration of the piece, in milliseconds, or unknownDuration.
Declaration
public int elapsedMs { get; }
Property Value
| Type | Description |
|---|---|
| int |
kind
What this piece carries.
Declaration
public ChatMessagePartKind kind { get; }
Property Value
| Type | Description |
|---|---|
| ChatMessagePartKind |
pending
Whether a tool call is still waiting on its result. A call whose result appears later in the same message is reported as finished regardless of what this said.
Declaration
public bool pending { get; }
Property Value
| Type | Description |
|---|---|
| bool |
result
What a tool returned, untyped. Only a ToolResult carries one.
Declaration
public object result { get; }
Property Value
| Type | Description |
|---|---|
| object |
text
The piece's text: the answer for a Text part, the reasoning for a Thinking one, the tool's header line for a ToolCall.
Declaration
public string text { get; }
Property Value
| Type | Description |
|---|---|
| string |
toolCallId
Identifier joining a ToolCall to its ToolResult. Null on the other kinds.
Declaration
public string toolCallId { get; }
Property Value
| Type | Description |
|---|---|
| string |
toolName
The tool's name. Null on the other kinds.
Declaration
public string toolName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Text(string)
Answer text meant for the reader.
Declaration
public static ChatMessagePart Text(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The answer text. |
Returns
| Type | Description |
|---|---|
| ChatMessagePart | The part. |
Thinking(string, int)
A stretch of the agent reasoning.
Declaration
public static ChatMessagePart Thinking(string thinking, int elapsedMs = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | thinking | The reasoning text. |
| int | elapsedMs | Duration in milliseconds, or a negative value if unmeasured. |
Returns
| Type | Description |
|---|---|
| ChatMessagePart | The part. |
ToolCall(string, string, string, bool, int)
The agent invoking a tool.
Declaration
public static ChatMessagePart ToolCall(string toolCallId, string toolName, string text = null, bool pending = false, int elapsedMs = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | toolCallId | Identifier the matching result will carry. |
| string | toolName | The tool's name. |
| string | text | The header line shown in the timeline. Falls back to the tool's name. |
| bool | pending | Whether the call is still running. |
| int | elapsedMs | Duration in milliseconds, or a negative value if unmeasured. |
Returns
| Type | Description |
|---|---|
| ChatMessagePart | The part. |
ToolResult(string, string, object)
What a tool returned.
Declaration
public static ChatMessagePart ToolResult(string toolCallId, string toolName, object result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | toolCallId | Identifier of the call this answers. |
| string | toolName | The tool's name. |
| object | result | The returned payload. |
Returns
| Type | Description |
|---|---|
| ChatMessagePart | The part. |