Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Move OasstApiClient & OasstError to oasst_shared, parse Oasst standard exception

Open andreaskoepf opened this issue 2 years ago • 1 comments
trafficstars

!! wait for changes of https://github.com/LAION-AI/Open-Assistant/pull/216 to be integrated

  1. OasstApiClient which is currently part of the discord bot should be moved to oasst_shared to be used by different python frontends (e.g. later text-frontend, testing etc.)
  2. The exception class used in the server code OasstError should be moved to oasst_shared and all locations that currently import oasst_backend.exceptions have to be patched, e.g. to oasst_shared.exceptions.
  3. The OA server supplies an error code + status message when standard OasstErrors happen. Instead of just using response.raise_for_status() the OaastApiCient should check (e.g. in post()) if the response (for non 2XX http status cases) contains a standard OASST JSON object (with message and error_code fields) and if so raise a corresponding OasstError exception (including the http-status and Oasst-error code).

Json serialization of OasstError:

404 Error: Not Found

Response body:

{
  "message": "Task for task_id=UUID('3fa85f64-5717-4562-b3fc-2c9a3f66afa6') not found",
  "error_code": 2100
}

Response headers:

 content-length: 103
 content-type: application/json
 

andreaskoepf avatar Jan 01 '23 16:01 andreaskoepf

Happy to take a crack at this. Feel free to assign to me

jack-michaud avatar Jan 01 '23 18:01 jack-michaud

Step 1 & 2 are done in #287 and #289. Waiting to get them merged to work on step 3.

jack-michaud avatar Jan 02 '23 20:01 jack-michaud

Step 1 & 2 are done in #287 and #289. Waiting to get them merged to work on step 3.

merged now :)

yk avatar Jan 02 '23 21:01 yk

Step 3 is ready to go in #300

jack-michaud avatar Jan 03 '23 02:01 jack-michaud