Open jimkring opened 1 week ago
I think adding the format specifier should be easy. Something like this:
from mirascope.core import prompt_template
@prompt_template(
"""
First Part {text:text} Third Part
"""
)
def prompt(text: str): ...
print(prompt("Second Part")
# > [BaseMessageParam(role='user', content=[TextPart(type='text', text='First Part'), TextPart(type='text', text='Second Part'), TextPart(type='text', text='Third Part')])]
We could even add the analogous {:texts}
:
from mirascope.core import prompt_template
@prompt_template("{texts:texts}")
def prompt(texts: str): ...
print(prompt(["First Part", "Second Part"])
# > [BaseMessageParam(role='user', content=[TextPart(type='text', text='First Part'), TextPart(type='text', text='Second Part')])]
I've added this to the v1.7
milestone and will try to get this out for the release on Friday :)
Unfortunately didn't get to this in time for the v1.7
release, but will shoot to get this out as part of the next release hopefully.
Description
Continuing this thread, I would like to have the input data of my user messages kept separate from the prompt template string itself. My use case is that I am storing all of the messages and message parts, and having the structured (JSON) data for the various input fields kept separate from the unstructured prompt string data is helpful, since it makes it easier to extract and work with later. For example, we have an Assistant API we are implementing and need to be able to traverse the message/conversation history. We don't want to have to parse inside of unstructured text content to find structured data -- that's why keeping the structured separate is very helpful.