Spaces:
Running
Running
File size: 1,013 Bytes
819bacd fe7c659 819bacd fe7c659 819bacd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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})
|