예제 #1
0
class GraphQLTestIndexer(Executor):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._docs = DocumentArray()

    @requests(on='/index')
    def index(self, docs: DocumentArray, **kwargs):
        self._docs.extend(docs)

    @requests(on='/search')
    def process(self, docs: DocumentArray, parameters: Dict, **kwargs):
        limit = int(parameters.get('limit', 2))
        docs.match(self._docs, limit=limit)

    @requests(on='/foo')
    def foo(self, docs: DocumentArray, **kwargs):
        docs[0].text = 'foo'

    @requests(on='/bar')
    def bar(self, docs: DocumentArray, **kwargs):
        docs[0].text = 'bar'

    @requests(on='/target-exec')
    def target_exec(self, docs: DocumentArray, **kwargs):
        docs[0].text = 'Indexer'
예제 #2
0
 def embed(self, docs: DocumentArray, **kwargs):
     docs.embeddings = np.random.random([len(docs), 10]).astype(np.float32)
예제 #3
0
 def process(self, docs: DocumentArray, parameters: Dict, **kwargs):
     limit = int(parameters.get('limit', 2))
     docs.match(self._docs, limit=limit)
예제 #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self._docs = DocumentArray()