https://www.boundaryml.com logo
🟡 Is it possible (or are there plans) to pass arb...
# questions
f
Is it possible (or are there plans) to pass arbitrary prompts into the functions, or embed baml types inside text? One use-case we have, is passing html content (either websites or emails), and wanting to preserve the location of the images inside the content, for which we haven't found a solution with BAML.
v
Could you outline what you mean?
f
So, imagine i have an email, that does something like (minimal example here, just to assist in understanding):
Copy code
html
<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
Copy code
md
Hello X,
as you can see in the diagram, we still haven't received\
![Diagram]("some_image.png")

Also, we changed the status for this to HANDLED\
![Item 1]("some_other_image.png")

Kind regards,
Y
2. And extract all the images as a list of b64 urls 3. The baml function then looks like
Copy code
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.
Thinking, would it make sense to do something like
Copy code
baml
function ExtractData(email_body: (image | string)[]) -> ItemInfo[] {...}
v
yea in that scenario, you'd have to make the transformation as you stated above.
(image | string)[]
and then just print it via an array
{% for x in body %}...