From 1a83bbcc945d2138bc7932d07bee20ce731a783c Mon Sep 17 00:00:00 2001 From: Debanjum Date: Fri, 1 Nov 2024 17:31:43 -0700 Subject: [PATCH] Clean API chat router. Move FeedbackData response type to router helper --- src/khoj/routers/api_chat.py | 13 ++----------- src/khoj/routers/helpers.py | 6 ++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 7aacf9db..a20982ea 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -31,6 +31,7 @@ from khoj.processor.speech.text_to_speech import generate_text_to_speech from khoj.processor.tools.online_search import read_webpages, search_online from khoj.processor.tools.run_code import run_code from khoj.routers.api import extract_references_and_questions +from khoj.routers.email import send_query_feedback from khoj.routers.helpers import ( ApiImageRateLimiter, ApiUserRateLimiter, @@ -39,13 +40,13 @@ from khoj.routers.helpers import ( CommonQueryParams, ConversationCommandRateLimiter, DeleteMessageRequestBody, + FeedbackData, agenerate_chat_response, aget_relevant_information_sources, aget_relevant_output_modes, construct_automation_created_message, create_automation, extract_relevant_info, - extract_relevant_summary, generate_excalidraw_diagram, generate_summary_from_files, get_conversation_command, @@ -82,10 +83,6 @@ conversation_command_rate_limiter = ConversationCommandRateLimiter( api_chat = APIRouter() -from pydantic import BaseModel - -from khoj.routers.email import send_query_feedback - @api_chat.get("/conversation/file-filters/{conversation_id}", response_class=Response) @requires(["authenticated"]) @@ -147,12 +144,6 @@ def remove_file_filter(request: Request, filter: FileFilterRequest) -> Response: return Response(content=json.dumps(file_filters), media_type="application/json", status_code=200) -class FeedbackData(BaseModel): - uquery: str - kquery: str - sentiment: str - - @api_chat.post("/feedback") @requires(["authenticated"]) async def sendfeedback(request: Request, data: FeedbackData): diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index d3de3aad..990fa33f 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -1273,6 +1273,12 @@ class DeleteMessageRequestBody(BaseModel): turn_id: str +class FeedbackData(BaseModel): + uquery: str + kquery: str + sentiment: str + + class ApiUserRateLimiter: def __init__(self, requests: int, subscribed_requests: int, window: int, slug: str): self.requests = requests