Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Add date validation to PipeSearchBlueprint and fix gateway depth parsing

Louis Choqueld7a829ea10c9
diff --git a/pipelex/pipe_operators/search/pipe_search_blueprint.py b/pipelex/pipe_operators/search/pipe_search_blueprint.py
index 80cfae88d..f2920e310 100644
--- a/pipelex/pipe_operators/search/pipe_search_blueprint.py
+++ b/pipelex/pipe_operators/search/pipe_search_blueprint.py
@@ -1,5 +1,7 @@
+from datetime import date
from typing import Literal
+from pydantic import field_validator
from typing_extensions import override
from pipelex.cogt.search.search_setting import SearchModelChoice
@@ -24,6 +26,18 @@ class PipeSearchBlueprint(PipeBlueprint):
include_domains: list[str] | None = None
exclude_domains: list[str] | None = None
+ @field_validator("from_date", "to_date", mode="before")
+ @classmethod
+ def validate_date_format(cls, date_value: str | None) -> str | None:
+ if date_value is None:
+ return date_value
+ try:
+ date.fromisoformat(date_value)
+ except ValueError:
+ msg = f"'{date_value}' is not a valid ISO 8601 date (expected YYYY-MM-DD)"
+ raise ValueError(msg) from None
+ return date_value
+
@override
def validate_inputs(self):
template_category = TemplateCategory.BASIC
diff --git a/pipelex/plugins/gateway/gateway_search_worker.py b/pipelex/plugins/gateway/gateway_search_worker.py
index e3399ef43..af9ce074b 100644
--- a/pipelex/plugins/gateway/gateway_search_worker.py
+++ b/pipelex/plugins/gateway/gateway_search_worker.py
@@ -76,7 +76,7 @@ class GatewaySearchWorker(SearchWorkerAbstract):
params = GatewaySearchRequestParams(
query=query,
- depth=SearchDepth(self.inference_model.model_id),
+ depth=SearchDepth(self.inference_model.model_id.rsplit("/", 1)[-1]),
include_images=search_setting.include_images,
include_inline_citations=search_setting.include_inline_citations,
max_results=search_setting.max_results,
@@ -139,7 +139,7 @@ class GatewaySearchWorker(SearchWorkerAbstract):
params = GatewaySearchRequestParams(
query=query,
- depth=SearchDepth(self.inference_model.model_id),
+ depth=SearchDepth(self.inference_model.model_id.rsplit("/", 1)[-1]),
include_images=search_setting.include_images,
include_inline_citations=search_setting.include_inline_citations,
max_results=search_setting.max_results,