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

Allows comments in prompt templates #14470

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Allows comments in prompt templates #14470

merged 2 commits into from
Nov 20, 2024

Conversation

JonasHelming
Copy link
Contributor

This should be reviewed first: #14465

fixed #14469

What it does

Allows comments in prompt templates

  • Comments must start in the first line only, but can then be multile lines
  • Comments are {{!-- comment --}}

How to test

There are automated tests.

Manual test:
Add comments and observe no effect on:

  • LLM requests
  • Variable detection in the AI configuration view

Check comments are highlighted correctly in the prompt editor:
image

Review checklist

Reminder for reviewers

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.

Nice, works pretty well! I don't approve it yet, because it is based on another PR that hasn't been approved yet and I want to avoid accidentally merging the other commit.

Code looks good! I just have a few general thoughts that me might want to address:

image

Line 7 above:
The syntax highlighting shows the content of line 7 as comment, whereas in reality it isn't. This might be confusing.

Line 6 above:
It doesn't show the comment-like string as a comment, however, due to the similar begin and end delimiters to variables, it highlights this false comment as a variable. This again might be a bit confusing. Maybe it'd be better to choose a different sequence of characters for comments, to avoid this overlap and false highlighting.

@JonasHelming
Copy link
Contributor Author

I will check this once #14465 is done, as it needs to be tested in combination

@JonasHelming
Copy link
Contributor Author

Line 6 above:
It doesn't show the comment-like string as a comment, however, due to the similar begin and end delimiters to variables, it highlights this false comment as a variable. This again might be a bit confusing. Maybe it'd be better to choose a different sequence of characters for comments, to avoid this overlap and false highlighting.

This is actually expected. This was a trade off. {{!-- is a very common pattern in template engines. Also we take less characters away for regular usage in prompts. So if {{!-- occurs somewhere not in the first line, it is indeed treated as a variable.

The other issue should be fixed now

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, looks good to me! 👍

@JonasHelming JonasHelming merged commit 8f293ed into master Nov 20, 2024
11 checks passed
@github-actions github-actions bot added this to the 1.56.0 milestone Nov 20, 2024
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] Allow comments in prompt templates
2 participants