You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that when I use langid in server mode langid -s, and send a request curl -d "q=This is a test" localhost:9008/detect I get an error with json.dumps because of its compatibility with float32.
This error also happens with the original langid code but the repo hasn't been updated for a while.
So, I added a custom encoder to prevent the error, which works well now.
You can find how I changed it in this commit log. master...Aprilistic:py3langid:master
Error log File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/site-packages/py3langid/langid.py", line 352, in application return [json.dumps(response)] ^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type float32 is not JSON serializable
The text was updated successfully, but these errors were encountered:
adbar
linked a pull request
Oct 1, 2024
that will
close
this issue
Hi there!
I found that when I use langid in server mode
langid -s
, and send a requestcurl -d "q=This is a test" localhost:9008/detect
I get an error withjson.dumps
because of its compatibility with float32.This error also happens with the original langid code but the repo hasn't been updated for a while.
So, I added a custom encoder to prevent the error, which works well now.
You can find how I changed it in this commit log.
master...Aprilistic:py3langid:master
Error log
File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/site-packages/py3langid/langid.py", line 352, in application return [json.dumps(response)] ^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/test/lib/python3.12/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type float32 is not JSON serializable
The text was updated successfully, but these errors were encountered: