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

Add additional backslash to escapedPrompt #215

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rahmaniaam
Copy link
Contributor

Problem

Chat prompts with a sequence of multiple backslashes will result in backslashes to be gone in the prompt card

Input example:

Make a regex that get '\\(' occurrences on string

Make a regex that get \\( occurrences on string

Make a regex that get\\( occurrences on string

Make a regex that get \\(occurrences on string

Make a regex that get '\\\(' occurrences on string

Make a regex that get '\\' occurrences on string

Make a regex that get \\ occurrences on string

Make a regex that get \' occurrences on string

Make a regex that get '\ occurrences on string

Result:
Screenshot 2024-12-24 at 15 37 00

Solution

Add regex logic in the escaped prompt to add an additional backslash on sequences of backslashes

Result:
Screenshot 2024-12-24 at 15 35 24

Tests

  • I have tested this change on VSCode
  • I have tested this change on JetBrains

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Jurredr
Copy link
Contributor

Jurredr commented Dec 24, 2024

Nice fix with the regex, seems to work as expected. Just wondering; do we know what exactly is the root cause of this? Is there not something we can do to prevent it in the first place, rather than patching it up with a replacement?

@rahmaniaam
Copy link
Contributor Author

Just wondering; do we know what exactly is the root cause of this? Is there not something we can do to prevent it in the first place, rather than patching it up with a replacement?

From what I can tell, it doesn't seem that the escapeHTML function successfully interpret the backslashes resulting in the card to render incorrectly, we may need to use a different library

@rahmaniaam
Copy link
Contributor Author

This needs more work, playing around with escaping backticks is still messing it up:

Input

Make a regex that get `\``\\(``` occurrences on string

or

Make a regex that get ```\\(``\` occurrences on string

Output

Make a regex that get ```\(``` occurrences on string

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.

2 participants