[Question]: Unexpected Escaping of Characters (Whitespace, Hyphen, etc.) Due to re.escape() in New Version in generate.py
Describe your problem
In the latest version of the code in the agent/componment/generate.py, I noticed that the usage of re.escape() was introduced in the following line: prompt = re.sub(r"{%s}" % n, re.escape(str(v)), prompt)
This results in unwanted behavior where characters like whitespace (" "), hyphen ("-"), and other symbols are unnecessarily escaped, adding additional backslashes (""). In the previous version of the code, this issue did not exist, as the line used to be: prompt = re.sub(r"{%s}" % n, str(v), prompt)
I am wondering what was the reason for adding re.escape() in the new version? Was it to address a specific issue?
I think it should be this:
prompt = re.sub(r"{%s}" % re.escape(n), str(v), prompt)
I think it should be this:
prompt = re.sub(r"{%s}" % re.escape(n), str(v), prompt)
I have tried. It works. Thank you for your great help. I think it need to be updated in the new version.