mirror of https://github.com/hwchase17/langchain
Patch: improve openai functions call parser compatibility (#15197)
```shell Python 3.11.6 (main, Nov 2 2023, 04:39:43) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> s = {'name': 'gc', 'arguments': '{"prompt":"hi\nbob."}'} >>> import json >>> json.loads(s['arguments']) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) ^^^^^^^^^^^^^^^^^^^^^^ json.decoder.JSONDecodeError: Invalid control character at: line 1 column 14 (char 13) >>> json.loads(s['arguments'].replace('\n', '\\n')) {'prompt': 'hi\nbob.'} >>> ``` --------- Co-authored-by: Nuno Campos <nuno@langchain.dev>pull/15293/head
parent
bf5385592e
commit
507c195a4b
Loading…
Reference in New Issue