File size: 729 Bytes
c674e24
 
22d4865
 
c674e24
22d4865
 
c674e24
6eb1e8c
22d4865
 
 
 
 
63e95b2
22d4865
 
c674e24
22d4865
c674e24
 
22d4865
c674e24
 
63e95b2
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
import torch
from fastapi import Request
from .BaseControllers import BaseControllers
from .SearchControllers import SearchControllers

class SemanticSearchControllers(BaseControllers, SearchControllers):
    def __init__(
        self,
        request: Request,
        limit: int
    ):
        BaseControllers.__init__(self)
        SearchControllers.__init__(self, limit=limit, request=request)
    
    async def search(
        self,
        text_features: torch.tensor
    ):
        search_res = self.client.search(
            collection_name = "text_features",
            query_vector = text_features[0].tolist(),
            limit = self.limit
        )

        return await self.url_response(search_res=search_res)