diff --git a/pyproject.toml b/pyproject.toml index 735468fa..427acf6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "docq" -version = "0.13.7" +version = "0.13.8" description = "Docq.AI - Your private ChatGPT alternative. Securely unlock knowledge from confidential documents." authors = ["Docq.AI Team "] maintainers = ["Docq.AI Team "] diff --git a/web/api/rag_completion_handler.py b/web/api/rag_completion_handler.py index e276321f..678c0e1d 100644 --- a/web/api/rag_completion_handler.py +++ b/web/api/rag_completion_handler.py @@ -104,6 +104,8 @@ def post(self: Self) -> None: except ValueError as e: logging.error("ValueError:", e) raise HTTPError(400, reason=f"Bad request. {e}", log_message=str(e)) from e + except HTTPError as e: + raise e except Exception as e: logging.error("Exception:", e) raise HTTPError(500, reason="Internal server error", log_message=str(e)) from e diff --git a/web/api/spaces_handler.py b/web/api/spaces_handler.py index e8ff9e8b..9ad4a622 100644 --- a/web/api/spaces_handler.py +++ b/web/api/spaces_handler.py @@ -96,6 +96,10 @@ def get(self: Self) -> None: spaces_response_model = SpacesResponseModel(response=space_model_list) self.write(spaces_response_model.model_dump(by_alias=True)) + except ValidationError as e: + raise HTTPError(400, reason="Bad request") from e + except HTTPError as e: + raise e except Exception as e: logging.error("Error: ", e) raise HTTPError(500, reason="Internal server error", log_message=f"Error: {str(e)}") from e diff --git a/web/api/threads_handler.py b/web/api/threads_handler.py index 646b905d..3ca8fbe3 100644 --- a/web/api/threads_handler.py +++ b/web/api/threads_handler.py @@ -129,6 +129,10 @@ def get(self: Self, feature_: FEATURE, thread_id: int) -> None: except ValidationError as e: raise HTTPError(status_code=400, reason="Bad request", log_message=str(e)) from e + except HTTPError as e: + raise e + except Exception as e: + raise HTTPError(status_code=500, reason="Internal server error", log_message=str(e)) from e @authenticated def delete(self: Self, feature_: FEATURE, thread_id: str) -> None: @@ -171,6 +175,7 @@ def get(self: Self, feature_: FEATURE, thread_id: str) -> None: try: thread = rq.list_thread_history(feature, int(thread_id)) + if not len(thread) > 0: raise HTTPError(status_code=404, reason="Thread not found") @@ -187,6 +192,8 @@ def get(self: Self, feature_: FEATURE, thread_id: str) -> None: except ValidationError as e: print("ValidationError: ", e) raise HTTPError(status_code=400, reason="Invalid page or limit") from e + except HTTPError as e: + raise e except Exception as e: raise HTTPError(status_code=500, reason="Internal server error") from e