from fastapi import APIRouter, Form, HTTPException from fastapi.responses import JSONResponse # from sentence_transformers import SentenceTransformer # from transformers import pipeline from app.db_local_storage.in_memory_db import query_response_storage from app.modules.querySearch.controllers.querySearch_controller import ( QuerySearchController, ) from app.modules.model import model, qa_pipeline from app.modules.querySearch.features.querySearch_feature import QuerySearchFeature 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})