File size: 725 Bytes
e68d535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Any, Union, Type, List
import re

# Define regex patterns for each keyword, allowing for flexible spacing and separators
keyword_patterns = [
    r"Fairfield\sCDC",
    r"Fairfield",
]

def scorer_fn(*, index: Union[int, str], node_input: str, node_output: str, **kwargs: Any) -> Union[float, int, bool, str, None]:
    # Check if any of the regex patterns match in the input
    for pattern in keyword_patterns:
        if re.search(pattern, node_output, re.IGNORECASE):
            # If pattern found, check if output is valid JSON
            return 1
    # No patterns found
    return 0

def score_type() -> Type:
    return int

def scoreable_node_types_fn() -> List[str]:
    return ["llm", "chat"]