@@ -417,3 +417,54 @@ async def search_pipeline_with_filters(
417417 return f"Failed to search using pipeline '{ pipeline_name } ': { e } "
418418 except Exception as e :
419419 return f"An unexpected error occurred while searching with pipeline '{ pipeline_name } ': { str (e )} "
420+
421+
422+ async def search_pipeline_with_params (
423+ * ,
424+ client : AsyncClientProtocol ,
425+ workspace : str ,
426+ pipeline_name : str ,
427+ query : str ,
428+ params : dict [str , Any ] | None = None ,
429+ ) -> DeepsetSearchResponse | str :
430+ """Searches using a pipeline with params.
431+
432+ Uses the specified pipeline to perform a search with the given query and params.
433+ Params can be arbitrary parameters to customize the search behavior.
434+ Filters can be used as well under the "filters" key in params.
435+ Filters follow the Haystack filter syntax: https://docs.haystack.deepset.ai/docs/metadata-filtering.
436+ Before executing the search, checks if the pipeline is deployed (status = DEPLOYED).
437+ Returns search results.
438+
439+ :param client: The async client for API communication.
440+ :param workspace: The workspace name.
441+ :param pipeline_name: Name of the pipeline to use for search.
442+ :param query: The search query to execute.
443+ :param params: The parameters to customize the search.
444+
445+ :returns: Search results or error message.
446+ """
447+ try :
448+ # First, check if the pipeline exists and get its status
449+ pipeline = await client .pipelines (workspace = workspace ).get (pipeline_name = pipeline_name )
450+
451+ # Check if pipeline is deployed
452+ if pipeline .status != "DEPLOYED" :
453+ return (
454+ f"Pipeline '{ pipeline_name } ' is not deployed (current status: { pipeline .status } ). "
455+ f"Please deploy the pipeline first using the deploy_pipeline tool before attempting to search."
456+ )
457+
458+ # Execute the search
459+ return await client .pipelines (workspace = workspace ).search (
460+ pipeline_name = pipeline_name , query = query , params = params if params is not None else None
461+ )
462+
463+ except ResourceNotFoundError :
464+ return f"There is no pipeline named '{ pipeline_name } ' in workspace '{ workspace } '."
465+ except BadRequestError as e :
466+ return f"Failed to search using pipeline '{ pipeline_name } ': { e } "
467+ except UnexpectedAPIError as e :
468+ return f"Failed to search using pipeline '{ pipeline_name } ': { e } "
469+ except Exception as e :
470+ return f"An unexpected error occurred while searching with pipeline '{ pipeline_name } ': { str (e )} "
0 commit comments