pub async fn ask_json(
model: &(dyn BaseChatModel + Send + Sync),
prompt: &str,
system_prompt: &str,
) -> Result<Option<Value>, RunnableError>Expand description
Ask the LLM a single prompt and get back a parsed JSON value.
This combines three steps that are repeated in every “structured output” node:
- Call
stream_llmwith a raw prompt (no state extraction) - Extract the response text
- Parse JSON (stripping markdown fences if present)
Returns None when the response is not valid JSON.
§Example
ⓘ
let plan = ask_json(model, "Create a plan in JSON format", "").await;