DocuRAG / Api /app /modules /querySearch /routes /querySearch_route.py
abadesalex's picture
src directory
fe7c659
raw
history blame
1.01 kB
from fastapi import APIRouter, Form, HTTPException
from fastapi.responses import JSONResponse
from sentence_transformers import SentenceTransformer
from transformers import pipeline
from app.modules.querySearch.features.querySearch_feature import QuerySearchFeature
from app.modules.querySearch.controllers.querySearch_controller import (
QuerySearchController,
)
from app.db_local_storage.in_memory_db import query_response_storage
router = APIRouter()
model = SentenceTransformer("paraphrase-MiniLM-L6-v2")
qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
querySearchFeature = QuerySearchFeature(model, qa_pipeline)
querySearchController = QuerySearchController(querySearchFeature)
@router.post("/query_search")
async def handle_query_search(q: str = Form(...)):
return await querySearchController.handle_query_search(q)
@router.get("/get_messages")
async def get_messages():
return JSONResponse(status_code=200, content={"data": query_response_storage})