-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[TheiaAi] Support referencing prompt fragments via variable #14985
base: master
Are you sure you want to change the base?
[TheiaAi] Support referencing prompt fragments via variable #14985
Conversation
Per discussion with @JonasHelming : The current implementation does not yet consider that the Thus, function references in prompt fragments should not be resolved in order to be resolved later when the fragments parent (i.e. a user chat input or a system prompt) is resolved. This needs to consider that functions are referenced differently in prompts ( |
Adds a new AI variable that resolves registered prompt templates based on their ID. The variable resolves to the resolved prompt template. I.e. variables and functions in the template are already resolved in the returned value. In the chat a prompt template with ID myprompt is referenced as #prompt:myprompt Adds prompt template id autocompletion for the chat window that triggers on entering the variable separator `:`
- different icon vor custom prompts - sort custom prompts first - add detail text specifying whether a prompt is built-in or custom - internationalize texts
Marks the prompt variable as a context variable. This adds the referenced prompt template to the context.
Functions must not be immediately resolved in prompt fragments because function objects are lost this way. Instead, they are left in and resolved when the final chat message or prompt containing the prompt fragment is resolved. - Extend PromptService with getPromptFragment method that resolves variables but not functions - ChatRequestParser can now handle chat and prompt function formats
This allows to resolve function references that are part of a resolved variable, e.g. a prompt fragment
d4c4b0f
to
009aeff
Compare
The PR is currently on hold due to issues with parsing functions of resolved variables in chat messages. See #14899 (comment) for more details |
What it does
Prompt fragments allow to define parts of prompts in a reusable way. You can embed these prompts then via a variable in the chat or in our prompt templates. This also allows to have a set of prompts available in the chat without always defining a custom agent.
This PR defines a Theia Ai variable
prompt
with an argument containing the prompt fragment's id. The variable is fully resolved including variables and function calls in the fragment.This also adds auto completion for available custom and builtin prompt fragments to the chat UI.
The variable is defined as a context variable meaning it is added to the chat context similar to referenced files. This was discussed here: #14899 (comment)
Note that agents need to be adapted to use this from the context as explained here: #14787 (comment)
This is not part of this PR.
prompt-template-autocomplete.webm
Part of #14899
How to test
Ai-features › Prompt Templates: Prompt Templates Folder
to point to a folder of your choosing.prompttemplate
file in the specified folder.What id does
)Follow-ups
Step 2 of #14899 implementing settings UI and editing for prompt fragments
Breaking changes
Attribution
Review checklist
Reminder for reviewers