mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-01 04:29:09 +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:
|
try:
|
||||||
# Greedy search for 1st json candidate.
|
# Greedy search for 1st json candidate.
|
||||||
match = re.search(
|
match = re.search(
|
||||||
"\{.*\}", text.strip(), re.MULTILINE | re.IGNORECASE | re.DOTALL
|
r"\{.*\}", text.strip(), re.MULTILINE | re.IGNORECASE | re.DOTALL
|
||||||
)
|
)
|
||||||
json_str = ""
|
json_str = ""
|
||||||
if match:
|
if match:
|
||||||
|
Loading…
Reference in New Issue
Block a user