Skip to content

Operator discover

OperatorDiscoverOperator

Bases: Operator

Operator discover operator that searches for operators

Attributes:

Name Type Required Default Description
search_query str "" Text to search for in operator names and descriptions
approximate bool True Whether to use approximate (vector) search
hybrid bool False Whether to use hybrid search (text + vector)
limit int -1 Max number of results to return (-1 = unlimited)
page int 0 Page number for pagination
page_size int 10 Number of results per page (default: 10, max: 100)
include_metadata bool False Whether to include metadata in results (description and properties always included)
threshold float 0.5 Similarity threshold for filtering results (0.0-1.0, lower = more similar; applies to approximate/hybrid search)
progressive_pagination bool False Whether to use progressive pagination for approximate/hybrid search (searches all pages until threshold exceeded)
Source code in blue/operators/operator_discover.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
class OperatorDiscoverOperator(Operator):
    """
    Operator discover operator that searches for operators

    Attributes:
    ----------
    | Name                   | Type  | Required | Default | Description                                                                                          |
    |------------------------|-------|----------|---------|------------------------------------------------------------------------------------------------------|
    | `search_query`           | str   | :fontawesome-solid-circle-check: {.green-check}     | ""      | Text to search for in operator names and descriptions                                               |
    | `approximate`            | bool  | :fontawesome-solid-circle-check: {.green-check}     | True    | Whether to use approximate (vector) search                                                          |
    | `hybrid`                 | bool  |     | False   | Whether to use hybrid search (text + vector)                                                        |
    | `limit`                  | int   |     | -1      | Max number of results to return (-1 = unlimited)                                                    |
    | `page`                   | int   |     | 0       | Page number for pagination                                                                          |
    | `page_size`              | int   |     | 10      | Number of results per page (default: 10, max: 100)                                                 |
    | `include_metadata`       | bool  |     | False   | Whether to include metadata in results (description and properties always included)                |
    | `threshold`              | float |     | 0.5     | Similarity threshold for filtering results (0.0-1.0, lower = more similar; applies to approximate/hybrid search) |
    | `progressive_pagination` | bool  |     | False   | Whether to use progressive pagination for approximate/hybrid search (searches all pages until threshold exceeded) |


    """

    PROPERTIES = {}

    name = "operator_discover"
    description = "Discovers operators using the operator registry"
    default_attributes = {
        "search_query": {"type": "str", "description": "Text to search for in operator names and descriptions", "required": True, "default": ""},
        "approximate": {"type": "bool", "description": "Whether to use approximate (vector) search", "required": True, "default": True},
        "hybrid": {"type": "bool", "description": "Whether to use hybrid search (text + vector)", "required": False, "default": False},
        "limit": {"type": "int", "description": "Max number of results to return (-1, unlimited)", "required": False, "default": -1},
        "page": {"type": "int", "description": "Page number for pagination", "required": False, "default": 0},
        "page_size": {"type": "int", "description": "Number of results per page (default: 10, max: 100)", "required": False, "default": 10},
        "include_metadata": {"type": "bool", "description": "Whether to include metadata in results (description and properties always included)", "required": False, "default": False},
        "threshold": {
            "type": "float",
            "description": "Similarity threshold for filtering results (0.0-1.0, lower = more similar, only applies to approximate/hybrid search)",
            "required": False,
            "default": 0.5,
        },
        "progressive_pagination": {
            "type": "bool",
            "description": "Whether to use progressive pagination for approximate/hybrid search (searches all pages until threshold exceeded)",
            "required": False,
            "default": False,
        },
    }

    def __init__(self, description: str = None, properties: Dict[str, Any] = None):
        super().__init__(
            self.name,
            function=operator_discover_operator_function,
            description=description or self.description,
            properties=properties,
            validator=operator_discover_operator_validator,
            explainer=operator_discover_operator_explainer,
        )

    def _initialize_properties(self):
        super()._initialize_properties()

        # attribute definitions
        self.properties["attributes"] = self.default_attributes

operator_discover_operator_explainer(output, input_data, attributes)

Explain operator discover operator output.

Source code in blue/operators/operator_discover.py
153
154
155
156
157
158
159
160
161
def operator_discover_operator_explainer(output: Any, input_data: List[List[Dict[str, Any]]], attributes: Dict[str, Any]) -> Dict[str, Any]:
    """Explain operator discover operator output."""
    operator_discover_explanation = {
        'output': output,
        'input_data': input_data,
        'attributes': attributes,
        'explanation': f"operator discover operator searched for operators with query '{attributes.get('search_query', '')}' and returned {len(output[0]) if output and len(output) > 0 else 0} results.",
    }
    return operator_discover_explanation

operator_discover_operator_validator(input_data, attributes, properties=None)

Validate operator discover operator attributes.

Source code in blue/operators/operator_discover.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
def operator_discover_operator_validator(input_data: List[List[Dict[str, Any]]], attributes: Dict[str, Any], properties: Dict[str, Any] = None) -> bool:
    """Validate operator discover operator attributes."""
    try:
        if not default_operator_validator(input_data, attributes, properties):
            return False
    except Exception:
        return False

    # Check required attributes, the type of the attributes is validated by the default operator validator
    search_query = attributes.get('search_query', '')
    page = attributes.get('page', 0)
    page_size = attributes.get('page_size', 10)
    threshold = attributes.get('threshold', 0.5)

    if not search_query or not search_query.strip():
        return False
    if page < 0 or page_size <= 0:
        return False
    if threshold < 0 or threshold > 1:
        return False

    return True
Last update: 2025-10-09