foxicution
08/31/2025, 7:35 PMVaibhav (BAML 🐑)
08/31/2025, 7:56 PMfoxicution
09/01/2025, 8:13 AMhtml
<div>
<p>Hello X,<p>
<p>as you can see in the diagram, we still haven't received Y<p>
<img href="some_image.png">Diagram</img>
<br/>
<p>Also, we changed the status for this to HANDLED<p>
<br/>
<img href="some_other_image.png">Item 1</img>
<p>Kind regards,<br/>Y<p>
</div>
To currently use this with baml, our best idea was to
1. Transform the content to markdown
md
Hello X,
as you can see in the diagram, we still haven't received\

Also, we changed the status for this to HANDLED\

Kind regards,
Y
2. And extract all the images as a list of b64 urls
3. The baml function then looks like
baml
function ExtractData(email_body: string, images: image[]) -> ItemInfo[] {
...
prompt #"
...Some prompt
{{ email_body }}
Here are the images
{% for image in images %}
{{ image }}
{% endfor %}
The issue here, is we lose the context, e.g. for Item 1 which status is HANDLED, the AI doesn't see it. We think it would be a lot better, if we could place the images prepositionally in the text, to the same position where they were originally.
We tested having the images and image names together, which helped in the extractions, but working with the raw OpenAI api, and placing the images where they were positionally in the message chain seemed to work even better.foxicution
09/01/2025, 8:19 AMbaml
function ExtractData(email_body: (image | string)[]) -> ItemInfo[] {...}Vaibhav (BAML 🐑)
09/01/2025, 10:20 PM(image | string)[]Vaibhav (BAML 🐑)
09/01/2025, 10:21 PMVaibhav (BAML 🐑)
09/01/2025, 10:21 PM{% for x in body %}...