mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Clean API chat router. Move FeedbackData response type to router helper
This commit is contained in:
parent
e6eb87bbb5
commit
1a83bbcc94
2 changed files with 8 additions and 11 deletions
|
@ -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.online_search import read_webpages, search_online
|
||||||
from khoj.processor.tools.run_code import run_code
|
from khoj.processor.tools.run_code import run_code
|
||||||
from khoj.routers.api import extract_references_and_questions
|
from khoj.routers.api import extract_references_and_questions
|
||||||
|
from khoj.routers.email import send_query_feedback
|
||||||
from khoj.routers.helpers import (
|
from khoj.routers.helpers import (
|
||||||
ApiImageRateLimiter,
|
ApiImageRateLimiter,
|
||||||
ApiUserRateLimiter,
|
ApiUserRateLimiter,
|
||||||
|
@ -39,13 +40,13 @@ from khoj.routers.helpers import (
|
||||||
CommonQueryParams,
|
CommonQueryParams,
|
||||||
ConversationCommandRateLimiter,
|
ConversationCommandRateLimiter,
|
||||||
DeleteMessageRequestBody,
|
DeleteMessageRequestBody,
|
||||||
|
FeedbackData,
|
||||||
agenerate_chat_response,
|
agenerate_chat_response,
|
||||||
aget_relevant_information_sources,
|
aget_relevant_information_sources,
|
||||||
aget_relevant_output_modes,
|
aget_relevant_output_modes,
|
||||||
construct_automation_created_message,
|
construct_automation_created_message,
|
||||||
create_automation,
|
create_automation,
|
||||||
extract_relevant_info,
|
extract_relevant_info,
|
||||||
extract_relevant_summary,
|
|
||||||
generate_excalidraw_diagram,
|
generate_excalidraw_diagram,
|
||||||
generate_summary_from_files,
|
generate_summary_from_files,
|
||||||
get_conversation_command,
|
get_conversation_command,
|
||||||
|
@ -82,10 +83,6 @@ conversation_command_rate_limiter = ConversationCommandRateLimiter(
|
||||||
|
|
||||||
api_chat = APIRouter()
|
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)
|
@api_chat.get("/conversation/file-filters/{conversation_id}", response_class=Response)
|
||||||
@requires(["authenticated"])
|
@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)
|
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")
|
@api_chat.post("/feedback")
|
||||||
@requires(["authenticated"])
|
@requires(["authenticated"])
|
||||||
async def sendfeedback(request: Request, data: FeedbackData):
|
async def sendfeedback(request: Request, data: FeedbackData):
|
||||||
|
|
|
@ -1273,6 +1273,12 @@ class DeleteMessageRequestBody(BaseModel):
|
||||||
turn_id: str
|
turn_id: str
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackData(BaseModel):
|
||||||
|
uquery: str
|
||||||
|
kquery: str
|
||||||
|
sentiment: str
|
||||||
|
|
||||||
|
|
||||||
class ApiUserRateLimiter:
|
class ApiUserRateLimiter:
|
||||||
def __init__(self, requests: int, subscribed_requests: int, window: int, slug: str):
|
def __init__(self, requests: int, subscribed_requests: int, window: int, slug: str):
|
||||||
self.requests = requests
|
self.requests = requests
|
||||||
|
|
Loading…
Reference in a new issue