https://www.boundaryml.com logo
🟡 Programmatically Generate Parsed Prompt Based o...
# questions
z
Hey team, just curious if there's any plan to add a way to programmatically generate a parsed prompt based on a function call with params. Something like this:
Copy code
generated_prompt = b.prompt.FunctionToRun(some_param, other_param=other_param, baml_options={'tb': tb, 'collector': coll})
generated_prompt
would be something like an array of parsed prompt components, e.g.
Copy code
[
  {
    "role": "system",
    "content_type": "text",
    "content": "system prompt text"
  }, 
  {
    "role": "user",
    "content_type": "text",
    "content": "parsed user prompt text here"
  },
  {
    "role": "user",
    "content_type": "pdf_base64",
    "content": "<base64_string>"
  }
]
I feel like some intermediate format like this has to already exist (what is the content of the Preview tab in the VSCode extension created from?) but just isn't exposed at this point, but I might be way off. Regardless, if something like this isn't planned or in the works, I'm gonna write some gross code that generates something similar from
b.request.FunctionToRun(*params).http_request.body.json()
. I say gross since it'll be a bunch of hard-coded logic for each provider's specific request format. 🙂
v
z
My description was probably crap, but my prompts are pretty wild and use a lot of dynamic types and params. It'd be a fruitless effort trying to track all of that to assemble my own final parsed/hydrated version of the prompt that would get sent to the model API. To keep it simple, I'd love to be able to programmatically get the parsed prompt for a given function with parameters. Essentially exactly the content that gets shown on the Preview tab of the VSCode extension.
v
ah, yo ucan do that via the modular api here! we can work on a render option for a type builder type tho!
thats a great call out here
2 Views