/ src / python / txtai / api / routers / extractor.py
extractor.py
 1  """
 2  Defines API paths for extractor endpoints.
 3  """
 4  
 5  from typing import List, Optional
 6  
 7  from fastapi import APIRouter, Body
 8  
 9  from .. import application
10  from ..route import EncodingAPIRoute
11  
12  router = APIRouter(route_class=EncodingAPIRoute)
13  
14  
15  @router.post("/extract")
16  def extract(queue: List[dict] = Body(...), texts: Optional[List[str]] = Body(default=None)):
17      """
18      Extracts answers to input questions.
19  
20      Args:
21          queue: list of {name: value, query: value, question: value, snippet: value}
22          texts: optional list of text
23  
24      Returns:
25          list of {name: value, answer: value}
26      """
27  
28      return application.get().extract(queue, texts)