https://www.boundaryml.com logo
🟡 Issue with BAML PDF summarization prompt
# questions
k
I'm trying out BAML, and I've been unable to get a simple PDF summarization prompt working. Is there something I'm missing? I get
It looks like you mentioned a PDF, but I don't see an attached file. Please upload the PDF document you'd like summarized, and I'll be happy to help!
when I run the test.
Copy code
function ExtractFromPdf(testPdf: pdf) -> string {
  client ResponsesClient
  prompt #"
    {{ _.role("user") }}

    Summarize the PDF

    {{ testPdf }}
  "#
}

test TestName {
  functions [ExtractFromPdf]
  args {
    testPdf { url "https://arxiv.org/pdf/2305.08675" }
  }
}

---

client<llm> ResponsesClient {
  provider "openai-responses"
  options {
    model "gpt-4.1"
    api_key env.OPENAI_API_KEY
  }
}
p
Hi @Kyori, that's a common issue when you first begin with BAML. You forgot to include {{ ctx.output_format }} before your user message. That is what tells BAML what it needs to output.
Also, I'd put the "Summarize the PDF" outside the user message too. It would be part of the system message. The way you write your prompt and the order on which you place things influences the actual prompt that BAML formulates for the LLM.
k
Copy code
class Summary {
  summaryText string
}

function ExtractFromPdf(testPdf: pdf) -> Summary {
  client ResponsesClient
  prompt #"
    Summarize the PDF

    {{ ctx.output_format }}

    {{ _.role("user") }}

    {{ testPdf }}
  "#
}

test TestName {
  functions [ExtractFromPdf]
  args {
    testPdf { url "https://arxiv.org/pdf/2305.08675" }
  }
}
produces the following curl
Copy code
curl -X POST 'https://api.openai.com/v1/responses' -H "authorization: Bearer $OPENAI_API_KEY" -H "content-type: application/json" -d "{
  \"model\": \"gpt-4.1\",
  \"input\": \"system: Summarize the PDF\n\nAnswer in JSON using this schema:\n{\n  summaryText: string,\n}\nuser: \"
}"
with the response
It appears you haven't uploaded a PDF file. Please upload the PDF you'd like summarized, and I will respond with the summary in JSON format.
The PDF is displaying correctly in the playground https://cdn.discordapp.com/attachments/1410268576853790760/1410278299883671614/Screenshot_2025-08-27_at_10.01.59_AM.png?ex=68b06f84&is=68af1e04&hm=4bb30ff6d8f3066c7fb4d097b2f748fe2c6271427f65441c1f101f1957b0123d&
p
Ah ok, my bad, may be something to do with the pdf function in BAML then.
b
There's a bug in openai-responses w.r.t. multimodal inputs that we'll be releasing today!