parseResponseToStructuredResponse
suspend fun <T> parseResponseToStructuredResponse(response: Message.Assistant, config: StructuredOutputConfig<T>): StructuredResponse<T>(source)
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.