File size: 746 Bytes
42cd5f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from abc import ABC, abstractmethod
import warnings


warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=UserWarning)


# Abstract Interface
class Ingest(ABC):
    @abstractmethod
    def run_ingest(self,
                   payload: str,
                   file_path: str,
                   index_name: str) -> None:
        pass


# Factory Method
def get_ingest(agent_name: str) -> Ingest:
    if agent_name == "llamaindex":
        from .llamaindex import LlamaIndexIngest
        return LlamaIndexIngest()
    elif agent_name == "haystack":
        from .haystack import HaystackIngest
        return HaystackIngest()
    else:
        raise ValueError(f"Unknown agent: {agent_name}")