pub fn construct_structured_response<'py>(
py: Python<'py>,
text: String,
output_model: Option<&Bound<'py, PyAny>>,
) -> Result<Bound<'py, PyAny>, UtilError>Expand description
Helper function to extract result from LLM response text If an output model is provided, it will attempt to convert the text to the structured output using the provided model. If no model is provided, it will attempt to convert the response to an appropriate Python type directly.
§Arguments
py- A Python interpreter instancetext- The text to be converted (typically from an LLM response)output_model- An optional bound python object representing the output model
§Returns
Result<Bound<'py, PyAny>, UtilError>- A result containing the structured output or an error