File size: 1,331 Bytes
dbaa71b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Any, List, Optional

from obsei.analyzer.base_analyzer import (
    BaseAnalyzer,
    BaseAnalyzerConfig,
)
from obsei.payload import TextPayload


class DummyAnalyzerConfig(BaseAnalyzerConfig):
    TYPE: str = "Dummy"
    dummy_data: Optional[Any] = None

    def __init__(self, **data: Any):
        super().__init__(**data)


class DummyAnalyzer(BaseAnalyzer):
    def analyze_input(  # type: ignore[override]
        self,
        source_response_list: List[TextPayload],
        analyzer_config: Optional[DummyAnalyzerConfig] = None,
        **kwargs: Any,
    ) -> List[TextPayload]:
        responses = []
        for source_response in source_response_list:

            segmented_data = {
                "dummy_data": None
                if not analyzer_config
                else analyzer_config.dummy_data
            }

            if source_response.segmented_data:
                segmented_data = {**segmented_data, **source_response.segmented_data}

            responses.append(
                TextPayload(
                    processed_text=source_response.processed_text,
                    meta=source_response.meta,
                    source_name=source_response.source_name,
                    segmented_data=segmented_data,
                )
            )

        return responses