mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-29 11:09:07 +00:00
fix: invalid escape sequence error in regex pattern (#3902)
This PR fixes the "SyntaxError: invalid escape sequence" error in the pydantic.py file. The issue was caused by the backslashes in the regular expression pattern being treated as escape characters. By using a raw string literal for the regex pattern (e.g., r"\{.*\}"), this fix ensures that backslashes are treated as literal characters, thus preventing the error. Co-authored-by: Tomer Levy <tomer.levy@tipalti.com>
This commit is contained in:
parent
c5c33786a7
commit
9acf80fd69
@ -17,7 +17,7 @@ class PydanticOutputParser(BaseOutputParser[T]):
|
||||
try:
|
||||
# Greedy search for 1st json candidate.
|
||||
match = re.search(
|
||||
"\{.*\}", text.strip(), re.MULTILINE | re.IGNORECASE | re.DOTALL
|
||||
r"\{.*\}", text.strip(), re.MULTILINE | re.IGNORECASE | re.DOTALL
|
||||
)
|
||||
json_str = ""
|
||||
if match:
|
||||
|
Loading…
Reference in New Issue
Block a user