Clean API chat router. Move FeedbackData response type to router helper

This commit is contained in:
Debanjum 2024-11-01 17:31:43 -07:00
parent e6eb87bbb5
commit 1a83bbcc94
2 changed files with 8 additions and 11 deletions

View file

@ -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):

View file

@ -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