parseResponseToStructuredResponse

Parses a structured response from the language model using the specified configuration.

This function takes a response message and a structured output configuration, parses the response content based on the defined structure, and returns a structured response containing the parsed data and the original message.

Return

A structured response containing the parsed data of type T along with the original message.

Parameters

response

The response message from the language model that contains the content to be parsed. The message is expected to match the defined structured output.

config

The configuration defining the expected structure and additional parsing behavior. It includes options such as structure definitions and optional parsers for error handling.