togethercomputer / together-python

The Official Python Client for Together's API
https://pypi.org/project/together/
Apache License 2.0
38 stars 8 forks source link

Can not print `TogetherException` if is contains non-json objects #108

Open failable opened 6 months ago

failable commented 6 months ago

Describe the bug

Can not print TogetherException if is contains non-json objects.

Screenshots

  File "/Users/user/git/work/ira/project/server/llm/utils.py", line 36, in llm_call
    print(responses)
  File "/Users/user/git/work/ira/project/.venv/lib/python3.10/site-packages/together/error.py", line 35, in __repr__
    repr_message = json.dumps(
  File "/Users/user/.rye/py/cpython@3.10.11/install/lib/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/user/.rye/py/cpython@3.10.11/install/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/user/.rye/py/cpython@3.10.11/install/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/user/.rye/py/cpython@3.10.11/install/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type CIMultiDictProxy is not JSON serializable
error: Recipe `predict` failed on line 20 with exit code 1

Desktop (please complete the following information):

i-khokhlov commented 2 months ago

@orangetin, Hi! I am facing the same bug, during async call with python lib. Do you have some workaround?