trait MapsMessages

Traits

Methods

array
mapMessagesToChat(array $messages, string|null $instructions = null)

Map the given Hypervel messages to Chat Completions messages format.

void
mapUserMessage(UserMessage|Message $message, array $chatMessages)

Map a user message to Chat Completions format.

void
mapAssistantMessage(AssistantMessage|Message $message, array $chatMessages)

Map an assistant message, replaying its reasoning details with its tool calls.

void
mapToolResultMessage(ToolResultMessage|Message $message, array $chatMessages)

Map a tool result message to Chat Completions format.

array
serializeToolCallToChat(ToolCall $toolCall)

Serialize a tool call DTO to Chat Completions array format.

string
mapToolCallId(string $id)

Map a tool call or result ID to the provider's wire format.

Details

protected array mapMessagesToChat(array $messages, string|null $instructions = null)

Map the given Hypervel messages to Chat Completions messages format.

Parameters

array $messages
string|null $instructions

Return Value

array

protected void mapUserMessage(UserMessage|Message $message, array $chatMessages)

Map a user message to Chat Completions format.

Parameters

UserMessage|Message $message
array $chatMessages

Return Value

void

at line 20
protected void mapAssistantMessage(AssistantMessage|Message $message, array $chatMessages)

Map an assistant message, replaying its reasoning details with its tool calls.

Parameters

AssistantMessage|Message $message
array $chatMessages

Return Value

void

protected void mapToolResultMessage(ToolResultMessage|Message $message, array $chatMessages)

Map a tool result message to Chat Completions format.

Parameters

ToolResultMessage|Message $message
array $chatMessages

Return Value

void

protected array serializeToolCallToChat(ToolCall $toolCall)

Serialize a tool call DTO to Chat Completions array format.

Parameters

ToolCall $toolCall

Return Value

array

protected string mapToolCallId(string $id)

Map a tool call or result ID to the provider's wire format.

Parameters

string $id

Return Value

string