File size: 2,276 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from abc import ABC, abstractmethod
from typing import Any
from typing import List
import warnings


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


# Abstract Interface
class Pipeline(ABC):
    @abstractmethod
    def run_pipeline(self,
                     payload: str,
                     query_inputs: [str],
                     query_types: [str],
                     keywords: [str],
                     query: str,
                     file_path: str,
                     index_name: str,
                     options: List[str] = None,
                     group_by_rows: bool = True,
                     update_targets: bool = True,
                     debug: bool = False,
                     local: bool = True) -> Any:
        pass


# Factory Method
def get_pipeline(agent_name: str) -> Pipeline:
    if agent_name == "llamaindex":
        from rag.agents.llamaindex.llamaindex import LlamaIndexPipeline
        return LlamaIndexPipeline()
    elif agent_name == "haystack":
        from rag.agents.haystack.haystack import HaystackPipeline
        return HaystackPipeline()
    elif agent_name == "vllamaindex":
        from rag.agents.llamaindex.vllamaindex import VLlamaIndexPipeline
        return VLlamaIndexPipeline()
    elif agent_name == "vprocessor":
        from rag.agents.llamaindex.vprocessor import VProcessorPipeline
        return VProcessorPipeline()
    elif agent_name == "fcall":
        from rag.agents.instructor.fcall import FCall
        return FCall()
    elif agent_name == "instructor":
        from rag.agents.instructor.instructor import InstructorPipeline
        return InstructorPipeline()
    elif agent_name == "unstructured-light":
        from rag.agents.unstructured.unstructured_light import UnstructuredLightPipeline
        return UnstructuredLightPipeline()
    elif agent_name == "unstructured":
        from rag.agents.unstructured.unstructured import UnstructuredPipeline
        return UnstructuredPipeline()
    elif agent_name == "sparrow-parse":
        from rag.agents.sparrow_parse.sparrow_parse import SparrowParsePipeline
        return SparrowParsePipeline()
    else:
        raise ValueError(f"Unknown agent: {agent_name}")