Spaces:
Running
Running
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) | |
async def handle_query_search(q: str = Form(...)): | |
return await querySearchController.handle_query_search(q) | |
async def get_messages(): | |
return JSONResponse(status_code=200, content={"data": query_response_storage}) | |