|
4 | 4 | to EvaluationRow format for use in evaluation pipelines. |
5 | 5 | """ |
6 | 6 |
|
| 7 | +from __future__ import annotations |
| 8 | + |
7 | 9 | import logging |
8 | | -from typing import Any, Callable, Dict, Iterator, List, Optional, Union |
| 10 | +from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Union |
9 | 11 |
|
10 | 12 | from eval_protocol.models import CompletionParams, EvaluationRow, InputMetadata, Message |
11 | 13 |
|
|
20 | 22 | BIGQUERY_AVAILABLE = True |
21 | 23 | except ImportError: |
22 | 24 | BIGQUERY_AVAILABLE = False |
23 | | - logger.warning("Google Cloud BigQuery not installed. Install with: pip install 'eval-protocol[bigquery]'") |
| 25 | + # Optional dependency: avoid noisy warnings during import |
| 26 | + logger.debug("Google Cloud BigQuery not installed. Optional feature disabled.") |
| 27 | + |
| 28 | +# Avoid importing BigQuery types at runtime for annotations when not installed |
| 29 | +if TYPE_CHECKING: |
| 30 | + from google.cloud import bigquery as _bigquery_type |
| 31 | + QueryParameterType = Union[ |
| 32 | + _bigquery_type.ScalarQueryParameter, |
| 33 | + _bigquery_type.ArrayQueryParameter, |
| 34 | + ] |
| 35 | +else: |
| 36 | + QueryParameterType = Any |
24 | 37 |
|
25 | 38 | # Type alias for transformation function |
26 | 39 | TransformFunction = Callable[[Dict[str, Any]], Dict[str, Any]] |
@@ -96,7 +109,7 @@ def __init__( |
96 | 109 | def get_evaluation_rows( |
97 | 110 | self, |
98 | 111 | query: str, |
99 | | - query_params: Optional[List[Union[bigquery.ScalarQueryParameter, bigquery.ArrayQueryParameter]]] = None, |
| 112 | + query_params: Optional[List[QueryParameterType]] = None, |
100 | 113 | limit: Optional[int] = None, |
101 | 114 | offset: int = 0, |
102 | 115 | model_name: str = "gpt-3.5-turbo", |
|
0 commit comments