Verba icon indicating copy to clipboard operation
Verba copied to clipboard

type object 'GeneratePayload' has no attribute 'model_validate_json'

Open wccyzxy opened this issue 2 years ago • 2 comments

Error:

✘ WebSocket Error: type object 'GeneratePayload' has no attribute
'model_validate_json'
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/output/Verba/goldenverba/server/api.py", line 597, in websocket_generate_stream
    payload = GeneratePayload.model_validate_json(data)
AttributeError: type object 'GeneratePayload' has no attribute 'model_validate_json'

Solution:

# api.py
import json

# change the code in line 597
payload = GeneratePayload.parse_obj(json.loads(data))

wccyzxy avatar Jan 27 '24 05:01 wccyzxy

Experiencing the same problem..

WebSocket Error: type object 'GeneratePayload' has no attribute
'model_validate_json'
ERROR:    Exception in ASGI application
Traceback (most recent call last):
 File "/Users/sai.praneeth/work/rag_ab/Verba/goldenverba/server/api.py", line 596, in websocket_generate_stream
   payload = GeneratePayload.model_validate_json(data)
AttributeError: type object 'GeneratePayload' has no attribute 'model_validate_json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 240, in run_asgi
   result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
   return await self.app(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/fastapi/applications.py", line 292, in __call__
   await super().__call__(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
   await self.middleware_stack(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/middleware/errors.py", line 149, in __call__
   await self.app(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/middleware/cors.py", line 75, in __call__
   await self.app(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
   raise exc
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
   await self.app(scope, receive, sender)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
   raise e
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
   await self.app(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
   await route.handle(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/routing.py", line 341, in handle
   await self.app(scope, receive, send)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/routing.py", line 82, in app
   await func(session)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/fastapi/routing.py", line 324, in app
   await dependant.call(**values)
 File "/Users/sai.praneeth/work/rag_ab/Verba/goldenverba/server/api.py", line 613, in websocket_generate_stream
   await websocket.send_json(
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/site-packages/starlette/websockets.py", line 171, in send_json
   text = json.dumps(data, separators=(",", ":"))
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/json/__init__.py", line 238, in dumps
   **kw).encode(obj)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/json/encoder.py", line 199, in encode
   chunks = self.iterencode(o, _one_shot=True)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/json/encoder.py", line 257, in iterencode
   return _iterencode(o, 0)
 File "/Users/sai.praneeth/.pyenv/versions/3.10.0/lib/python3.10/json/encoder.py", line 179, in default
   raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AttributeError is not JSON serializable
  • Followed instructions to install using git clone, within venv
  • provided all the necessary api keys etc within .env
  • Tested with both .md, .pdf files

saaipraneeth avatar May 03 '24 02:05 saaipraneeth

This might be a problem regarding pydantic, what pydantic version are you currently running?

thomashacker avatar May 15 '24 17:05 thomashacker