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

All three brackets for variables #14465

Merged
merged 3 commits into from
Nov 20, 2024
Merged

All three brackets for variables #14465

merged 3 commits into from
Nov 20, 2024

Conversation

JonasHelming
Copy link
Contributor

@JonasHelming JonasHelming commented Nov 16, 2024

fixed #14464

What it does

Allows to use three brackets for variables in prompts. No mixed formats are allows for consistency

How to test

There are automated test.
To manually test,

  • open the code completion prompt and a code file.
  • Add one bracket to {{textUntilCurrentPosition}}, see how it fails.
  • Add the second bracket to complete {{{textUntilCurrentPosition}}} and see how it works again.
  • Check that the variable is still listed in the AI configuration view then.
  • Check that in the prompt editor, three brackets are valid, but mixtures are an error

Review checklist

Reminder for reviewers

@JonasHelming JonasHelming requested a review from planger November 16, 2024 23:21
@JonasHelming JonasHelming force-pushed the GH14464 branch 2 times, most recently from 3d3edc1 to c20d0a2 Compare November 17, 2024 21:33
Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, interpreting the variables seem to work fine!

However, the syntax highlighting doesn't work for me:
image

Also I have a few comments inline above.

packages/ai-core/data/prompttemplate.tmLanguage.json Outdated Show resolved Hide resolved
packages/ai-core/src/common/prompt-service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this message somehow got lost, readding it:

Nice, thanks for adding additional tests also covering the negative cases now.

I think we may want to avoid duplicating the three tests for the two- and three-bracket cases. This will reduce maintenance effort in the future. I think the following should work (but haven't tested it):

['{{', '{{{'].forEach((openingBrackets, index) => {
    const closingBrackets = openingBrackets.replace(/{/g, '}'); // Replace each `{` with `}`
    it(`should retrieve raw prompt by id (${index + 2} brackets)`, () => {
        const rawPrompt = promptService.getRawPrompt('8');
        expect(rawPrompt?.template).to.equal(`Hello, ${openingBrackets}name${closingBrackets}`);
    });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am no sure about this proposal. I agree that the duplication on the tests might require maintenance (if we ever change this). However, I am not a huge fan of making tests with loops instead of clearly writing them out. I think if the test ever break, it will be much easier to understand the test cases if they are simple.

JonasHelming and others added 2 commits November 19, 2024 22:47
Co-authored-by: Philip Langer <planger@eclipsesource.com>
Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
@JonasHelming
Copy link
Contributor Author

However, the syntax highlighting doesn't work for me

Should be fixed

@JonasHelming JonasHelming requested a review from planger November 19, 2024 23:01
Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revision, works fine now! 👍

@JonasHelming JonasHelming merged commit cf430d5 into master Nov 20, 2024
11 checks passed
@github-actions github-actions bot added this to the 1.56.0 milestone Nov 20, 2024
@sdirix sdirix deleted the GH14464 branch November 20, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Theia AI] Allows three brackets for variables in prompt templates
2 participants