Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom PromptLFile type #21

Merged
merged 1 commit into from
Mar 11, 2025
Merged

Custom PromptLFile type #21

merged 1 commit into from
Mar 11, 2025

Conversation

csansoon
Copy link
Contributor

@csansoon csansoon commented Mar 11, 2025

Added a custom opt-in PromptLFile type.

If a user, before rendering a prompt, adapts all of their File parameters to a PromptLFile, using the handy toPromptLFile method, PromptL will automatically insert them as content items of the message with the correct mime type and contents. There is no need for the user to specify any content tags in the prompt!

<user>
    Take a look at this pdf:
    {{ pdf }}
    What it is about?
</user>
const pdf = toPromptLFile({ file, url })
const { messages } = await render({ prompt, parameters: { pdf } })

(Pseudo-code) OUTPUT:

<message role="user">
    <content-text>
        Take a look at this pdf:
    </content-text>

    <content-file mime="application/pdf">
        https://source/file.pdf
    </content-file>

    <content-text>
        What it is about?
    </content-text>
</message>

Additionally, some attributes can be used in the prompt too:

Look at this file: {{ file }}

It should be of type {{ file.type }}, be {{ file.size }}B and hosted at {{ file.url }}

closes: latitude-dev/latitude-llm#959

@neoxelox neoxelox changed the title Custom PromtLFile type Custom PromptLFile type Mar 11, 2025
@csansoon csansoon merged commit 53ff168 into main Mar 11, 2025
2 checks passed
@csansoon csansoon deleted the custom-promptl-files branch March 11, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve PromptL error message for blank values in image and file messages content types.
2 participants