Skip to main content

extract_assistant_content

Function extract_assistant_content 

Source
pub fn extract_assistant_content(root: &Value) -> Option<String>
Expand description

Extract the assistant’s text content from an LLM API response.

Handles various response formats (tried in order):

  • OpenAI: choices[0].message.content string or array of content blocks
  • Anthropic Messages API: root-level content array with type: "text" blocks
  • output_text field (some providers)