|
| 1 | +from collections.abc import AsyncIterator |
| 2 | +from typing import Any, Protocol |
| 3 | + |
| 4 | +from deepset_mcp.api.pipeline.log_level import LogLevel |
| 5 | +from deepset_mcp.api.pipeline.models import ( |
| 6 | + DeepsetPipeline, |
| 7 | + DeepsetSearchResponse, |
| 8 | + DeepsetStreamEvent, |
| 9 | + PipelineList, |
| 10 | + PipelineLogList, |
| 11 | + PipelineValidationResult, |
| 12 | +) |
| 13 | +from deepset_mcp.api.shared_models import NoContentResponse |
| 14 | + |
| 15 | + |
| 16 | +class PipelineResourceProtocol(Protocol): |
| 17 | + """Protocol defining the implementation for PipelineResource.""" |
| 18 | + |
| 19 | + async def validate(self, yaml_config: str) -> PipelineValidationResult: |
| 20 | + """Validate a pipeline's YAML configuration against the API.""" |
| 21 | + ... |
| 22 | + |
| 23 | + async def get(self, pipeline_name: str, include_yaml: bool = True) -> DeepsetPipeline: |
| 24 | + """Fetch a single pipeline by its name.""" |
| 25 | + ... |
| 26 | + |
| 27 | + async def list( |
| 28 | + self, |
| 29 | + page_number: int = 1, |
| 30 | + limit: int = 10, |
| 31 | + ) -> PipelineList: |
| 32 | + """List pipelines in the configured workspace with optional pagination.""" |
| 33 | + ... |
| 34 | + |
| 35 | + async def create(self, name: str, yaml_config: str) -> NoContentResponse: |
| 36 | + """Create a new pipeline with a name and YAML config.""" |
| 37 | + ... |
| 38 | + |
| 39 | + async def update( |
| 40 | + self, |
| 41 | + pipeline_name: str, |
| 42 | + updated_pipeline_name: str | None = None, |
| 43 | + yaml_config: str | None = None, |
| 44 | + ) -> NoContentResponse: |
| 45 | + """Update name and/or YAML config of an existing pipeline.""" |
| 46 | + ... |
| 47 | + |
| 48 | + async def get_logs( |
| 49 | + self, |
| 50 | + pipeline_name: str, |
| 51 | + limit: int = 30, |
| 52 | + level: LogLevel | None = None, |
| 53 | + ) -> PipelineLogList: |
| 54 | + """Fetch logs for a specific pipeline.""" |
| 55 | + ... |
| 56 | + |
| 57 | + async def deploy(self, pipeline_name: str) -> PipelineValidationResult: |
| 58 | + """Deploy a pipeline.""" |
| 59 | + ... |
| 60 | + |
| 61 | + async def search( |
| 62 | + self, |
| 63 | + pipeline_name: str, |
| 64 | + query: str, |
| 65 | + debug: bool = False, |
| 66 | + view_prompts: bool = False, |
| 67 | + params: dict[str, Any] | None = None, |
| 68 | + filters: dict[str, Any] | None = None, |
| 69 | + ) -> DeepsetSearchResponse: |
| 70 | + """Search using a pipeline.""" |
| 71 | + ... |
| 72 | + |
| 73 | + def search_stream( |
| 74 | + self, |
| 75 | + pipeline_name: str, |
| 76 | + query: str, |
| 77 | + debug: bool = False, |
| 78 | + view_prompts: bool = False, |
| 79 | + params: dict[str, Any] | None = None, |
| 80 | + filters: dict[str, Any] | None = None, |
| 81 | + ) -> AsyncIterator[DeepsetStreamEvent]: |
| 82 | + """Search using a pipeline with response streaming.""" |
| 83 | + ... |
0 commit comments