Hi i want to build custom Ai i use python for backend and the framework use flask + flask restful api, when i want to upload file to openai storage the file successfully but the response message i get internal server error 500 heres the error
successfully with ID: file-prCm7Qh9c0ku9Zarv3ersPKu
Response to be sent: {‘message’: ‘File successfully uploaded and analyzed!’, ‘id’: ‘file-prCm7Qh9c0ku9Zarv3ersPKu’, ‘filename’: ‘uploads\SWOT_Analysis.pdf’, ‘object’: ‘file’, ‘analysis’: {‘error’: “Package not found at ‘uploads\SWOT_Analysis.pdf’”, ‘message’: ‘Error while analyzing file content’}}
[2024-08-18 17:42:05,927] ERROR in app: Exception on /uploads [POST]
Traceback (most recent call last):
File “C:\Users\raiha\PycharmProjects\s2iassistants.venv\Lib\site-packages\flask\app.py”, line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\raiha\PycharmProjects\s2iassistants.venv\Lib\site-packages\flask\app.py”, line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\raiha\PycharmProjects\s2iassistants.venv\Lib\site-packages\flask_restful_init_.py”, line 493, in wrapper
return self.make_response(data, code, headers=headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\raiha\PycharmProjects\s2iassistants.venv\Lib\site-packages\flask_restful_init_.py”, line 522, in make_response
resp = self.representations[mediatype](data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\raiha\PycharmProjects\s2iassistants.venv\Lib\site-packages\flask_restful\representations\json.py”, line 21, in output_json
dumped = dumps(data, **settings) + “\n”
^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python312\Lib\json_init_.py”, line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python312\Lib\json\encoder.py”, line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python312\Lib\json\encoder.py”, line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File “C:\Python312\Lib\json\encoder.py”, line 180, in default
raise TypeError(f’Object of type {o.class.name} ’
TypeError: Object of type Response is not JSON serializable
127.0.0.1 - - [18/Aug/2024 17:42:05] “POST /uploads HTTP/1.1” 500 -