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.

docs: add PipeSearch operator and SearchResult to docs & builder (#733)

Louis Choquelab8b9dd8ec41
diff --git a/.pipelex/inference/backends.toml b/.pipelex/inference/backends.toml
index 6d9a3dca7..08e993c27 100644
--- a/.pipelex/inference/backends.toml
+++ b/.pipelex/inference/backends.toml
@@ -58,6 +58,11 @@ display_name = "Hugging Face"
enabled = true
api_key = "${HF_TOKEN}"
+[linkup]
+display_name = "Linkup"
+enabled = true
+api_key = "${LINKUP_API_KEY}"
+
[mistral]
display_name = "Mistral AI"
enabled = true
diff --git a/.pipelex/inference/backends/linkup.toml b/.pipelex/inference/backends/linkup.toml
new file mode 100644
index 000000000..9ff7d159f
--- /dev/null
+++ b/.pipelex/inference/backends/linkup.toml
@@ -0,0 +1,37 @@
+################################################################################
+# Linkup Backend Configuration
+################################################################################
+#
+# This file defines the model specifications for Linkup search models.
+# Linkup provides web search capabilities with sourced answers and structured
+# data extraction.
+#
+# Documentation: https://docs.pipelex.com
+# Support: https://go.pipelex.com/discord
+#
+################################################################################
+
+################################################################################
+# MODEL DEFAULTS
+################################################################################
+
+[defaults]
+model_type = "search"
+sdk = "linkup"
+thinking_mode = "none"
+
+################################################################################
+# SEARCH MODELS
+################################################################################
+
+["linkup/standard"]
+model_id = "standard"
+inputs = ["text"]
+outputs = ["structured"]
+costs = {}
+
+["linkup/deep"]
+model_id = "deep"
+inputs = ["text"]
+outputs = ["structured"]
+costs = {}
diff --git a/.pipelex/inference/backends/pipelex_gateway_models.md b/.pipelex/inference/backends/pipelex_gateway_models.md
index 4f4f6ddcb..d519b307a 100644
--- a/.pipelex/inference/backends/pipelex_gateway_models.md
+++ b/.pipelex/inference/backends/pipelex_gateway_models.md
@@ -508,6 +508,6 @@ For configuration details, see the [documentation](https://docs.pipelex.com/late
> **AUTO-GENERATED FILE** - Do not edit manually.
-> Last updated: 2026-02-08T16:30:33Z
+> Last updated: 2026-03-02T17:46:49Z
>
> Run `pipelex-dev update-gateway-models` or `make ugm` to regenerate.
\ No newline at end of file
diff --git a/.pipelex/inference/backends/pipelex_gateway_models_plain.md b/.pipelex/inference/backends/pipelex_gateway_models_plain.md
index fdbb5a47e..231b5733c 100644
--- a/.pipelex/inference/backends/pipelex_gateway_models_plain.md
+++ b/.pipelex/inference/backends/pipelex_gateway_models_plain.md
@@ -190,6 +190,6 @@ For configuration details, see the [documentation](https://docs.pipelex.com/late
> **AUTO-GENERATED FILE** - Do not edit manually.
-> Last updated: 2026-02-08T16:30:33Z
+> Last updated: 2026-03-02T17:46:49Z
>
> Run `pipelex-dev update-gateway-models` or `make ugm` to regenerate.
\ No newline at end of file
diff --git a/.pipelex/inference/deck/4_search_deck.toml b/.pipelex/inference/deck/4_search_deck.toml
new file mode 100644
index 000000000..9c5433936
--- /dev/null
+++ b/.pipelex/inference/deck/4_search_deck.toml
@@ -0,0 +1,38 @@
+####################################################################################################
+# Pipelex Model Deck - Search Configuration
+####################################################################################################
+#
+# This file defines model aliases and presets for Search models, including
+# web search providers like Linkup.
+#
+# Model Reference Syntax:
+# - Preset: $preset_name or preset:preset_name
+# - Alias: @alias_name or alias:alias_name
+#
+# Documentation: https://docs.pipelex.com
+# Support: https://go.pipelex.com/discord
+#
+####################################################################################################
+
+####################################################################################################
+# Search Default Choices
+####################################################################################################
+
+[search]
+default_depth = "standard"
+choice_default = "@default-search"
+
+####################################################################################################
+# Aliases
+####################################################################################################
+
+[search.aliases]
+default-search = "linkup/standard"
+
+####################################################################################################
+# Search Presets
+####################################################################################################
+
+[search.presets]
+linkup-standard = { model = "linkup/standard", depth = "standard", include_images = false, include_inline_citations = true }
+linkup-deep = { model = "linkup/deep", depth = "deep", include_images = false, include_inline_citations = true }
diff --git a/.pipelex/inference/routing_profiles.toml b/.pipelex/inference/routing_profiles.toml
index 5d60059f2..612338ae7 100644
--- a/.pipelex/inference/routing_profiles.toml
+++ b/.pipelex/inference/routing_profiles.toml
@@ -27,6 +27,8 @@ active = "all_pipelex_gateway"
[profiles.all_pipelex_gateway]
description = "Use Pipelex Gateway for all its supported models"
default = "pipelex_gateway"
+[profiles.all_pipelex_gateway.routes]
+"linkup/*" = "linkup"
[profiles.all_anthropic]
description = "Use Anthropic backend for all its supported models"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80a8c064e..4ccb44215 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+## Unreleased
+
+### Added
+ - **Web Search Integration**: Introduced a comprehensive system for performing web searches within pipelines, including a new `PipeSearch` operator, native support for Linkup as a search backend provider, `SearchResult` and `SearchResultContent` concepts for handling answers with citations, and Model Deck support for search models with presets (e.g., `$linkup-standard`, `$linkup-deep`), aliases, and waterfalls.
+ - **Graph View Generation**: Added a `--view` option to `pipelex validate bundle` that generates a `ViewSpec` JSON (compatible with ReactFlow) for client-side graph rendering without writing files to disk.
+
+### Changed
+ - **Test Configuration**: Added a `search` pytest marker, excluded from default test runs.
+ - `mthds` bumped to `>=0.1.0`.
+ - `pipelex-tools` bumped to `>=0.2.3`.
+ - `linkup-sdk>=0.12.0` added as optional dependency for the Linkup search provider.
+
## [v0.18.6] - 2026-03-01
### Added
diff --git a/Makefile b/Makefile
index 9b3d290e4..c0efe06e8 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ SKELETON_DIR := "$(HOME)/.pipelex-skeleton/"
UV_MIN_VERSION = $(shell grep -m1 'required-version' pyproject.toml | sed -E 's/.*= *"([^<>=, ]+).*/\1/')
-USUAL_PYTEST_MARKERS := "(dry_runnable or not (inference or llm or img_gen or extract)) and not pipelex_api"
+USUAL_PYTEST_MARKERS := "(dry_runnable or not (inference or llm or img_gen or extract or search)) and not pipelex_api"
define PRINT_TITLE
$(eval PROJECT_PART := [$(PROJECT_NAME)])
diff --git a/docs/home/6-build-reliable-ai-workflows/concepts/native-concepts.md b/docs/home/6-build-reliable-ai-workflows/concepts/native-concepts.md
index 9ba73cf3b..9b2629c99 100644
--- a/docs/home/6-build-reliable-ai-workflows/concepts/native-concepts.md
+++ b/docs/home/6-build-reliable-ai-workflows/concepts/native-concepts.md
@@ -29,6 +29,7 @@ Here are all the native concepts you can use out of the box:
| `Page` | A document page with text, images, and optional page view | `PageContent` |
| `Dynamic` | A dynamic concept that adapts to context | `DynamicContent` |
| `JSON` | A JSON object | `JSONContent` |
+| `SearchResult` | A web search result with answer and sources | `SearchResultContent` |
| `Anything` | Any type of content | *No specific implementation* |
## Native Concept Structures
@@ -144,6 +145,26 @@ class JSONContent(StuffContent):
json_obj: dict[str, Any]
```
+### SearchResultContent
+
+Represents the result of a web search query. Produced by `PipeSearch`:
+
+```python
+class SearchResultContent(StuffContent):
+ answer: str
+ sources: list[SearchSourceContent] = []
+```
+
+**Fields:**
+
+- `answer`: The synthesized answer text from the search
+- `sources`: A list of source citations, each containing:
+ - `name` (str): Source name/title
+ - `url` (str): Source URL
+ - `snippet` (str | None): Relevant excerpt from the source
+
+**Use for:** Web search results, research findings, information retrieval with citations.
+
### Anything
!!! note "Special Concepts"
@@ -281,6 +302,18 @@ prompt = "Given this context: $context
Analyze this image: $image"
```
+### Web Search
+
+```toml
+[pipe.search_topic]
+type = "PipeSearch"
+description = "Search the web for information"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-standard"
+prompt = "What is $topic?"
+```
+
## Related Documentation
- [Define Your Concepts](define_your_concepts.md) - Learn about concept semantics
diff --git a/docs/home/6-build-reliable-ai-workflows/pipe-builder.md b/docs/home/6-build-reliable-ai-workflows/pipe-builder.md
index 258f10ad3..5a07926ad 100644
--- a/docs/home/6-build-reliable-ai-workflows/pipe-builder.md
+++ b/docs/home/6-build-reliable-ai-workflows/pipe-builder.md
@@ -141,7 +141,7 @@ For concepts that need structure, the builder:
The builder designs the complete flow architecture:
- Maps out pipe controllers (PipeSequence, PipeBatch, PipeParallel, PipeCondition)
-- Assigns pipe operators (PipeLLM, PipeExtract, PipeImgGen) to specific tasks
+- Assigns pipe operators (PipeLLM, PipeExtract, PipeImgGen, PipeSearch) to specific tasks
- Ensures variables flow correctly through the memory system
- Reviews the flow for consistency and fixes any issues
@@ -159,6 +159,7 @@ For each pipe signature, generates the complete specification:
- **PipeLLM**: Creates prompts and configures LLM settings
- **PipeExtract**: Sets up document/image extraction
- **PipeImgGen**: Configures image generation from prompts
+- **PipeSearch**: Configures web search with structured results
- **PipeSequence**: Defines step-by-step execution
- **PipeBatch**: Sets up concurrent processing over lists
- **PipeParallel**: Orchestrates concurrent different pipes
diff --git a/docs/home/6-build-reliable-ai-workflows/pipes/index.md b/docs/home/6-build-reliable-ai-workflows/pipes/index.md
index ad466e927..7e3ad761d 100644
--- a/docs/home/6-build-reliable-ai-workflows/pipes/index.md
+++ b/docs/home/6-build-reliable-ai-workflows/pipes/index.md
@@ -8,7 +8,7 @@ This guide provides an overview of how to design your pipelines.
A pipeline is composed of pipes. There are two fundamental types of pipes you will use to build your methods:
-* **[Pipe Operators](./pipe-operators/index.md)**: These are the "workers" of your pipeline. They perform concrete actions like calling an LLM (`PipeLLM`), extracting text from a document (`PipeExtract`), or running a Python function (`PipeFunc`). Each operator is a specialized tool designed for a specific task.
+* **[Pipe Operators](./pipe-operators/index.md)**: These are the "workers" of your pipeline. They perform concrete actions like calling an LLM (`PipeLLM`), extracting text from a document (`PipeExtract`), searching the web (`PipeSearch`), or running a Python function (`PipeFunc`). Each operator is a specialized tool designed for a specific task.
* **[Pipe Controllers](./pipe-controllers/index.md)**: These are the "managers" of your pipeline. They don't perform tasks themselves but orchestrate the execution flow of other pipes. They define the logic of your method, such as running pipes in sequence (`PipeSequence`), in parallel (`PipeParallel`), or based on a condition (`PipeCondition`).
## Designing a Pipeline: Composition in MTHDS
diff --git a/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeSearch.md b/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeSearch.md
new file mode 100644
index 000000000..e690e169f
--- /dev/null
+++ b/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeSearch.md
@@ -0,0 +1,83 @@
+# PipeSearch
+
+The `PipeSearch` operator searches the web using a configurable search provider and returns structured results with an answer and source citations.
+
+## How it works
+
+`PipeSearch` takes a search prompt (which can include `$variable` template references) and sends it to a web search provider (such as Linkup). The provider returns a synthesized answer along with a list of sources.
+
+The output is a `SearchResult` (or a concept that refines it), which contains:
+
+- `answer`: The synthesized answer text from the search
+- `sources`: A list of sources, each with a `name`, `url`, and optional `snippet`
+
+## Configuration
+
+`PipeSearch` is configured in your pipeline's `.mthds` file.
+
+### Search Models and Backend System
+
+PipeSearch uses the unified inference backend system to manage search providers. This means you can:
+
+- Use different search providers (e.g., Linkup)
+- Configure search depth (standard vs deep) through presets
+- Route search requests through the same backend system as LLMs and other operators
+
+Common search presets:
+
+- `$linkup-standard`: Standard web search with fast results
+- `$linkup-deep`: Deep web search for more thorough results
+
+### MTHDS Parameters
+
+| Parameter | Type | Description | Required |
+| ------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
+| `type` | string | The type of the pipe: `PipeSearch` | Yes |
+| `description` | string | A description of the search operation. | Yes |
+| `inputs` | dictionary | The input concept(s) for the search query, as a dictionary mapping input names to concept codes. Required when the prompt references variables. | No |
+| `output` | string | The output concept produced by the search. Must be `SearchResult` or a concept that refines `SearchResult`. | Yes |
+| `model` | string | The search model preset to use (e.g., `"$linkup-standard"`, `"$linkup-deep"`). Defaults to the model specified in the global config. | No |
+| `prompt` | string | The search query. Can be a static string or reference input variables using `$` prefix (e.g., `"What is $topic?"`). | Yes |
+
+### Example: Static search query
+
+This pipe performs a fixed search query without any inputs.
+
+```toml
+[pipe.search_ai_news]
+type = "PipeSearch"
+description = "Search for the latest AI news"
+output = "SearchResult"
+model = "$linkup-standard"
+prompt = "What are the latest developments in artificial intelligence?"
+```
+
+### Example: Dynamic search with input variable
+
+This pipe takes a topic as input and searches the web for information about it.
+
+```toml
+[pipe.search_topic]
+type = "PipeSearch"
+description = "Search the web for information about a topic"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-standard"
+prompt = "What is $topic?"
+```
+
+### Example: Deep search
+
+Use a deep search preset for more thorough results.
+
+```toml
+[pipe.deep_research]
+type = "PipeSearch"
+description = "Perform deep research on a topic"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-deep"
+prompt = "What are the main details about $topic?"
+```
+
+The output of PipeSearch must be `SearchResult` or a concept that refines `SearchResult`. After execution, the output contains the synthesized `answer` and a list of `sources` with their names, URLs, and snippets.
diff --git a/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/index.md b/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/index.md
index 9b1daeb01..1c77ba2a8 100644
--- a/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/index.md
+++ b/docs/home/6-build-reliable-ai-workflows/pipes/pipe-operators/index.md
@@ -11,6 +11,7 @@ Here are the primary pipe operators available in Pipelex:
- [**`PipeLLM`**](./PipeLLM.md): The core operator for all interactions with Large Language Models (LLMs), including text generation, structured data extraction, and vision tasks.
- [**`PipeExtract`**](./PipeExtract.md): Performs Optical Character Recognition (OCR) on images and PDF documents to extract text and embedded images.
- [**`PipeImgGen`**](./PipeImgGen.md): Generates images from a text prompt using models like GPT Image, Flux, or other image generation models.
+- [**`PipeSearch`**](./PipeSearch.md): Searches the web using a configurable search provider and returns structured results with an answer and source citations.
- [**`PipeFunc`**](./PipeFunc.md): An escape hatch that allows you to execute any custom Python function, giving you maximum flexibility.
- [**`PipeCompose`**](./PipeCompose.md): Renders a Jinja2 template using data from the working memory, perfect for creating formatted reports or complex prompts.
@@ -22,6 +23,7 @@ Pipelex provides the following pipe operators:
- `PipeExtract`: For optical character recognition and document processing
- `PipeFunc`: For executing custom functions
- `PipeImgGen`: For AI-powered image generation
+- `PipeSearch`: For web search with structured results
## PipeLLM
@@ -76,3 +78,14 @@ Generates and manipulates images.
- Multiple output formats
- Batch processing
- Parameter customization
+
+## PipeSearch
+
+Searches the web and returns structured results with sources.
+
+### Key Features
+
+- Web search via configurable providers
+- Structured results with answer and source citations
+- Dynamic prompt templates with `$variable` syntax
+- Configurable search depth (standard vs deep)
diff --git a/docs/home/9-tools/pipe-builder.md b/docs/home/9-tools/pipe-builder.md
index f4e41eded..d68ca785b 100644
--- a/docs/home/9-tools/pipe-builder.md
+++ b/docs/home/9-tools/pipe-builder.md
@@ -56,7 +56,7 @@ The concept drafts are formalized into proper Pipelex concept specifications wit
The plan is translated into a structured flow with:
-- Pipe operators (PipeLLM, PipeExtract, PipeImgGen)
+- Pipe operators (PipeLLM, PipeExtract, PipeImgGen, PipeSearch)
- Pipe controllers (PipeSequence, PipeBatch, PipeParallel, PipeCondition)
- Input/output contracts for each pipe
- Memory flow between steps
diff --git a/docs/under-the-hood/architecture-overview.md b/docs/under-the-hood/architecture-overview.md
index 7919d22bb..30995febd 100644
--- a/docs/under-the-hood/architecture-overview.md
+++ b/docs/under-the-hood/architecture-overview.md
@@ -43,6 +43,7 @@ Operators perform concrete actions:
- **PipeImgGen** - Generate images
- **PipeFunc** - Execute custom Python functions
- **PipeCompose** - Compose content from templates
+- **PipeSearch** - Search the web for information
### Core Domain
@@ -66,6 +67,7 @@ The COGT layer abstracts AI provider details from business logic:
- **LLM Workers** - Prompt construction, structured output, templating
- **Extract Workers** - Document processing and OCR
- **Image Generation Workers** - Image creation
+- **Search Workers** - Web search and information retrieval
- **Model Catalog & Model Deck** - Manages available models, aliases, and presets
- **Content Generation** - Unified generation interface
@@ -112,6 +114,7 @@ flowchart TB
O3["PipeFunc"]
O4["PipeImgGen"]
O5["PipeCompose"]
+ O6["PipeSearch"]
end
subgraph Core["Core Domain"]
CR1["Concepts"]
@@ -128,8 +131,9 @@ flowchart TB
subgraph COGT["COGT Layer"]
CG1["LLM Workers"]
CG2["Extract Workers"]
- CG3["Model Catalog"]
- CG4["Content Gen"]
+ CG3["Search Workers"]
+ CG4["Model Catalog"]
+ CG5["Content Gen"]
end
subgraph Plugins["Plugins"]
P1["OpenAI"]
diff --git a/mkdocs.yml b/mkdocs.yml
index a3e2fcc12..5c744eb31 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -145,6 +145,7 @@ nav:
- PipeLLM: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeLLM.md
- PipeExtract: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeExtract.md
- PipeImgGen: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeImgGen.md
+ - PipeSearch: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeSearch.md
- PipeCompose: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeCompose.md
- PipeFunc: home/6-build-reliable-ai-workflows/pipes/pipe-operators/PipeFunc.md
- Pipe Controllers:
diff --git a/pipelex/builder/CLAUDE.md b/pipelex/builder/CLAUDE.md
index c79070954..315230f35 100644
--- a/pipelex/builder/CLAUDE.md
+++ b/pipelex/builder/CLAUDE.md
@@ -37,6 +37,7 @@ pipe/
pipe_func_spec.py # PipeFunc — Python function operator
pipe_img_gen_spec.py # PipeImgGen — image generation operator
pipe_extract_spec.py # PipeExtract — OCR/text extraction operator
+ pipe_search_spec.py # PipeSearch — web search operator
pipe_compose_spec.py # PipeCompose — template/construct operator
pipe_sequence_spec.py # PipeSequence — sequential controller
pipe_parallel_spec.py # PipeParallel — concurrent controller
@@ -46,13 +47,14 @@ talents/
llm_talent.py # LLMTalent enum + preset mapping
extract_talent.py # ExtractTalent enum + preset mapping
img_gen_talent.py # ImgGenTalent enum + preset mapping
+ search_talent.py # SearchTalent enum + preset mapping
```
## Spec Architecture
All specs are Pydantic models (`StructuredContent` base). Two categories of pipes:
-**Operators** (data transformation): `PipeLLM`, `PipeFunc`, `PipeImgGen`, `PipeExtract`, `PipeCompose`
+**Operators** (data transformation): `PipeLLM`, `PipeFunc`, `PipeImgGen`, `PipeExtract`, `PipeSearch`, `PipeCompose`
**Controllers** (execution flow): `PipeSequence`, `PipeParallel`, `PipeCondition`, `PipeBatch`
diff --git a/pipelex/builder/pipe/pipe_design.mthds b/pipelex/builder/pipe/pipe_design.mthds
index b88e0ba91..a556d5ccb 100644
--- a/pipelex/builder/pipe/pipe_design.mthds
+++ b/pipelex/builder/pipe/pipe_design.mthds
@@ -14,6 +14,7 @@ PipeImgGenSpec = "A structured spec for a PipeImgGen."
PipeComposeSpec = "A structured spec for a pipe jinja2."
PipeLLMSpec = "A structured spec for a PipeLLM."
PipeExtractSpec = "A structured spec for a PipeExtract."
+PipeSearchSpec = "A structured spec for a PipeSearch."
PipeFailure = "Details of a single pipe failure during dry run."
[pipe]
@@ -35,6 +36,7 @@ PipeExtract = "detail_pipe_extract"
PipeImgGen = "detail_pipe_img_gen"
PipeBatch = "detail_pipe_batch"
PipeCompose = "detail_pipe_compose"
+PipeSearch = "detail_pipe_search"
# ────────────────────────────────────────────────────────────────────────────────
# PIPE CONTROLLERS
@@ -219,6 +221,32 @@ Notes:
- The inputs for the image has to be a single input which must be a Text or another concept which refines Text.
"""
+[pipe.detail_pipe_search]
+type = "PipeLLM"
+description = "Build a PipeSearchSpec from the signature."
+inputs = { plan_draft = "builder.PlanDraft", pipe_signature = "PipeSignature", concept_specs = "builder.ConceptSpec[]" }
+output = "PipeSearchSpec"
+model = "$pipe-builder-engineering"
+prompt = """
+Design a PipeSearchSpec to search the web for up-to-date information.
+Whatever it's really going to do has already been decided as part of this plan:
+@plan_draft
+
+You must pick the relevant concepts for inputs and outputs from the following possibilities:
+@concept_specs
+
++ you can use the native concepts: Text, Html, Image, Document (note: PDF is a document), Number, Page, TextAndImages, ImgGenPrompt, JSON, SearchResult, Anything, Dynamic
+
+Based on the pipe signature, build the PipeSearchSpec.
+
+@pipe_signature
+
+Notes:
+- The prompt is a search query template: use dollar-sign prefix for inline variables.
+- Choose web-search for standard searches or web-search-deep for comprehensive research.
+- The output must be SearchResult or a concept that refines SearchResult.
+"""
+
[pipe.detail_pipe_compose]
type = "PipeLLM"
description = "Build a PipeComposeSpec from the signature."
diff --git a/pipelex/builder/pipe/pipe_img_gen_spec.py b/pipelex/builder/pipe/pipe_img_gen_spec.py
index 80825532a..604dd6862 100644
--- a/pipelex/builder/pipe/pipe_img_gen_spec.py
+++ b/pipelex/builder/pipe/pipe_img_gen_spec.py
@@ -65,7 +65,7 @@ class PipeImgGenSpec(PipeSpec):
@override
def to_blueprint(self) -> PipeImgGenBlueprint:
- """Convert this PipeImgGenBlueprint to the core PipeImgGenBlueprint."""
+ """Convert this PipeImgGenSpec to the core PipeImgGenBlueprint."""
base_blueprint = super().to_blueprint()
# Get img_gen choice from config-based mapping
diff --git a/pipelex/builder/pipe/pipe_search_spec.py b/pipelex/builder/pipe/pipe_search_spec.py
new file mode 100644
index 000000000..c69d73417
--- /dev/null
+++ b/pipelex/builder/pipe/pipe_search_spec.py
@@ -0,0 +1,90 @@
+from typing import TYPE_CHECKING, Literal
+
+from pydantic import Field, field_validator
+from rich.console import Group
+from rich.panel import Panel
+from rich.text import Text
+from typing_extensions import override
+
+from pipelex.builder.pipe.pipe_spec import PipeSpec
+from pipelex.builder.talents.search_talent import SearchTalent
+from pipelex.config import get_config
+from pipelex.pipe_operators.search.pipe_search_blueprint import PipeSearchBlueprint
+from pipelex.tools.misc.pretty import PrettyPrintable
+
+if TYPE_CHECKING:
+ from pipelex.cogt.search.search_setting import SearchModelChoice
+
+
+class PipeSearchSpec(PipeSpec):
+ """Specs for web search pipe operations in the Pipelex framework.
+
+ PipeSearch enables web search using various search providers.
+ Supports static and dynamic prompts with configurable search parameters.
+ """
+
+ type: Literal["PipeSearch"] = "PipeSearch"
+ pipe_category: Literal["PipeOperator"] = "PipeOperator"
+ search_talent: SearchTalent | str = Field(
+ description="Select the most adequate search talent according to the task to be performed.",
+ examples=list(SearchTalent),
+ )
+ prompt: str = Field(description="A finalized search prompt or prompt template: use `$` prefix for inline variables (e.g., `$topic`).")
+
+ @field_validator("search_talent", mode="before")
+ @classmethod
+ def validate_search_talent(cls, search_talent_value: str) -> SearchTalent:
+ try:
+ return SearchTalent(search_talent_value)
+ except ValueError:
+ valid = list(SearchTalent)
+ msg = f"'{search_talent_value}' is not a valid SearchTalent. Valid values: {valid}"
+ raise ValueError(msg) from None
+
+ @override
+ def rendered_pretty(self, title: str | None = None, depth: int = 0) -> PrettyPrintable:
+ # Get base pipe information from parent
+ base_group = super().rendered_pretty(title=title, depth=depth)
+
+ # Create a group combining base info with search-specific details
+ search_group = Group()
+ search_group.renderables.append(base_group)
+
+ # Add search specific information
+ search_group.renderables.append(Text()) # Blank line
+ search_group.renderables.append(Text.from_markup(f"Search Talent: [bold yellow]{self.search_talent}[/bold yellow]"))
+ prompt_panel = Panel(
+ self.prompt,
+ title="Search Prompt",
+ title_align="left",
+ border_style="cyan",
+ padding=(0, 1),
+ )
+ search_group.renderables.append(Text()) # Blank line
+ search_group.renderables.append(prompt_panel)
+
+ return search_group
+
+ @override
+ def to_blueprint(self) -> PipeSearchBlueprint:
+ """Convert this PipeSearchSpec to the core PipeSearchBlueprint."""
+ base_blueprint = super().to_blueprint()
+
+ # Get search choice from config-based mapping
+ mappings = get_config().pipelex.builder_config.talent_preset_mappings.search
+ search_choice: SearchModelChoice = mappings[self.search_talent]
+
+ return PipeSearchBlueprint(
+ description=base_blueprint.description,
+ inputs=base_blueprint.inputs,
+ output=base_blueprint.output,
+ prompt=self.prompt,
+ model=search_choice,
+ depth=None,
+ include_images=None,
+ max_results=None,
+ from_date=None,
+ to_date=None,
+ include_domains=None,
+ exclude_domains=None,
+ )
diff --git a/pipelex/builder/pipe/pipe_spec_map.py b/pipelex/builder/pipe/pipe_spec_map.py
index 356ed6b60..a74dc111b 100644
--- a/pipelex/builder/pipe/pipe_spec_map.py
+++ b/pipelex/builder/pipe/pipe_spec_map.py
@@ -6,6 +6,7 @@ from pipelex.builder.pipe.pipe_func_spec import PipeFuncSpec
from pipelex.builder.pipe.pipe_img_gen_spec import PipeImgGenSpec
from pipelex.builder.pipe.pipe_llm_spec import PipeLLMSpec
from pipelex.builder.pipe.pipe_parallel_spec import PipeParallelSpec
+from pipelex.builder.pipe.pipe_search_spec import PipeSearchSpec
from pipelex.builder.pipe.pipe_sequence_spec import PipeSequenceSpec
pipe_type_to_spec_class: dict[str, type] = {
@@ -14,6 +15,7 @@ pipe_type_to_spec_class: dict[str, type] = {
"PipeCompose": PipeComposeSpec,
"PipeLLM": PipeLLMSpec,
"PipeExtract": PipeExtractSpec,
+ "PipeSearch": PipeSearchSpec,
"PipeBatch": PipeBatchSpec,
"PipeCondition": PipeConditionSpec,
"PipeParallel": PipeParallelSpec,
diff --git a/pipelex/builder/pipe/pipe_spec_union.py b/pipelex/builder/pipe/pipe_spec_union.py
index d6ffb6f27..725044e50 100644
--- a/pipelex/builder/pipe/pipe_spec_union.py
+++ b/pipelex/builder/pipe/pipe_spec_union.py
@@ -10,6 +10,7 @@ from pipelex.builder.pipe.pipe_func_spec import PipeFuncSpec
from pipelex.builder.pipe.pipe_img_gen_spec import PipeImgGenSpec
from pipelex.builder.pipe.pipe_llm_spec import PipeLLMSpec
from pipelex.builder.pipe.pipe_parallel_spec import PipeParallelSpec
+from pipelex.builder.pipe.pipe_search_spec import PipeSearchSpec
from pipelex.builder.pipe.pipe_sequence_spec import PipeSequenceSpec
PipeSpecUnion = Annotated[
@@ -18,6 +19,7 @@ PipeSpecUnion = Annotated[
| PipeComposeSpec
| PipeLLMSpec
| PipeExtractSpec
+ | PipeSearchSpec
| PipeBatchSpec
| PipeConditionSpec
| PipeParallelSpec
diff --git a/pipelex/builder/talents/search_talent.py b/pipelex/builder/talents/search_talent.py
new file mode 100644
index 000000000..3e2da3067
--- /dev/null
+++ b/pipelex/builder/talents/search_talent.py
@@ -0,0 +1,6 @@
+from pipelex.types import StrEnum
+
+
+class SearchTalent(StrEnum):
+ WEB_SEARCH = "web-search"
+ WEB_SEARCH_DEEP = "web-search-deep"
diff --git a/pipelex/cli/agent_cli/commands/models_cmd.py b/pipelex/cli/agent_cli/commands/models_cmd.py
index ad509c45b..670d4fb83 100644
--- a/pipelex/cli/agent_cli/commands/models_cmd.py
+++ b/pipelex/cli/agent_cli/commands/models_cmd.py
@@ -15,16 +15,19 @@ from pipelex.pipelex import Pipelex
from pipelex.types import StrEnum
+# TODO: get this from somewhere else, not hardcoded here.
class ModelCategory(StrEnum):
LLM = "llm"
EXTRACT = "extract"
IMG_GEN = "img_gen"
+ SEARCH = "search"
CATEGORY_TO_MODEL_TYPE: dict[ModelCategory, ModelType] = {
ModelCategory.LLM: ModelType.LLM,
ModelCategory.EXTRACT: ModelType.TEXT_EXTRACTOR,
ModelCategory.IMG_GEN: ModelType.IMG_GEN,
+ ModelCategory.SEARCH: ModelType.SEARCH,
}
@@ -131,6 +134,8 @@ def _build_presets_for_category(
presets_dict = model_deck.extract_presets
case ModelCategory.IMG_GEN:
presets_dict = model_deck.img_gen_presets
+ case ModelCategory.SEARCH:
+ presets_dict = model_deck.search_presets
presets_list: list[dict[str, Any]] = []
for preset_name, setting in presets_dict.items():
@@ -160,6 +165,8 @@ def _build_aliases_for_category(
aliases = model_deck.extract_aliases
case ModelCategory.IMG_GEN:
aliases = model_deck.img_gen_aliases
+ case ModelCategory.SEARCH:
+ aliases = model_deck.search_aliases
if backend is not None:
aliases = _filter_aliases_by_backend(aliases, model_deck, model_type, backend)
@@ -182,6 +189,8 @@ def _build_waterfalls_for_category(
waterfalls = model_deck.extract_waterfalls
case ModelCategory.IMG_GEN:
waterfalls = model_deck.img_gen_waterfalls
+ case ModelCategory.SEARCH:
+ waterfalls = model_deck.search_waterfalls
if backend is not None:
waterfalls = _filter_waterfalls_by_backend(waterfalls, model_deck, model_type, backend)
@@ -208,6 +217,8 @@ def _build_talent_mappings_for_category(
presets_dict = model_deck.extract_presets
case ModelCategory.IMG_GEN:
presets_dict = model_deck.img_gen_presets
+ case ModelCategory.SEARCH:
+ presets_dict = model_deck.search_presets
return _filter_talent_mappings_by_backend(mappings, presets_dict, model_deck, model_type, backend)
@@ -216,7 +227,7 @@ def agent_models_cmd(
ctx: typer.Context,
model_type: Annotated[
list[ModelCategory] | None,
- typer.Option("--type", "-t", help="Filter by model category (repeatable): llm, extract, img_gen"),
+ typer.Option("--type", "-t", help="Filter by model category (repeatable): llm, extract, img_gen, search"),
] = None,
backend: Annotated[
str | None,
@@ -258,6 +269,12 @@ def agent_models_cmd(
waterfalls["extract"] = _build_waterfalls_for_category(model_deck, ModelCategory.EXTRACT, backend)
talent["extract"] = _build_talent_mappings_for_category(model_deck, ModelCategory.EXTRACT, talent_mappings.extract, backend)
+ if _should_include(ModelCategory.SEARCH, model_type):
+ presets["search"] = _build_presets_for_category(model_deck, ModelCategory.SEARCH, backend)
+ aliases["search"] = _build_aliases_for_category(model_deck, ModelCategory.SEARCH, backend)
+ waterfalls["search"] = _build_waterfalls_for_category(model_deck, ModelCategory.SEARCH, backend)
+ talent["search"] = _build_talent_mappings_for_category(model_deck, ModelCategory.SEARCH, talent_mappings.search, backend)
+
result: dict[str, Any] = {
"success": True,
"presets": presets,
@@ -265,7 +282,7 @@ def agent_models_cmd(
"waterfalls": waterfalls,
"talent_mappings": talent,
"talent_mappings_usage_hint": (
- "Use the talent name (key) as the value for llm_talent / extract_talent / img_gen_talent"
+ "Use the talent name (key) as the value for llm_talent / extract_talent / img_gen_talent / search_talent"
" in pipe specs passed to 'pipelex-agent pipe --spec'"
),
}
diff --git a/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py b/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py
index 5b8cb6bee..dd6da0939 100644
--- a/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py
+++ b/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py
@@ -16,7 +16,7 @@ from pipelex.cli.agent_cli.commands.validate._validate_core import (
from pipelex.core.interpreter.exceptions import MthdsDecodeError, PipelexInterpreterError
from pipelex.core.interpreter.helpers import MTHDS_EXTENSION, is_pipelex_file
from pipelex.core.pipes.exceptions import PipeOperatorModelChoiceError
-from pipelex.graph.graph_rendering import GraphFormat, generate_graph_for_bundle
+from pipelex.graph.graph_rendering import GraphFormat, generate_graph_for_bundle, generate_view_for_bundle
from pipelex.libraries.pipe.exceptions import PipeNotFoundError
from pipelex.pipe_operators.exceptions import PipeOperatorModelAvailabilityError
from pipelex.pipelex import Pipelex
@@ -47,6 +47,10 @@ def validate_bundle_cmd(
FlowchartDirection | None,
typer.Option("--direction", help="Flowchart direction"),
] = None,
+ view: Annotated[
+ bool,
+ typer.Option("--view", help="On successful bundle validation, include a ViewSpec (structured JSON for graph rendering) in the output"),
+ ] = False,
library_dir: Annotated[
list[str] | None,
typer.Option("--library-dir", "-L", help="Directory to search for pipe definitions (.mthds files)"),
@@ -143,6 +147,33 @@ def validate_bundle_cmd(
except Exception as exc:
agent_error(f"Graph generation failed: {exc}", type(exc).__name__, cause=exc)
+ # Generate view (ViewSpec JSON) if requested and validation succeeded
+ if view:
+ try:
+ view_result = asyncio.run(
+ generate_view_for_bundle(
+ bundle_path=Path(bundle_path), # type: ignore[arg-type]
+ library_dirs=library_dir_strings,
+ direction=direction,
+ )
+ )
+ result.update(view_result)
+ except PipelineExecutionError as exc:
+ view_extra: dict[str, Any] = {
+ "pipe_code": exc.pipe_code,
+ "pipe_stack": exc.pipe_stack,
+ }
+ if exc.__cause__:
+ view_extra["cause_type"] = type(exc.__cause__).__name__
+ view_extra["cause_message"] = str(exc.__cause__)
+ agent_error(f"View generation failed: {exc.message}", "PipelineExecutionError", cause=exc, **view_extra)
+ except (PipelexInterpreterError, MthdsDecodeError) as exc:
+ agent_error(f"View generation failed: {exc}", type(exc).__name__, cause=exc)
+ except typer.Exit:
+ raise
+ except Exception as exc:
+ agent_error(f"View generation failed: {exc}", type(exc).__name__, cause=exc)
+
agent_success(result)
except PipeNotFoundError as exc:
diff --git a/pipelex/cogt/exceptions.py b/pipelex/cogt/exceptions.py
index f82754fec..3bd0fb795 100644
--- a/pipelex/cogt/exceptions.py
+++ b/pipelex/cogt/exceptions.py
@@ -126,6 +126,13 @@ class ExtractHandleNotFoundError(CogtError):
super().__init__(message)
+class SearchHandleNotFoundError(CogtError):
+ def __init__(self, message: str, preset_id: str, model_handle: str):
+ self.preset_id = preset_id
+ self.model_handle = model_handle
+ super().__init__(message)
+
+
class ExtractOutputError(CogtError):
pass
diff --git a/pipelex/cogt/model_backends/model_type.py b/pipelex/cogt/model_backends/model_type.py
index bd1ad873e..f00c86945 100644
--- a/pipelex/cogt/model_backends/model_type.py
+++ b/pipelex/cogt/model_backends/model_type.py
@@ -5,3 +5,4 @@ class ModelType(StrEnum):
LLM = "llm"
TEXT_EXTRACTOR = "text_extractor"
IMG_GEN = "img_gen"
+ SEARCH = "search"
diff --git a/pipelex/cogt/models/model_deck.py b/pipelex/cogt/models/model_deck.py
index dcc70550f..cd411538b 100644
--- a/pipelex/cogt/models/model_deck.py
+++ b/pipelex/cogt/models/model_deck.py
@@ -14,6 +14,7 @@ from pipelex.cogt.exceptions import (
ModelDeckValidatonError,
ModelNotFoundError,
ModelWaterfallError,
+ SearchHandleNotFoundError,
)
from pipelex.cogt.extract.extract_setting import ExtractModelChoice, ExtractSetting
from pipelex.cogt.img_gen.img_gen_job_components import Quality
@@ -29,6 +30,8 @@ from pipelex.cogt.model_backends.constraints import ValuedConstraint
from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
from pipelex.cogt.model_backends.model_type import ModelType
from pipelex.cogt.models.model_reference import ModelReference, ModelReferenceKind, ModelReferenceParseError, ensure_model_reference
+from pipelex.cogt.search.search_depth import SearchDepth
+from pipelex.cogt.search.search_setting import SearchModelChoice, SearchSetting
from pipelex.system.configuration.config_model import ConfigModel
from pipelex.system.exceptions import ConfigValidationError
from pipelex.system.runtime import ProblemReaction
@@ -65,10 +68,19 @@ class ImgGenDeckBlueprint(ConfigModel):
choice_default: ImgGenModelChoice
+class SearchDeckBlueprint(ConfigModel):
+ default_depth: SearchDepth = Field(strict=False)
+ aliases: dict[str, str] = Field(default_factory=dict)
+ waterfalls: dict[str, list[str]] = Field(default_factory=dict)
+ presets: dict[str, SearchSetting] = Field(default_factory=dict)
+ choice_default: SearchModelChoice
+
+
class ModelDeckBlueprint(ConfigModel):
llm: LLMDeckBlueprint
extract: ExtractDeckBlueprint
img_gen: ImgGenDeckBlueprint
+ search: SearchDeckBlueprint
class ModelDeck(ConfigModel):
@@ -102,6 +114,13 @@ class ModelDeck(ConfigModel):
img_gen_presets: dict[str, ImgGenSetting] = Field(default_factory=dict)
img_gen_choice_default: ImgGenModelChoice
+ # Search-specific
+ search_default_depth: SearchDepth = Field(strict=False)
+ search_aliases: dict[str, str] = Field(default_factory=dict)
+ search_waterfalls: dict[str, list[str]] = Field(default_factory=dict)
+ search_presets: dict[str, SearchSetting] = Field(default_factory=dict)
+ search_choice_default: SearchModelChoice
+
def _get_aliases_and_waterfalls_for_type(self, model_type: ModelType) -> tuple[dict[str, str], dict[str, list[str]]]:
"""Return the type-specific aliases and waterfalls dictionaries."""
match model_type:
@@ -111,6 +130,8 @@ class ModelDeck(ConfigModel):
return self.extract_aliases, self.extract_waterfalls
case ModelType.IMG_GEN:
return self.img_gen_aliases, self.img_gen_waterfalls
+ case ModelType.SEARCH:
+ return self.search_aliases, self.search_waterfalls
def is_model_handle_defined(self, model_handle: str, model_type: ModelType) -> bool:
"""Check if a model handle is defined in the model deck.
@@ -182,11 +203,25 @@ class ModelDeck(ConfigModel):
f"Bare string '{name}' matches: {', '.join(matches)}. Using it as a direct model handle. Add explicit prefix to avoid ambiguity."
)
+ def _warn_if_ambiguous_search(self, name: str) -> None:
+ """Log a warning if a bare string handle matches presets/aliases/waterfalls."""
+ matches: list[str] = []
+ if name in self.search_presets:
+ matches.append(f"search preset (use ${name} or preset:{name})")
+ if name in self.search_aliases:
+ matches.append(f"alias (use @{name} or alias:{name})")
+ if name in self.search_waterfalls:
+ matches.append(f"waterfall (use ~{name} or waterfall:{name})")
+ if matches:
+ log.warning(
+ f"Bare string '{name}' matches: {', '.join(matches)}. Using it as a direct model handle. Add explicit prefix to avoid ambiguity."
+ )
+
def _raise_handle_not_found_error(
self,
ref: ModelReference,
model_type: ModelType,
- presets: dict[str, LLMSetting] | dict[str, ExtractSetting] | dict[str, ImgGenSetting],
+ presets: dict[str, LLMSetting] | dict[str, ExtractSetting] | dict[str, ImgGenSetting] | dict[str, SearchSetting],
) -> NoReturn:
"""Raise ModelChoiceNotFoundError with migration hints if applicable."""
msg = f"Model handle '{ref.name}' was not found in the model deck"
@@ -372,6 +407,55 @@ class ModelDeck(ConfigModel):
presets=self.extract_presets,
)
+ def get_search_setting(self, search_choice: SearchModelChoice) -> SearchSetting:
+ if isinstance(search_choice, SearchSetting):
+ return search_choice
+
+ ref = ensure_model_reference(search_choice)
+ match ref.kind:
+ case ModelReferenceKind.PRESET:
+ if preset := self.search_presets.get(ref.name):
+ return preset
+ msg = f"Search preset '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.PRESET,
+ available_options=list(self.search_presets.keys()),
+ )
+ case ModelReferenceKind.ALIAS:
+ if alias_target := self.search_aliases.get(ref.name):
+ return SearchSetting(model=alias_target, depth=self.search_default_depth)
+ msg = f"Alias '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.ALIAS,
+ available_options=list(self.search_aliases.keys()),
+ )
+ case ModelReferenceKind.WATERFALL:
+ if ref.name in self.search_waterfalls:
+ return SearchSetting(model=ref.name, depth=self.search_default_depth)
+ msg = f"Waterfall '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.WATERFALL,
+ available_options=list(self.search_waterfalls.keys()),
+ )
+ case ModelReferenceKind.HANDLE:
+ self._warn_if_ambiguous_search(ref.name)
+ if self.is_model_handle_defined(model_handle=ref.name, model_type=ModelType.SEARCH):
+ return SearchSetting(model=ref.name, depth=self.search_default_depth)
+ self._raise_handle_not_found_error(
+ ref=ref,
+ model_type=ModelType.SEARCH,
+ presets=self.search_presets,
+ )
+
def get_img_gen_setting(self, img_gen_choice: ImgGenModelChoice) -> ImgGenSetting:
if isinstance(img_gen_choice, ImgGenSetting):
return img_gen_choice
@@ -514,6 +598,17 @@ class ModelDeck(ConfigModel):
)
return self
+ def validate_search_presets(self) -> Self:
+ for search_preset_id, search_setting in self.search_presets.items():
+ if not self.is_model_handle_defined(model_handle=search_setting.model, model_type=ModelType.SEARCH):
+ msg = f"Search handle '{search_setting.model}' for search preset '{search_preset_id}' was not found in the model deck"
+ raise SearchHandleNotFoundError(
+ message=msg,
+ preset_id=search_preset_id,
+ model_handle=search_setting.model,
+ )
+ return self
+
def validate_registered_models(self):
self.validate_inference_models()
try:
@@ -565,6 +660,22 @@ class ModelDeck(ConfigModel):
log.warning(f"Extract handle not found: {exc}")
case ProblemReaction.NONE:
pass
+ try:
+ self.validate_search_presets()
+ except SearchHandleNotFoundError as exc:
+ match self.model_deck_config.missing_presets_reaction:
+ case ProblemReaction.RAISE:
+ msg = f"Failed to validate all Search presets: {exc}"
+ raise ModelDeckPresetValidatonError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ preset_id=exc.preset_id,
+ model_handle=exc.model_handle,
+ ) from exc
+ case ProblemReaction.LOG:
+ log.warning(f"Search handle not found: {exc}")
+ case ProblemReaction.NONE:
+ pass
def validate_inference_models(self):
for model_handle, model_spec in self.inference_models.items():
diff --git a/pipelex/cogt/models/model_deck_check.py b/pipelex/cogt/models/model_deck_check.py
index 4527a448b..e07019e74 100644
--- a/pipelex/cogt/models/model_deck_check.py
+++ b/pipelex/cogt/models/model_deck_check.py
@@ -4,6 +4,7 @@ from pipelex.cogt.img_gen.img_gen_setting import ImgGenModelChoice, ImgGenSettin
from pipelex.cogt.llm.llm_setting import LLMModelChoice, LLMSetting
from pipelex.cogt.model_backends.model_type import ModelType
from pipelex.cogt.models.model_reference import ModelReferenceKind, ensure_model_reference
+from pipelex.cogt.search.search_setting import SearchModelChoice, SearchSetting
from pipelex.hub import get_model_deck
@@ -115,6 +116,60 @@ def check_extract_choice_with_deck(extract_choice: ExtractModelChoice):
)
+def check_search_choice_with_deck(search_choice: SearchModelChoice):
+ if isinstance(search_choice, SearchSetting):
+ return
+
+ model_deck = get_model_deck()
+ ref = ensure_model_reference(search_choice)
+
+ match ref.kind:
+ case ModelReferenceKind.PRESET:
+ if ref.name in model_deck.search_presets:
+ return
+ msg = f"Search preset '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.PRESET,
+ available_options=list(model_deck.search_presets.keys()),
+ )
+ case ModelReferenceKind.ALIAS:
+ if ref.name in model_deck.search_aliases:
+ return
+ msg = f"Alias '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.ALIAS,
+ available_options=list(model_deck.search_aliases.keys()),
+ )
+ case ModelReferenceKind.WATERFALL:
+ if ref.name in model_deck.search_waterfalls:
+ return
+ msg = f"Waterfall '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.WATERFALL,
+ available_options=list(model_deck.search_waterfalls.keys()),
+ )
+ case ModelReferenceKind.HANDLE:
+ if model_deck.is_model_handle_defined(model_handle=ref.name, model_type=ModelType.SEARCH):
+ return
+ msg = f"Model handle '{ref.name}' was not found in the model deck"
+ raise ModelChoiceNotFoundError(
+ message=msg,
+ model_type=ModelType.SEARCH,
+ model_choice=ref.raw,
+ reference_kind=ModelReferenceKind.HANDLE,
+ available_options=list(model_deck.inference_models.keys()),
+ )
+
+
def check_img_gen_choice_with_deck(img_gen_choice: ImgGenModelChoice):
if isinstance(img_gen_choice, ImgGenSetting):
return
diff --git a/pipelex/cogt/models/model_manager.py b/pipelex/cogt/models/model_manager.py
index 95ee7c3ee..fc3d4c9f1 100644
--- a/pipelex/cogt/models/model_manager.py
+++ b/pipelex/cogt/models/model_manager.py
@@ -167,6 +167,12 @@ class ModelManager(ModelManagerAbstract):
img_gen_waterfalls=model_deck_blueprint.img_gen.waterfalls,
img_gen_presets=model_deck_blueprint.img_gen.presets,
img_gen_choice_default=model_deck_blueprint.img_gen.choice_default,
+ # Search
+ search_default_depth=model_deck_blueprint.search.default_depth,
+ search_aliases=model_deck_blueprint.search.aliases,
+ search_waterfalls=model_deck_blueprint.search.waterfalls,
+ search_presets=model_deck_blueprint.search.presets,
+ search_choice_default=model_deck_blueprint.search.choice_default,
model_deck_config=get_config().cogt.model_deck_config,
)
diff --git a/pipelex/cogt/search/__init__.py b/pipelex/cogt/search/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/pipelex/cogt/search/search_depth.py b/pipelex/cogt/search/search_depth.py
new file mode 100644
index 000000000..aa07c459c
--- /dev/null
+++ b/pipelex/cogt/search/search_depth.py
@@ -0,0 +1,6 @@
+from pipelex.types import StrEnum
+
+
+class SearchDepth(StrEnum):
+ STANDARD = "standard"
+ DEEP = "deep"
diff --git a/pipelex/cogt/search/search_setting.py b/pipelex/cogt/search/search_setting.py
new file mode 100644
index 000000000..64acb78b8
--- /dev/null
+++ b/pipelex/cogt/search/search_setting.py
@@ -0,0 +1,28 @@
+from typing import Annotated, Union
+
+from pydantic import BeforeValidator, Field
+
+from pipelex.cogt.models.model_reference import ModelReference, parse_model_reference
+from pipelex.cogt.search.search_depth import SearchDepth
+from pipelex.system.configuration.config_model import ConfigModel
+
+
+class SearchSetting(ConfigModel):
+ model: str
+ depth: SearchDepth = Field(strict=False)
+ include_images: bool = False
+ include_inline_citations: bool = True
+ max_results: int | None = Field(default=None, ge=1)
+ description: str | None = None
+
+ def desc(self) -> str:
+ return f"SearchSetting(model={self.model}, depth={self.depth}, max_results={self.max_results})"
+
+
+# SearchModelChoice accepts SearchSetting, ModelReference, or a string (which gets parsed to ModelReference)
+# The BeforeValidator ensures that strings are automatically converted to ModelReference during validation
+# ModelReference.model_serializer handles serialization back to the raw string value
+SearchModelChoice = Union[
+ SearchSetting,
+ Annotated[str | ModelReference, BeforeValidator(parse_model_reference)],
+]
diff --git a/pipelex/cogt/search/search_worker_abstract.py b/pipelex/cogt/search/search_worker_abstract.py
new file mode 100644
index 000000000..e6ae6a225
--- /dev/null
+++ b/pipelex/cogt/search/search_worker_abstract.py
@@ -0,0 +1,57 @@
+from abc import ABC, abstractmethod
+from typing import Any
+
+from pipelex.cogt.search.search_setting import SearchSetting
+from pipelex.core.stuffs.search_result_content import SearchResultContent
+
+
+class SearchWorkerAbstract(ABC):
+ @abstractmethod
+ async def search_sourced_answer(
+ self,
+ query: str,
+ search_setting: SearchSetting,
+ include_domains: list[str] | None = None,
+ exclude_domains: list[str] | None = None,
+ from_date: str | None = None,
+ to_date: str | None = None,
+ ) -> SearchResultContent:
+ """Execute a search query and return a sourced answer with sources.
+
+ Args:
+ query: The search query text
+ search_setting: Search configuration including model, depth, etc.
+ include_domains: Optional list of domains to restrict search to
+ exclude_domains: Optional list of domains to exclude from search
+ from_date: Optional start date filter (YYYY-MM-DD)
+ to_date: Optional end date filter (YYYY-MM-DD)
+
+ Returns:
+ SearchResultContent with answer and sources
+ """
+
+ @abstractmethod
+ async def search_structured(
+ self,
+ query: str,
+ search_setting: SearchSetting,
+ output_schema: type,
+ include_domains: list[str] | None = None,
+ exclude_domains: list[str] | None = None,
+ from_date: str | None = None,
+ to_date: str | None = None,
+ ) -> dict[str, Any]:
+ """Execute a search query and return structured data matching the schema.
+
+ Args:
+ query: The search query text
+ search_setting: Search configuration including model, depth, etc.
+ output_schema: Pydantic model class defining the expected output structure
+ include_domains: Optional list of domains to restrict search to
+ exclude_domains: Optional list of domains to exclude from search
+ from_date: Optional start date filter (YYYY-MM-DD)
+ to_date: Optional end date filter (YYYY-MM-DD)
+
+ Returns:
+ Dictionary matching the output_schema structure
+ """
diff --git a/pipelex/cogt/search/search_worker_factory.py b/pipelex/cogt/search/search_worker_factory.py
new file mode 100644
index 000000000..985d8a2e8
--- /dev/null
+++ b/pipelex/cogt/search/search_worker_factory.py
@@ -0,0 +1,35 @@
+from pipelex.cogt.search.search_worker_abstract import SearchWorkerAbstract
+
+# Cache of search worker instances by provider prefix
+_search_workers: dict[str, SearchWorkerAbstract] = {}
+
+
+def get_search_worker(model_handle: str) -> SearchWorkerAbstract:
+ """Get a search worker instance for the given model handle.
+
+ The model handle format is "provider/variant" (e.g., "linkup/standard", "linkup/deep").
+ The provider prefix determines which worker implementation to use.
+
+ Args:
+ model_handle: The search model handle (e.g., "linkup/standard")
+
+ Returns:
+ A SearchWorkerAbstract instance for the provider
+ """
+ provider = model_handle.split("/", maxsplit=1)[0] if "/" in model_handle else model_handle
+
+ if provider in _search_workers:
+ return _search_workers[provider]
+
+ worker: SearchWorkerAbstract
+ match provider:
+ case "linkup":
+ from pipelex.plugins.linkup.linkup_search_worker import LinkupSearchWorker # noqa: PLC0415
+
+ worker = LinkupSearchWorker()
+ case _:
+ msg = f"Unknown search provider: '{provider}' (from model handle '{model_handle}')"
+ raise ValueError(msg)
+
+ _search_workers[provider] = worker
+ return worker
diff --git a/pipelex/core/bundles/pipelex_bundle_blueprint.py b/pipelex/core/bundles/pipelex_bundle_blueprint.py
index a40175742..d2e8aa009 100644
--- a/pipelex/core/bundles/pipelex_bundle_blueprint.py
+++ b/pipelex/core/bundles/pipelex_bundle_blueprint.py
@@ -21,6 +21,7 @@ from pipelex.pipe_operators.extract.pipe_extract_blueprint import PipeExtractBlu
from pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprint
from pipelex.pipe_operators.img_gen.pipe_img_gen_blueprint import PipeImgGenBlueprint
from pipelex.pipe_operators.llm.pipe_llm_blueprint import PipeLLMBlueprint
+from pipelex.pipe_operators.search.pipe_search_blueprint import PipeSearchBlueprint
from pipelex.types import Self
from pipelex.urls import URLs
@@ -30,6 +31,7 @@ PipeBlueprintUnion = Annotated[
| PipeComposeBlueprint
| PipeLLMBlueprint
| PipeExtractBlueprint
+ | PipeSearchBlueprint
| PipeBatchBlueprint
| PipeConditionBlueprint
| PipeParallelBlueprint
diff --git a/pipelex/core/concepts/concept_factory.py b/pipelex/core/concepts/concept_factory.py
index 9f9c2732a..648210f78 100644
--- a/pipelex/core/concepts/concept_factory.py
+++ b/pipelex/core/concepts/concept_factory.py
@@ -162,6 +162,13 @@ class ConceptFactory:
description="A JSON object",
structure_class_name=structure_class_name,
)
+ case NativeConceptCode.SEARCH_RESULT:
+ return Concept(
+ code=native_concept_code,
+ domain_code=SpecialDomain.NATIVE,
+ description="A search result with answer and sources",
+ structure_class_name=structure_class_name,
+ )
@classmethod
def make_domain_and_concept_code_from_concept_ref_or_code(
diff --git a/pipelex/core/concepts/native/concept_native.py b/pipelex/core/concepts/native/concept_native.py
index bba314e77..565daff43 100644
--- a/pipelex/core/concepts/native/concept_native.py
+++ b/pipelex/core/concepts/native/concept_native.py
@@ -9,6 +9,7 @@ from pipelex.core.stuffs.image_content import ImageContent
from pipelex.core.stuffs.json_content import JSONContent
from pipelex.core.stuffs.number_content import NumberContent
from pipelex.core.stuffs.page_content import PageContent
+from pipelex.core.stuffs.search_result_content import SearchResultContent
from pipelex.core.stuffs.text_and_images_content import TextAndImagesContent
from pipelex.core.stuffs.text_content import TextContent
from pipelex.types import StrEnum
@@ -25,6 +26,7 @@ class NativeConceptCode(StrEnum):
IMG_GEN_PROMPT = "ImgGenPrompt"
PAGE = "Page"
JSON = "JSON"
+ SEARCH_RESULT = "SearchResult"
ANYTHING = "Anything"
@property
@@ -65,6 +67,8 @@ class NativeConceptCode(StrEnum):
return PageContent
case NativeConceptCode.JSON:
return JSONContent
+ case NativeConceptCode.SEARCH_RESULT:
+ return SearchResultContent
case NativeConceptCode.IMG_GEN_PROMPT | NativeConceptCode.ANYTHING:
# These don't have dedicated content classes
return None
@@ -120,6 +124,7 @@ class NativeConceptCode(StrEnum):
| NativeConceptCode.PAGE
| NativeConceptCode.ANYTHING
| NativeConceptCode.JSON
+ | NativeConceptCode.SEARCH_RESULT
):
return False
@@ -142,6 +147,7 @@ class NativeConceptCode(StrEnum):
| NativeConceptCode.PAGE
| NativeConceptCode.ANYTHING
| NativeConceptCode.JSON
+ | NativeConceptCode.SEARCH_RESULT
):
return False
case NativeConceptCode.DYNAMIC:
diff --git a/pipelex/core/pipes/output/output_renderer.py b/pipelex/core/pipes/output/output_renderer.py
index c6be056d4..64ad77646 100644
--- a/pipelex/core/pipes/output/output_renderer.py
+++ b/pipelex/core/pipes/output/output_renderer.py
@@ -98,6 +98,7 @@ def _collect_possible_outputs(
| PipeType.PIPE_COMPOSE
| PipeType.PIPE_LLM
| PipeType.PIPE_EXTRACT
+ | PipeType.PIPE_SEARCH
| PipeType.PIPE_BATCH
| PipeType.PIPE_PARALLEL
):
diff --git a/pipelex/core/pipes/pipe_blueprint.py b/pipelex/core/pipes/pipe_blueprint.py
index c610a4d56..fb5d51614 100644
--- a/pipelex/core/pipes/pipe_blueprint.py
+++ b/pipelex/core/pipes/pipe_blueprint.py
@@ -43,6 +43,7 @@ class PipeType(StrEnum):
PIPE_COMPOSE = "PipeCompose"
PIPE_LLM = "PipeLLM"
PIPE_EXTRACT = "PipeExtract"
+ PIPE_SEARCH = "PipeSearch"
# Pipe Controller
PIPE_BATCH = "PipeBatch"
PIPE_CONDITION = "PipeCondition"
@@ -66,6 +67,8 @@ class PipeType(StrEnum):
return PipeCategory.PIPE_OPERATOR
case PipeType.PIPE_EXTRACT:
return PipeCategory.PIPE_OPERATOR
+ case PipeType.PIPE_SEARCH:
+ return PipeCategory.PIPE_OPERATOR
case PipeType.PIPE_BATCH:
return PipeCategory.PIPE_CONTROLLER
case PipeType.PIPE_CONDITION:
diff --git a/pipelex/core/registry_models.py b/pipelex/core/registry_models.py
index 457ca8781..6b6f88baa 100644
--- a/pipelex/core/registry_models.py
+++ b/pipelex/core/registry_models.py
@@ -10,6 +10,7 @@ from pipelex.core.stuffs.json_content import JSONContent
from pipelex.core.stuffs.list_content import ListContent
from pipelex.core.stuffs.number_content import NumberContent
from pipelex.core.stuffs.page_content import PageContent
+from pipelex.core.stuffs.search_result_content import SearchResultContent, SearchSourceContent
from pipelex.core.stuffs.structured_content import StructuredContent
from pipelex.core.stuffs.stuff import Stuff
from pipelex.core.stuffs.stuff_content import StuffContent
@@ -33,6 +34,8 @@ from pipelex.pipe_operators.img_gen.pipe_img_gen import PipeImgGen
from pipelex.pipe_operators.img_gen.pipe_img_gen_factory import PipeImgGenFactory
from pipelex.pipe_operators.llm.pipe_llm import PipeLLM
from pipelex.pipe_operators.llm.pipe_llm_factory import PipeLLMFactory
+from pipelex.pipe_operators.search.pipe_search import PipeSearch
+from pipelex.pipe_operators.search.pipe_search_factory import PipeSearchFactory
from pipelex.system.registries.registry_base import ModelType, RegistryModels
@@ -45,6 +48,7 @@ class CoreRegistryModels(RegistryModels):
PipeCompose,
PipeLLM,
PipeExtract,
+ PipeSearch,
]
PIPE_OPERATORS_FACTORY: ClassVar[list[PipeFactoryProtocol[Any, Any]]] = [
@@ -53,6 +57,7 @@ class CoreRegistryModels(RegistryModels):
PipeComposeFactory,
PipeLLMFactory,
PipeExtractFactory,
+ PipeSearchFactory,
]
PIPE_CONTROLLERS: ClassVar[list[PipeAbstractType]] = [
@@ -82,6 +87,8 @@ class CoreRegistryModels(RegistryModels):
TextAndImagesContent,
PageContent,
JSONContent,
+ SearchResultContent,
+ SearchSourceContent,
]
EXPERIMENTAL: ClassVar[list[ModelType]] = [
diff --git a/pipelex/core/stuffs/search_result_content.py b/pipelex/core/stuffs/search_result_content.py
new file mode 100644
index 000000000..1c27f8f7c
--- /dev/null
+++ b/pipelex/core/stuffs/search_result_content.py
@@ -0,0 +1,122 @@
+import html as html_module
+
+from pydantic import Field
+from rich.console import Group
+from rich.markdown import Markdown
+from rich.text import Text
+from typing_extensions import override
+
+from pipelex.core.stuffs.stuff_content import StuffContent
+from pipelex.tools.misc.pretty import PrettyPrintable
+from pipelex.tools.typing.pydantic_utils import empty_list_factory_of
+
+
+class SearchSourceContent(StuffContent):
+ """Represents a single search source with name, URL, and optional snippet."""
+
+ name: str
+ url: str
+ snippet: str | None = None
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"source: {self.name}"
+
+ @override
+ def rendered_plain(self) -> str:
+ result = f"- {self.name}: {self.url}"
+ if self.snippet:
+ result += f"\n {self.snippet}"
+ return result
+
+ @override
+ def rendered_html(self) -> str:
+ name_escaped = html_module.escape(self.name)
+ url_escaped = html_module.escape(self.url)
+ result = f'<li><a href="{url_escaped}">{name_escaped}</a>'
+ if self.snippet:
+ snippet_escaped = html_module.escape(self.snippet)
+ result += f"<br/><small>{snippet_escaped}</small>"
+ result += "</li>"
+ return result
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ result = f"- [{self.name}]({self.url})"
+ if self.snippet:
+ result += f"\n {self.snippet}"
+ return result
+
+ @override
+ def rendered_pretty(self, title: str | None = None, depth: int = 0) -> PrettyPrintable:
+ source_text = Text()
+ source_text.append(self.name, style="bold")
+ source_text.append(f" ({self.url})", style="dim cyan")
+ if self.snippet:
+ source_text.append(f"\n {self.snippet}", style="dim italic")
+ return source_text
+
+
+class SearchResultContent(StuffContent):
+ """Represents the result of a search query with an answer and list of sources."""
+
+ answer: str
+ sources: list[SearchSourceContent] = Field(default_factory=empty_list_factory_of(SearchSourceContent))
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ nb_sources = len(self.sources)
+ return f"search result ({len(self.answer)} chars, {nb_sources} source{'s' if nb_sources != 1 else ''})"
+
+ @override
+ def rendered_plain(self) -> str:
+ result = self.answer
+ if self.sources:
+ result += "\n\nSources:\n"
+ result += "\n".join(source.rendered_plain() for source in self.sources)
+ return result
+
+ @override
+ def rendered_html(self) -> str:
+ answer_escaped = html_module.escape(self.answer)
+ result = f"<div><p>{answer_escaped}</p>"
+ if self.sources:
+ source_items = "".join(source.rendered_html() for source in self.sources)
+ result += f"<h4>Sources</h4><ul>{source_items}</ul>"
+ result += "</div>"
+ return result
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ result = self.answer
+ if self.sources:
+ result += "\n\n**Sources:**\n\n"
+ result += "\n".join(source.rendered_markdown(level=level, is_pretty=is_pretty) for source in self.sources)
+ return result
+
+ @override
+ def rendered_pretty(self, title: str | None = None, depth: int = 0) -> PrettyPrintable:
+ group = Group()
+
+ # Title
+ title_text = Text("Search Result:", style="bold cyan")
+ group.renderables.append(title_text)
+
+ # Answer as markdown
+ group.renderables.append(Markdown(self.answer))
+
+ # Sources
+ if self.sources:
+ group.renderables.append(Text()) # spacing
+ sources_header = Text(f"Sources ({len(self.sources)}):", style="bold yellow")
+ group.renderables.append(sources_header)
+
+ for index, source in enumerate(self.sources):
+ if index > 0:
+ group.renderables.append(Text()) # spacing between sources
+ source_renderable = source.rendered_pretty(depth=depth + 1)
+ group.renderables.append(source_renderable)
+
+ return group
diff --git a/pipelex/graph/graph_rendering.py b/pipelex/graph/graph_rendering.py
index 9b59379b4..f37878fe0 100644
--- a/pipelex/graph/graph_rendering.py
+++ b/pipelex/graph/graph_rendering.py
@@ -11,9 +11,12 @@ from pipelex.base_exceptions import PipelexError
from pipelex.config import get_config
from pipelex.core.interpreter.exceptions import PipelexInterpreterError
from pipelex.core.interpreter.interpreter import PipelexInterpreter
+from pipelex.graph.graph_analysis import GraphAnalysis
from pipelex.graph.graph_config import GraphConfig
from pipelex.graph.graph_factory import GraphOutputs, generate_graph_outputs, save_graph_outputs_to_dir
from pipelex.graph.graphspec import GraphSpec
+from pipelex.graph.reactflow.viewspec import LayoutSpec
+from pipelex.graph.reactflow.viewspec_transformer import graphspec_to_viewspec
from pipelex.pipe_run.pipe_run_mode import PipeRunMode
from pipelex.pipeline.runner import PipelexRunner
from pipelex.tools.misc.chart_utils import FlowchartDirection
@@ -92,25 +95,21 @@ async def render_graph_from_spec(
return save_graph_outputs_to_dir(graph_outputs=graph_outputs, output_dir=output_dir)
-async def generate_graph_for_bundle(
+async def _dry_run_bundle(
bundle_path: Path,
- graph_format: GraphFormat,
library_dirs: list[str] | None = None,
- direction: FlowchartDirection | None = None,
-) -> dict[str, Any]:
- """Generate graph visualization for a bundle via dry-run pipeline execution.
+) -> tuple[GraphSpec, str]:
+ """Perform a dry-run pipeline execution on a bundle to produce a GraphSpec.
- Reads the bundle, parses main_pipe, performs a dry-run with graph tracing,
- then renders and saves graph HTML files alongside the bundle.
+ Reads the bundle, parses main_pipe, builds a runner, and executes a dry-run
+ with graph tracing enabled.
Args:
bundle_path: Path to the .mthds bundle file.
- graph_format: Which graph format(s) to generate.
library_dirs: Optional library directories for pipe resolution.
- direction: Flowchart layout direction (default: None, uses TB).
Returns:
- Dictionary with graph_files, graph_output_dir, and direction.
+ Tuple of (GraphSpec, pipe_code).
Raises:
PipelexInterpreterError: If bundle parsing fails or main_pipe is missing.
@@ -157,7 +156,40 @@ async def generate_graph_for_bundle(
msg = "Pipeline execution did not produce a graph spec"
raise PipelexError(msg)
- graph_spec = pipe_output.graph_spec
+ return pipe_output.graph_spec, pipe_code
+
+
+async def generate_graph_for_bundle(
+ bundle_path: Path,
+ graph_format: GraphFormat,
+ library_dirs: list[str] | None = None,
+ direction: FlowchartDirection | None = None,
+) -> dict[str, Any]:
+ """Generate graph visualization for a bundle via dry-run pipeline execution.
+
+ Reads the bundle, parses main_pipe, performs a dry-run with graph tracing,
+ then renders and saves graph HTML files alongside the bundle.
+
+ Args:
+ bundle_path: Path to the .mthds bundle file.
+ graph_format: Which graph format(s) to generate.
+ library_dirs: Optional library directories for pipe resolution.
+ direction: Flowchart layout direction (default: None, uses TB).
+
+ Returns:
+ Dictionary with graph_files, graph_output_dir, and direction.
+
+ Raises:
+ PipelexInterpreterError: If bundle parsing fails or main_pipe is missing.
+ PipelexError: If pipeline execution does not produce a graph spec.
+ PipelineExecutionError: If dry-run execution fails.
+ """
+ graph_spec, pipe_code = await _dry_run_bundle(bundle_path, library_dirs)
+
+ execution_config = get_config().pipelex.pipeline_execution_config.with_graph_config_overrides(
+ generate_graph=True,
+ mock_inputs=True,
+ )
include_mermaidflow: bool
include_reactflow: bool
@@ -189,3 +221,52 @@ async def generate_graph_for_bundle(
"pipe_code": pipe_code,
"direction": str(direction) if direction else None,
}
+
+
+# TODO: refactor to do only one dry run and generate both graph and ViewSpec
+async def generate_view_for_bundle(
+ bundle_path: Path,
+ library_dirs: list[str] | None = None,
+ direction: FlowchartDirection | None = None,
+) -> dict[str, Any]:
+ """Generate a ViewSpec for a bundle via dry-run pipeline execution.
+
+ Returns structured JSON data (ViewSpec) suitable for client-side rendering,
+ without writing any files to disk.
+
+ Args:
+ bundle_path: Path to the .mthds bundle file.
+ library_dirs: Optional library directories for pipe resolution.
+ direction: Flowchart layout direction (default: None, uses config default).
+
+ Returns:
+ Dictionary with viewspec (JSON-serializable dict), pipe_code, and direction.
+
+ Raises:
+ PipelexInterpreterError: If bundle parsing fails or main_pipe is missing.
+ PipelexError: If pipeline execution does not produce a graph spec.
+ PipelineExecutionError: If dry-run execution fails.
+ """
+ graph_spec, pipe_code = await _dry_run_bundle(bundle_path, library_dirs)
+
+ execution_config = get_config().pipelex.pipeline_execution_config.with_graph_config_overrides(
+ generate_graph=True,
+ mock_inputs=True,
+ )
+ rf_config = execution_config.graph_config.reactflow_config
+ effective_direction = direction or rf_config.layout_direction
+
+ analysis = GraphAnalysis.from_graphspec(graph_spec)
+ layout = LayoutSpec(
+ direction=effective_direction,
+ nodesep=rf_config.nodesep,
+ ranksep=rf_config.ranksep,
+ )
+ viewspec = graphspec_to_viewspec(graph_spec, analysis, layout=layout)
+
+ return {
+ "viewspec": viewspec.model_dump(mode="json"),
+ "graphspec": graph_spec.model_dump(mode="json", by_alias=True),
+ "pipe_code": pipe_code,
+ "direction": str(effective_direction) if effective_direction else None,
+ }
diff --git a/pipelex/kit/configs/inference/backends.toml b/pipelex/kit/configs/inference/backends.toml
index 6d9a3dca7..08e993c27 100644
--- a/pipelex/kit/configs/inference/backends.toml
+++ b/pipelex/kit/configs/inference/backends.toml
@@ -58,6 +58,11 @@ display_name = "Hugging Face"
enabled = true
api_key = "${HF_TOKEN}"
+[linkup]
+display_name = "Linkup"
+enabled = true
+api_key = "${LINKUP_API_KEY}"
+
[mistral]
display_name = "Mistral AI"
enabled = true
diff --git a/pipelex/kit/configs/inference/backends/linkup.toml b/pipelex/kit/configs/inference/backends/linkup.toml
new file mode 100644
index 000000000..9ff7d159f
--- /dev/null
+++ b/pipelex/kit/configs/inference/backends/linkup.toml
@@ -0,0 +1,37 @@
+################################################################################
+# Linkup Backend Configuration
+################################################################################
+#
+# This file defines the model specifications for Linkup search models.
+# Linkup provides web search capabilities with sourced answers and structured
+# data extraction.
+#
+# Documentation: https://docs.pipelex.com
+# Support: https://go.pipelex.com/discord
+#
+################################################################################
+
+################################################################################
+# MODEL DEFAULTS
+################################################################################
+
+[defaults]
+model_type = "search"
+sdk = "linkup"
+thinking_mode = "none"
+
+################################################################################
+# SEARCH MODELS
+################################################################################
+
+["linkup/standard"]
+model_id = "standard"
+inputs = ["text"]
+outputs = ["structured"]
+costs = {}
+
+["linkup/deep"]
+model_id = "deep"
+inputs = ["text"]
+outputs = ["structured"]
+costs = {}
diff --git a/pipelex/kit/configs/inference/backends/pipelex_gateway_models.md b/pipelex/kit/configs/inference/backends/pipelex_gateway_models.md
index 4f4f6ddcb..d519b307a 100644
--- a/pipelex/kit/configs/inference/backends/pipelex_gateway_models.md
+++ b/pipelex/kit/configs/inference/backends/pipelex_gateway_models.md
@@ -508,6 +508,6 @@ For configuration details, see the [documentation](https://docs.pipelex.com/late
> **AUTO-GENERATED FILE** - Do not edit manually.
-> Last updated: 2026-02-08T16:30:33Z
+> Last updated: 2026-03-02T17:46:49Z
>
> Run `pipelex-dev update-gateway-models` or `make ugm` to regenerate.
\ No newline at end of file
diff --git a/pipelex/kit/configs/inference/backends/pipelex_gateway_models_plain.md b/pipelex/kit/configs/inference/backends/pipelex_gateway_models_plain.md
index fdbb5a47e..231b5733c 100644
--- a/pipelex/kit/configs/inference/backends/pipelex_gateway_models_plain.md
+++ b/pipelex/kit/configs/inference/backends/pipelex_gateway_models_plain.md
@@ -190,6 +190,6 @@ For configuration details, see the [documentation](https://docs.pipelex.com/late
> **AUTO-GENERATED FILE** - Do not edit manually.
-> Last updated: 2026-02-08T16:30:33Z
+> Last updated: 2026-03-02T17:46:49Z
>
> Run `pipelex-dev update-gateway-models` or `make ugm` to regenerate.
\ No newline at end of file
diff --git a/pipelex/kit/configs/inference/deck/4_search_deck.toml b/pipelex/kit/configs/inference/deck/4_search_deck.toml
new file mode 100644
index 000000000..9c5433936
--- /dev/null
+++ b/pipelex/kit/configs/inference/deck/4_search_deck.toml
@@ -0,0 +1,38 @@
+####################################################################################################
+# Pipelex Model Deck - Search Configuration
+####################################################################################################
+#
+# This file defines model aliases and presets for Search models, including
+# web search providers like Linkup.
+#
+# Model Reference Syntax:
+# - Preset: $preset_name or preset:preset_name
+# - Alias: @alias_name or alias:alias_name
+#
+# Documentation: https://docs.pipelex.com
+# Support: https://go.pipelex.com/discord
+#
+####################################################################################################
+
+####################################################################################################
+# Search Default Choices
+####################################################################################################
+
+[search]
+default_depth = "standard"
+choice_default = "@default-search"
+
+####################################################################################################
+# Aliases
+####################################################################################################
+
+[search.aliases]
+default-search = "linkup/standard"
+
+####################################################################################################
+# Search Presets
+####################################################################################################
+
+[search.presets]
+linkup-standard = { model = "linkup/standard", depth = "standard", include_images = false, include_inline_citations = true }
+linkup-deep = { model = "linkup/deep", depth = "deep", include_images = false, include_inline_citations = true }
diff --git a/pipelex/kit/configs/inference/routing_profiles.toml b/pipelex/kit/configs/inference/routing_profiles.toml
index 5d60059f2..612338ae7 100644
--- a/pipelex/kit/configs/inference/routing_profiles.toml
+++ b/pipelex/kit/configs/inference/routing_profiles.toml
@@ -27,6 +27,8 @@ active = "all_pipelex_gateway"
[profiles.all_pipelex_gateway]
description = "Use Pipelex Gateway for all its supported models"
default = "pipelex_gateway"
+[profiles.all_pipelex_gateway.routes]
+"linkup/*" = "linkup"
[profiles.all_anthropic]
description = "Use Anthropic backend for all its supported models"
diff --git a/pipelex/language/mthds_schema_generator.py b/pipelex/language/mthds_schema_generator.py
index 49d0dabac..39e2f8294 100644
--- a/pipelex/language/mthds_schema_generator.py
+++ b/pipelex/language/mthds_schema_generator.py
@@ -29,6 +29,7 @@ _PIPE_DEFINITION_NAMES = {
"PipeComposeBlueprint",
"PipeLLMBlueprint",
"PipeExtractBlueprint",
+ "PipeSearchBlueprint",
"PipeBatchBlueprint",
"PipeConditionBlueprint",
"PipeParallelBlueprint",
diff --git a/pipelex/pipe_operators/search/__init__.py b/pipelex/pipe_operators/search/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/pipe_operators/search/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/pipe_operators/search/exceptions.py b/pipelex/pipe_operators/search/exceptions.py
new file mode 100644
index 000000000..bfe184a67
--- /dev/null
+++ b/pipelex/pipe_operators/search/exceptions.py
@@ -0,0 +1,9 @@
+from pipelex.base_exceptions import PipelexError
+
+
+class PipeSearchFactoryError(PipelexError):
+ pass
+
+
+class PipeSearchError(PipelexError):
+ pass
diff --git a/pipelex/pipe_operators/search/pipe_search.py b/pipelex/pipe_operators/search/pipe_search.py
new file mode 100644
index 000000000..6eba17f9f
--- /dev/null
+++ b/pipelex/pipe_operators/search/pipe_search.py
@@ -0,0 +1,200 @@
+from typing import TYPE_CHECKING, Literal
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.content_generation.dry_run_factory import DryRunFactory
+from pipelex.cogt.exceptions import ModelChoiceNotFoundError
+from pipelex.cogt.model_backends.model_type import ModelType
+from pipelex.cogt.models.model_deck_check import check_search_choice_with_deck
+from pipelex.cogt.search.search_depth import SearchDepth
+from pipelex.cogt.search.search_setting import SearchModelChoice, SearchSetting
+from pipelex.cogt.search.search_worker_factory import get_search_worker
+from pipelex.cogt.templating.template_blueprint import TemplateBlueprint
+from pipelex.cogt.templating.template_rendering import render_template
+from pipelex.core.memory.working_memory import WorkingMemory
+from pipelex.core.pipes.inputs.input_stuff_specs import InputStuffSpecs
+from pipelex.core.pipes.pipe_output import PipeOutput
+from pipelex.core.stuffs.search_result_content import SearchResultContent
+from pipelex.core.stuffs.stuff_factory import StuffFactory
+from pipelex.hub import get_model_deck
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.pipe_run.pipe_run_params import PipeRunParams
+from pipelex.pipeline.job_metadata import JobMetadata
+from pipelex.tools.misc.string_utils import get_root_from_dotted_path
+
+if TYPE_CHECKING:
+ from pipelex.core.stuffs.stuff_content import StuffContent
+
+
+class PipeSearchOutput(PipeOutput):
+ pass
+
+
+class PipeSearch(PipeOperator[PipeSearchOutput]):
+ type: Literal["PipeSearch"] = "PipeSearch"
+ search_choice: SearchModelChoice | None
+ prompt_blueprint: TemplateBlueprint
+ depth_override: SearchDepth | None = None
+ include_images_override: bool | None = None
+ max_results_override: int | None = None
+ from_date: str | None = None
+ to_date: str | None = None
+ include_domains: list[str] | None = None
+ exclude_domains: list[str] | None = None
+ is_structured_output: bool
+
+ @override
+ def needed_inputs(self, visited_pipes: set[str] | None = None) -> InputStuffSpecs:
+ return self.inputs
+
+ @override
+ def required_variables(self) -> set[str]:
+ full_paths = self.prompt_blueprint.required_variables()
+ return {get_root_from_dotted_path(path) for path in full_paths if not path.startswith("_")}
+
+ @override
+ def validate_inputs_static(self):
+ if self.search_choice:
+ try:
+ check_search_choice_with_deck(search_choice=self.search_choice)
+ except ModelChoiceNotFoundError as exc:
+ msg = f"Search choice '{self.search_choice}' was not found in the model deck"
+ raise ValueError(msg) from exc
+
+ @override
+ def validate_inputs_with_library(self):
+ pass
+
+ @override
+ def validate_output_static(self):
+ pass
+
+ @override
+ def validate_output_with_library(self):
+ pass
+
+ @override
+ async def _live_run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: str | None = None,
+ ) -> PipeSearchOutput:
+ # 0. Log the search run
+ search_choice_desc = self.search_choice or "default"
+ log.dev(f"✨ PipeSearch '{self.code}' running with search choice '{search_choice_desc}' ✨")
+
+ # 1. Render the prompt template against working memory context
+ query_text = await render_template(
+ template=self.prompt_blueprint.template,
+ category=self.prompt_blueprint.category,
+ context=working_memory.generate_context(),
+ )
+
+ # 2. Resolve SearchSetting from deck
+ model_deck = get_model_deck()
+ search_choice: SearchModelChoice = self.search_choice or model_deck.search_choice_default
+ search_setting: SearchSetting = model_deck.get_search_setting(search_choice=search_choice)
+
+ # 3. Resolve the model handle (waterfalls/aliases → actual provider/variant handle)
+ inference_model = model_deck.get_required_inference_model(model_handle=search_setting.model, model_type=ModelType.SEARCH)
+ resolved_model_handle = inference_model.name
+ if resolved_model_handle != search_setting.model:
+ search_setting = search_setting.model_copy(update={"model": resolved_model_handle})
+
+ # 4. Apply pipe-level overrides
+ if self.depth_override is not None:
+ search_setting = search_setting.model_copy(update={"depth": self.depth_override})
+ if self.include_images_override is not None:
+ search_setting = search_setting.model_copy(update={"include_images": self.include_images_override})
+ if self.max_results_override is not None:
+ search_setting = search_setting.model_copy(update={"max_results": self.max_results_override})
+
+ # 5. Get search worker from factory
+ worker = get_search_worker(model_handle=search_setting.model)
+
+ # 6. Execute search based on output type
+ content: StuffContent
+ if not self.is_structured_output:
+ content = await worker.search_sourced_answer(
+ query=query_text,
+ search_setting=search_setting,
+ include_domains=self.include_domains,
+ exclude_domains=self.exclude_domains,
+ from_date=self.from_date,
+ to_date=self.to_date,
+ )
+ else:
+ output_structure_class = self.output.concept.get_structure_class()
+ result_dict = await worker.search_structured(
+ query=query_text,
+ search_setting=search_setting,
+ output_schema=output_structure_class,
+ include_domains=self.include_domains,
+ exclude_domains=self.exclude_domains,
+ from_date=self.from_date,
+ to_date=self.to_date,
+ )
+ content = output_structure_class.model_validate(result_dict)
+
+ # 7. Create Stuff, set in working memory, and return output
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept=self.output.concept,
+ content=content,
+ )
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+ return PipeSearchOutput(
+ working_memory=working_memory,
+ pipeline_run_id=job_metadata.pipeline_run_id,
+ )
+
+ @override
+ async def _dry_run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: str | None = None,
+ ) -> PipeSearchOutput:
+ content: StuffContent
+ if not self.is_structured_output:
+ content = SearchResultContent(
+ answer="[DRY RUN] Mock search result",
+ sources=[],
+ )
+ else:
+ output_structure_class = self.output.concept.get_structure_class()
+ object_factory = DryRunFactory.make_dry_run_factory(output_structure_class)
+ content = object_factory.build()
+
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept=self.output.concept,
+ content=content,
+ )
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+ return PipeSearchOutput(
+ working_memory=working_memory,
+ pipeline_run_id=job_metadata.pipeline_run_id,
+ )
+
+ @override
+ async def _validate_before_run(
+ self, job_metadata: JobMetadata, working_memory: WorkingMemory, pipe_run_params: PipeRunParams, output_name: str | None = None
+ ):
+ pass
+
+ @override
+ async def _validate_after_run(
+ self, job_metadata: JobMetadata, working_memory: WorkingMemory, pipe_run_params: PipeRunParams, output_name: str | None = None
+ ):
+ pass
diff --git a/pipelex/pipe_operators/search/pipe_search_blueprint.py b/pipelex/pipe_operators/search/pipe_search_blueprint.py
new file mode 100644
index 000000000..f38635e34
--- /dev/null
+++ b/pipelex/pipe_operators/search/pipe_search_blueprint.py
@@ -0,0 +1,61 @@
+from typing import Literal
+
+from typing_extensions import override
+
+from pipelex.cogt.search.search_depth import SearchDepth
+from pipelex.cogt.search.search_setting import SearchModelChoice
+from pipelex.cogt.templating.template_category import TemplateCategory
+from pipelex.cogt.templating.template_preprocessor import preprocess_template
+from pipelex.core.pipes.pipe_blueprint import PipeBlueprint
+from pipelex.tools.jinja2.jinja2_errors import Jinja2TemplateSyntaxError
+from pipelex.tools.jinja2.jinja2_parsing import check_jinja2_parsing
+from pipelex.tools.jinja2.jinja2_required_variables import detect_jinja2_required_variables
+from pipelex.tools.misc.string_utils import get_root_from_dotted_path
+
+
+class PipeSearchBlueprint(PipeBlueprint):
+ type: Literal["PipeSearch"] = "PipeSearch"
+ pipe_category: Literal["PipeOperator"] = "PipeOperator"
+ prompt: str
+ model: SearchModelChoice | None = None
+ depth: SearchDepth | None = None
+ include_images: bool | None = None
+ max_results: int | None = None
+ from_date: str | None = None
+ to_date: str | None = None
+ include_domains: list[str] | None = None
+ exclude_domains: list[str] | None = None
+
+ @override
+ def validate_inputs(self):
+ template_category = TemplateCategory.BASIC
+ preprocessed_template = preprocess_template(self.prompt)
+ try:
+ check_jinja2_parsing(
+ template_source=preprocessed_template,
+ template_category=template_category,
+ )
+ except Jinja2TemplateSyntaxError as exc:
+ msg = f"Could not parse template for PipeSearch: {exc}"
+ raise ValueError(msg) from exc
+
+ full_paths = detect_jinja2_required_variables(
+ template_category=template_category,
+ template_source=preprocessed_template,
+ )
+ required_variables: set[str] = set()
+ for path in full_paths:
+ root = get_root_from_dotted_path(path)
+ if not root.startswith("_"):
+ required_variables.add(root)
+
+ input_names: set[str] = set(self.inputs.keys()) if self.inputs else set()
+ missing_variables: set[str] = required_variables - input_names
+
+ if missing_variables:
+ missing_vars_str = ", ".join(sorted(missing_variables))
+ msg = (
+ f"Missing input variable(s) in prompt template: {missing_vars_str}. "
+ "These variables are used in the prompt but not declared in inputs."
+ )
+ raise ValueError(msg)
diff --git a/pipelex/pipe_operators/search/pipe_search_factory.py b/pipelex/pipe_operators/search/pipe_search_factory.py
new file mode 100644
index 000000000..c1428c402
--- /dev/null
+++ b/pipelex/pipe_operators/search/pipe_search_factory.py
@@ -0,0 +1,61 @@
+from typing import Any
+
+from typing_extensions import override
+
+from pipelex.cogt.templating.template_blueprint import TemplateBlueprint
+from pipelex.cogt.templating.template_category import TemplateCategory
+from pipelex.core.concepts.native.concept_native import NativeConceptCode
+from pipelex.core.pipes.inputs.input_stuff_specs import InputStuffSpecs
+from pipelex.core.pipes.pipe_factory import PipeFactoryProtocol
+from pipelex.core.pipes.stuff_spec.stuff_spec import StuffSpec
+from pipelex.hub import get_concept_library, get_native_concept
+from pipelex.pipe_operators.search.pipe_search import PipeSearch
+from pipelex.pipe_operators.search.pipe_search_blueprint import PipeSearchBlueprint
+
+
+class PipeSearchFactory(PipeFactoryProtocol[PipeSearchBlueprint, PipeSearch]):
+ @classmethod
+ @override
+ def make(
+ cls,
+ pipe_category: Any,
+ pipe_type: str,
+ pipe_code: str,
+ domain_code: str,
+ description: str,
+ inputs: InputStuffSpecs,
+ output: StuffSpec,
+ blueprint: PipeSearchBlueprint,
+ ) -> PipeSearch:
+ concept_library = get_concept_library()
+
+ prompt_blueprint = TemplateBlueprint(
+ template=blueprint.prompt,
+ category=TemplateCategory.BASIC,
+ )
+
+ # Determine if output is structured (not SearchResult)
+ search_result_concept = get_native_concept(native_concept=NativeConceptCode.SEARCH_RESULT)
+ is_structured_output = not concept_library.is_compatible(
+ tested_concept=output.concept,
+ wanted_concept=search_result_concept,
+ strict=True,
+ )
+
+ return PipeSearch(
+ domain_code=domain_code,
+ code=pipe_code,
+ description=description,
+ output=output,
+ inputs=inputs,
+ search_choice=blueprint.model,
+ prompt_blueprint=prompt_blueprint,
+ depth_override=blueprint.depth,
+ include_images_override=blueprint.include_images,
+ max_results_override=blueprint.max_results,
+ from_date=blueprint.from_date,
+ to_date=blueprint.to_date,
+ include_domains=blueprint.include_domains,
+ exclude_domains=blueprint.exclude_domains,
+ is_structured_output=is_structured_output,
+ )
diff --git a/pipelex/pipelex.toml b/pipelex/pipelex.toml
index 2ccc3d7e6..00d6ccbfb 100644
--- a/pipelex/pipelex.toml
+++ b/pipelex/pipelex.toml
@@ -73,6 +73,10 @@ pdf-basic-text-extractor = "@default-text-from-pdf"
image-text-extractor = "@default-extract-image"
full-document-extractor = "@default-extract-document"
+[pipelex.builder_config.talent_preset_mappings.search]
+web-search = "$linkup-standard"
+web-search-deep = "$linkup-deep"
+
[pipelex.feature_config]
# WIP/Experimental feature flags
is_reporting_enabled = true
diff --git a/pipelex/plugins/linkup/__init__.py b/pipelex/plugins/linkup/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/pipelex/plugins/linkup/linkup_search_worker.py b/pipelex/plugins/linkup/linkup_search_worker.py
new file mode 100644
index 000000000..ac038d594
--- /dev/null
+++ b/pipelex/plugins/linkup/linkup_search_worker.py
@@ -0,0 +1,95 @@
+import asyncio
+from datetime import date
+from typing import Any
+
+from linkup import LinkupClient, LinkupSourcedAnswer
+from typing_extensions import override
+
+from pipelex.cogt.search.search_setting import SearchSetting
+from pipelex.cogt.search.search_worker_abstract import SearchWorkerAbstract
+from pipelex.core.stuffs.search_result_content import SearchResultContent, SearchSourceContent
+from pipelex.hub import get_secrets_provider
+
+
+class LinkupSearchWorker(SearchWorkerAbstract):
+ def __init__(self) -> None:
+ api_key = get_secrets_provider().get_secret(secret_id="LINKUP_API_KEY")
+ self._client = LinkupClient(api_key=api_key)
+
+ def _parse_date(self, date_str: str | None) -> date | None:
+ if date_str is None:
+ return None
+ return date.fromisoformat(date_str)
+
+ @override
+ async def search_sourced_answer(
+ self,
+ query: str,
+ search_setting: SearchSetting,
+ include_domains: list[str] | None = None,
+ exclude_domains: list[str] | None = None,
+ from_date: str | None = None,
+ to_date: str | None = None,
+ ) -> SearchResultContent:
+ depth_value = search_setting.depth
+ response: LinkupSourcedAnswer = await asyncio.to_thread(
+ self._client.search,
+ query=query,
+ depth=depth_value, # type: ignore[arg-type]
+ output_type="sourcedAnswer",
+ include_images=search_setting.include_images,
+ include_inline_citations=search_setting.include_inline_citations,
+ max_results=search_setting.max_results,
+ include_domains=include_domains,
+ exclude_domains=exclude_domains,
+ from_date=self._parse_date(from_date),
+ to_date=self._parse_date(to_date),
+ )
+
+ sources: list[SearchSourceContent] = []
+ for source in response.sources:
+ sources.append(
+ SearchSourceContent(
+ name=source.name,
+ url=source.url,
+ snippet=source.snippet,
+ )
+ )
+
+ return SearchResultContent(
+ answer=response.answer,
+ sources=sources,
+ )
+
+ @override
+ async def search_structured(
+ self,
+ query: str,
+ search_setting: SearchSetting,
+ output_schema: type,
+ include_domains: list[str] | None = None,
+ exclude_domains: list[str] | None = None,
+ from_date: str | None = None,
+ to_date: str | None = None,
+ ) -> dict[str, Any]:
+ depth_value = search_setting.depth
+ response = await asyncio.to_thread(
+ self._client.search,
+ query=query,
+ depth=depth_value, # type: ignore[arg-type]
+ output_type="structured",
+ structured_output_schema=output_schema,
+ include_images=search_setting.include_images,
+ max_results=search_setting.max_results,
+ include_domains=include_domains,
+ exclude_domains=exclude_domains,
+ from_date=self._parse_date(from_date),
+ to_date=self._parse_date(to_date),
+ include_sources=True,
+ )
+
+ # If response is a Pydantic model, convert to dict
+ if hasattr(response, "model_dump"):
+ result: dict[str, Any] = response.model_dump()
+ return result
+ return dict(response) # type: ignore[arg-type]
diff --git a/pipelex/system/configuration/configs.py b/pipelex/system/configuration/configs.py
index bb629acf9..da5f03208 100644
--- a/pipelex/system/configuration/configs.py
+++ b/pipelex/system/configuration/configs.py
@@ -103,6 +103,7 @@ class TalentPresetMappings(ConfigModel):
llm: dict[str, str]
img_gen: dict[str, str]
extract: dict[str, str]
+ search: dict[str, str]
class BuilderConfig(ConfigModel):
diff --git a/pipelex/test_extras/shared_pytest_plugins.py b/pipelex/test_extras/shared_pytest_plugins.py
index 6a8d23652..47ec8d5d3 100644
--- a/pipelex/test_extras/shared_pytest_plugins.py
+++ b/pipelex/test_extras/shared_pytest_plugins.py
@@ -41,6 +41,7 @@ ENV_VAR_KEYS_WHICH_MAY_NEED_PLACEHOLDERS_IN_CI = [
"BLACKBOX_API_KEY",
"GOOGLE_API_KEY",
"HF_TOKEN",
+ "LINKUP_API_KEY",
"OPENROUTER_API_KEY",
]
diff --git a/pyproject.toml b/pyproject.toml
index 3a67561e0..7b8f05429 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -28,7 +28,7 @@ dependencies = [
"json2html>=1.3.0",
"kajson==0.3.1",
"markdown>=3.6",
- "mthds>=0.0.7",
+ "mthds>=0.1.0",
"networkx>=3.4.2",
"openai>=1.108.1",
"opentelemetry-api",
@@ -36,7 +36,7 @@ dependencies = [
"opentelemetry-semantic-conventions",
"opentelemetry-sdk",
"pillow>=11.2.1",
- "pipelex-tools>=0.2.1", # plxt CLI for MTHDS/TOML/PLX formatting & linting, needed by client projects too
+ "pipelex-tools>=0.2.3", # plxt CLI for MTHDS/TOML/PLX formatting & linting, needed by client projects too
"polyfactory>=2.21.0",
"portkey-ai>=2.1.0",
"posthog>=6.7.0",
@@ -70,6 +70,7 @@ gcp-storage = ["google-cloud-storage>=2.10.0"]
google = ["google-auth-oauthlib>=1.2.1"]
google-genai = ["google-genai", "instructor[google-genai]"]
huggingface = ["huggingface_hub>=0.23,<1.0.0"]
+linkup = ["linkup-sdk>=0.12.0"]
mistralai = ["mistralai>=1.12.0"]
s3 = ["boto3>=1.34.131", "aioboto3>=13.4.0"]
docs = [
@@ -228,9 +229,9 @@ typeCheckingMode = "strict"
minversion = "9.0"
addopts = [
"--import-mode=importlib",
- "-ra", # Show all test outcomes (including skips)
+ "-ra", # Show all test outcomes (including skips)
"-m",
- "not (inference or llm or img_gen or extract or pipelex_api)",
+ "not (inference or llm or img_gen or extract or search or pipelex_api)",
]
asyncio_default_fixture_loop_scope = "session"
xfail_strict = true
@@ -247,6 +248,7 @@ markers = [
"llm: slow and costly due to llm inference calls",
"img_gen: slow and costly due to image generation inference calls",
"extract: slow and costly due to doc extraction inference calls",
+ "search: slow and costly due to search inference calls",
"gha_disabled: tests that should not run in GitHub Actions",
"codex_disabled: tests that should not run in Codex",
"dry_runnable: tests that can be run in dry-run mode",
diff --git a/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/pipe_search.mthds b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/pipe_search.mthds
new file mode 100644
index 000000000..92f5744e4
--- /dev/null
+++ b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/pipe_search.mthds
@@ -0,0 +1,26 @@
+domain = "pipe_search_e2e"
+description = "Test PipeSearch with sourced search queries"
+
+[pipe.search_news_e2e]
+type = "PipeSearch"
+description = "Search the web for recent news"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-standard"
+prompt = "What's the latest news about $topic in the last 24 hours?"
+
+[pipe.search_sourced_e2e_using_preset]
+type = "PipeSearch"
+description = "Search the web for sourced information using the standard preset"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-standard"
+prompt = "What is $topic?"
+
+[pipe.search_sourced_e2e_deep]
+type = "PipeSearch"
+description = "Search the web for sourced information using the deep preset"
+inputs = { topic = "Text" }
+output = "SearchResult"
+model = "$linkup-deep"
+prompt = "What are the main details about $topic?"
diff --git a/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_data.py b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_data.py
new file mode 100644
index 000000000..8076d5113
--- /dev/null
+++ b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_data.py
@@ -0,0 +1,14 @@
+"""Test data for PipeSearch E2E tests."""
+
+from typing import ClassVar
+
+
+class PipeSearchTestCases:
+ """Test cases for PipeSearch E2E tests."""
+
+ # (variant, pipe_code, input_name, input_value)
+ SOURCED_QUERIES: ClassVar[list[tuple[str, str, str, str]]] = [
+ ("news", "search_news_e2e", "topic", "Middle East"),
+ # ("standard_preset", "search_sourced_e2e_using_preset", "topic", "the capital of France"),
+ # ("deep_preset", "search_sourced_e2e_deep", "topic", "the main causes of climate change"),
+ ]
diff --git a/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_pipe_search.py b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_pipe_search.py
new file mode 100644
index 000000000..857fee64d
--- /dev/null
+++ b/tests/e2e/pipelex/pipes/pipe_operators/pipe_search/test_pipe_search.py
@@ -0,0 +1,56 @@
+"""E2E tests for PipeSearch operator."""
+
+import pytest
+
+from pipelex import pretty_print
+from pipelex.core.stuffs.search_result_content import SearchResultContent
+from pipelex.core.stuffs.text_content import TextContent
+from pipelex.pipe_run.pipe_run_mode import PipeRunMode
+from pipelex.pipeline.runner import PipelexRunner
+from tests.e2e.pipelex.pipes.pipe_operators.pipe_search.test_data import PipeSearchTestCases
+
+LIBRARY_DIRS = ["tests/e2e/pipelex/pipes/pipe_operators/pipe_search"]
+
+
+class TestPipeSearch:
+ """E2E tests for PipeSearch operator."""
+
+ @pytest.mark.parametrize(
+ ("variant", "pipe_code", "input_name", "input_value"),
+ PipeSearchTestCases.SOURCED_QUERIES,
+ )
+ async def test_search_sourced(
+ self,
+ pipe_run_mode: PipeRunMode,
+ variant: str,
+ pipe_code: str,
+ input_name: str,
+ input_value: str,
+ ) -> None:
+ """Test a sourced web search that returns an answer with sources."""
+ runner = PipelexRunner(
+ library_dirs=LIBRARY_DIRS,
+ pipe_run_mode=pipe_run_mode,
+ )
+ pipeline_response = await runner.execute_pipeline(
+ pipe_code=pipe_code,
+ inputs={
+ input_name: TextContent(text=input_value),
+ },
+ )
+
+ pipe_output = pipeline_response.pipe_output
+ assert pipe_output is not None
+ assert pipe_output.working_memory is not None
+ assert pipe_output.main_stuff is not None
+
+ if pipe_run_mode.is_live:
+ search_result = pipe_output.main_stuff_as(content_type=SearchResultContent)
+ assert search_result.answer is not None
+ assert len(search_result.answer.strip()) > 0
+ assert len(search_result.sources) > 0
+ pretty_print(search_result, title=f"Search Result ({variant})")
diff --git a/tests/integration/pipelex/cogt/test_data.py b/tests/integration/pipelex/cogt/test_data.py
index 67104f4f3..6539f91a0 100644
--- a/tests/integration/pipelex/cogt/test_data.py
+++ b/tests/integration/pipelex/cogt/test_data.py
@@ -234,6 +234,21 @@ class SerDeTestLLMCases:
]
+class SearchTestCases:
+ """Test cases for search integration tests."""
+
+ SOURCED_ANSWER_QUERIES: ClassVar[list[tuple[str, str]]] = [ # topic, query
+ ("Middle East", "Latest events in the middle east"),
+ # ("Capital of France", "What is the capital of France?"),
+ # ("Python creator", "Who created the Python programming language?"),
+ ]
+
+ STRUCTURED_QUERIES: ClassVar[list[tuple[str, str]]] = [ # topic, query
+ ("Python language", "What is the Python programming language and what are its main features?"),
+ ("Machine learning", "What is machine learning and its main applications?"),
+ ]
+
+
class LLMReasoningTestCases:
"""Test cases for LLM reasoning/thinking integration tests."""
diff --git a/tests/integration/pipelex/cogt/test_search.py b/tests/integration/pipelex/cogt/test_search.py
new file mode 100644
index 000000000..82eedbbfb
--- /dev/null
+++ b/tests/integration/pipelex/cogt/test_search.py
@@ -0,0 +1,63 @@
+import pytest
+from pydantic import BaseModel
+
+from pipelex import pretty_print
+from pipelex.cogt.search.search_depth import SearchDepth
+from pipelex.cogt.search.search_setting import SearchSetting
+from pipelex.cogt.search.search_worker_factory import get_search_worker
+from tests.integration.pipelex.cogt.test_data import SearchTestCases
+
+
+class TopicSummary(BaseModel):
+ title: str
+ summary: str
+ key_points: list[str]
+
+
[email protected](loop_scope="class")
+class TestSearch:
+ @pytest.mark.parametrize(
+ ("topic", "query"),
+ SearchTestCases.SOURCED_ANSWER_QUERIES,
+ )
+ async def test_search_sourced_answer(self, topic: str, query: str) -> None:
+ """Verify that search_sourced_answer returns a non-empty answer with sources."""
+ worker = get_search_worker("linkup/standard")
+ search_setting = SearchSetting(
+ model="linkup/standard",
+ depth=SearchDepth.STANDARD,
+ )
+ result = await worker.search_sourced_answer(
+ query=query,
+ search_setting=search_setting,
+ )
+ pretty_print(result, title=f"Sourced Answer Result ({topic})")
+ assert result.answer, "Expected a non-empty answer"
+ assert len(result.sources) > 0, "Expected at least one source"
+ for source in result.sources:
+ assert source.name, "Expected source to have a name"
+ assert source.url, "Expected source to have a URL"
+
+ @pytest.mark.parametrize(
+ ("topic", "query"),
+ SearchTestCases.STRUCTURED_QUERIES,
+ )
+ async def test_search_structured(self, topic: str, query: str) -> None:
+ """Verify that search_structured returns a dict with the expected schema keys."""
+ worker = get_search_worker("linkup/standard")
+ search_setting = SearchSetting(
+ model="linkup/standard",
+ depth=SearchDepth.STANDARD,
+ )
+ result = await worker.search_structured(
+ query=query,
+ search_setting=search_setting,
+ output_schema=TopicSummary,
+ )
+ pretty_print(result, title=f"Structured Search Result ({topic})")
+ assert isinstance(result, dict), "Expected a dict result"
+ assert "title" in result, "Expected 'title' key in result"
+ assert "summary" in result, "Expected 'summary' key in result"
+ assert "key_points" in result, "Expected 'key_points' key in result"
diff --git a/tests/integration/pipelex/cogt/test_setup_inference_workers.py b/tests/integration/pipelex/cogt/test_setup_inference_workers.py
index 820e7dbe2..de8a85060 100644
--- a/tests/integration/pipelex/cogt/test_setup_inference_workers.py
+++ b/tests/integration/pipelex/cogt/test_setup_inference_workers.py
@@ -16,3 +16,5 @@ class TestSetupInferenceWorkers:
_ = inference_manager.get_extract_worker(extract_handle=model_handle)
case ModelType.IMG_GEN:
_ = inference_manager.get_img_gen_worker(img_gen_handle=model_handle)
+ case ModelType.SEARCH:
+ pass
diff --git a/tests/unit/pipelex/cli/test_agent_models_cmd.py b/tests/unit/pipelex/cli/test_agent_models_cmd.py
index 829dfadcf..b80f2d4a0 100644
--- a/tests/unit/pipelex/cli/test_agent_models_cmd.py
+++ b/tests/unit/pipelex/cli/test_agent_models_cmd.py
@@ -26,10 +26,11 @@ class _FakeSetting:
class _FakeTalentMappings:
"""Minimal stand-in for TalentPresetMappings."""
- def __init__(self, llm: dict[str, str], img_gen: dict[str, str], extract: dict[str, str]):
+ def __init__(self, llm: dict[str, str], img_gen: dict[str, str], extract: dict[str, str], search: dict[str, str] | None = None):
self.llm = llm
self.img_gen = img_gen
self.extract = extract
+ self.search = search or {}
class _FakeBuilderConfig:
@@ -97,12 +98,17 @@ def _make_fake_model_deck() -> Any:
llm_presets = TestData.LLM_PRESETS
extract_presets = TestData.EXTRACT_PRESETS
img_gen_presets = TestData.IMG_GEN_PRESETS
+ search_presets: ClassVar[dict[str, Any]] = {}
+
llm_aliases = TestData.LLM_ALIASES
extract_aliases = TestData.EXTRACT_ALIASES
img_gen_aliases = TestData.IMG_GEN_ALIASES
+ search_aliases: ClassVar[dict[str, str]] = {}
+
llm_waterfalls = TestData.LLM_WATERFALLS
extract_waterfalls = TestData.EXTRACT_WATERFALLS
img_gen_waterfalls = TestData.IMG_GEN_WATERFALLS
+ search_waterfalls: ClassVar[dict[str, list[str]]] = {}
def get_optional_inference_model(self, model_handle: str, model_type: ModelType) -> _FakeInferenceModelSpec | None:
entry = TestData.INFERENCE_MAP.get(model_handle)
diff --git a/tests/unit/pipelex/cli/test_installed_methods.py b/tests/unit/pipelex/cli/test_installed_methods.py
index e04078902..b06757d73 100644
--- a/tests/unit/pipelex/cli/test_installed_methods.py
+++ b/tests/unit/pipelex/cli/test_installed_methods.py
@@ -46,13 +46,13 @@ class TestDiscoverMethodsFromLibraryDirs:
def test_discovers_method_with_manifest(self, tmp_path: Path) -> None:
"""A directory containing METHODS.toml is discovered as an installed method."""
method_dir = tmp_path / "my-method"
- _write_manifest(method_dir, name="my-method")
+ _write_manifest(method_dir, name="my_method")
(method_dir / "core.mthds").write_text("# placeholder", encoding="utf-8")
results = discover_methods_from_library_dirs([str(method_dir)])
assert len(results) == 1
- assert results[0].name == "my-method"
+ assert results[0].name == "my_method"
assert results[0].path == method_dir.resolve()
assert len(results[0].mthds_files) == 1
assert results[0].mthds_files[0].name == "core.mthds"
@@ -76,7 +76,7 @@ class TestDiscoverMethodsFromLibraryDirs:
def test_deduplicates_by_resolved_path(self, tmp_path: Path) -> None:
"""The same directory passed multiple times yields only one method."""
method_dir = tmp_path / "dup-method"
- _write_manifest(method_dir, name="dup-method")
+ _write_manifest(method_dir, name="dup_method")
results = discover_methods_from_library_dirs([str(method_dir), str(method_dir)])
@@ -98,11 +98,11 @@ class TestDiscoverMethodsFromLibraryDirs:
parent_dir.mkdir()
method_a = parent_dir / "method-a"
- _write_manifest(method_a, name="method-a", address_suffix="a")
+ _write_manifest(method_a, name="method_a", address_suffix="a")
(method_a / "a.mthds").write_text("# placeholder", encoding="utf-8")
method_b = parent_dir / "method-b"
- _write_manifest(method_b, name="method-b", address_suffix="b")
+ _write_manifest(method_b, name="method_b", address_suffix="b")
(method_b / "b.mthds").write_text("# placeholder", encoding="utf-8")
# A non-method subdirectory (no METHODS.toml) should be ignored
@@ -112,7 +112,7 @@ class TestDiscoverMethodsFromLibraryDirs:
assert len(results) == 2
names = {result.name for result in results}
- assert names == {"method-a", "method-b"}
+ assert names == {"method_a", "method_b"}
def test_discovers_methods_nested_deeply(self, tmp_path: Path) -> None:
"""When -L points to a grandparent dir, methods nested multiple levels deep are found."""
@@ -120,29 +120,29 @@ class TestDiscoverMethodsFromLibraryDirs:
root_dir = tmp_path / "project"
root_dir.mkdir()
method_dir = root_dir / "methods" / "cv-analyzer"
- _write_manifest(method_dir, name="cv-analyzer", address_suffix="cv")
+ _write_manifest(method_dir, name="cv_analyzer", address_suffix="cv")
(method_dir / "cv.mthds").write_text("# placeholder", encoding="utf-8")
results = discover_methods_from_library_dirs([str(root_dir)])
assert len(results) == 1
- assert results[0].name == "cv-analyzer"
+ assert results[0].name == "cv_analyzer"
def test_find_method_by_name_with_library_dirs(self, tmp_path: Path) -> None:
"""find_method_by_name discovers a method via library_dirs when not in standard locations."""
method_dir = tmp_path / "lib-method"
- _write_manifest(method_dir, name="lib-method")
+ _write_manifest(method_dir, name="lib_method")
(method_dir / "lib.mthds").write_text("# placeholder", encoding="utf-8")
- result = find_method_by_name("lib-method", methods=[], library_dirs=[str(method_dir)])
+ result = find_method_by_name("lib_method", methods=[], library_dirs=[str(method_dir)])
- assert result.name == "lib-method"
+ assert result.name == "lib_method"
assert result.path == method_dir.resolve()
def test_find_method_by_name_not_found_raises(self, tmp_path: Path) -> None:
"""MethodNotFoundError is raised when the method is absent from both standard and library dirs."""
method_dir = tmp_path / "other-method"
- _write_manifest(method_dir, name="other-method")
+ _write_manifest(method_dir, name="other_method")
with pytest.raises(MethodNotFoundError):
find_method_by_name("nonexistent", methods=[], library_dirs=[str(method_dir)])
@@ -150,20 +150,20 @@ class TestDiscoverMethodsFromLibraryDirs:
def test_find_method_by_name_duplicate_raises(self, tmp_path: Path) -> None:
"""DuplicateMethodNameError is raised when same name appears in standard and library dirs."""
method_dir = tmp_path / "dup"
- _write_manifest(method_dir, name="dup-name", address_suffix="pkg2")
+ _write_manifest(method_dir, name="dup_name", address_suffix="pkg2")
(method_dir / "dup.mthds").write_text("# placeholder", encoding="utf-8")
# Simulate a pre-discovered method with the same name but different path
other_dir = tmp_path / "other-dup"
- _write_manifest(other_dir, name="dup-name", address_suffix="pkg3")
+ _write_manifest(other_dir, name="dup_name", address_suffix="pkg3")
manifest_content = (other_dir / MANIFEST_FILENAME).read_text(encoding="utf-8")
pre_existing = InstalledMethod(
- name="dup-name",
+ name="dup_name",
path=other_dir.resolve(),
manifest=parse_methods_toml(manifest_content),
mthds_files=[],
)
with pytest.raises(DuplicateMethodNameError):
- find_method_by_name("dup-name", methods=[pre_existing], library_dirs=[str(method_dir)])
+ find_method_by_name("dup_name", methods=[pre_existing], library_dirs=[str(method_dir)])
diff --git a/tests/unit/pipelex/cli/test_method_resolver.py b/tests/unit/pipelex/cli/test_method_resolver.py
index b74f55f70..202a50cc6 100644
--- a/tests/unit/pipelex/cli/test_method_resolver.py
+++ b/tests/unit/pipelex/cli/test_method_resolver.py
@@ -28,7 +28,7 @@ MINIMAL_MANIFEST = """\
address = "github.com/test/remote-method"
version = "0.1.0"
description = "A remote test method"
-name = "remote-method"
+name = "remote_method"
main_pipe = "test_pipe"
[exports.test]
@@ -111,7 +111,7 @@ class TestResolveMethodTarget:
method = resolve_method_from_url("https://github.com/test/remote-method")
- assert method.name == "remote-method"
+ assert method.name == "remote_method"
assert method.manifest.main_pipe == "test_pipe"
assert len(method.mthds_files) == 1
@@ -128,7 +128,7 @@ class TestResolveMethodTarget:
method = resolve_method_from_url("https://github.com/test/repo/methods/my-method")
- assert method.name == "remote-method"
+ assert method.name == "remote_method"
assert method.manifest.main_pipe == "test_pipe"
def test_resolve_method_from_url_clone_failure(self, mocker: MockerFixture, tmp_path: Path) -> None:
@@ -168,7 +168,7 @@ class TestResolveMethodTarget:
pipe_code, lib_dirs, method = resolve_method_target("https://github.com/test/remote-method")
assert pipe_code == "test_pipe"
- assert method.name == "remote-method"
+ assert method.name == "remote_method"
assert len(lib_dirs) == 1
@pytest.mark.parametrize(
@@ -196,7 +196,7 @@ class TestResolveMethodTarget:
method = resolve_method_from_path(str(method_dir))
- assert method.name == "remote-method"
+ assert method.name == "remote_method"
assert method.manifest.main_pipe == "test_pipe"
assert len(method.mthds_files) == 1
@@ -221,5 +221,5 @@ class TestResolveMethodTarget:
pipe_code, lib_dirs, method = resolve_method_target(str(method_dir))
assert pipe_code == "test_pipe"
- assert method.name == "remote-method"
+ assert method.name == "remote_method"
assert len(lib_dirs) == 1
diff --git a/tests/unit/pipelex/cogt/models/test_model_deck.py b/tests/unit/pipelex/cogt/models/test_model_deck.py
index 25bc578cd..0514804b2 100644
--- a/tests/unit/pipelex/cogt/models/test_model_deck.py
+++ b/tests/unit/pipelex/cogt/models/test_model_deck.py
@@ -8,6 +8,7 @@ from pipelex.cogt.llm.thinking_mode import ThinkingMode
from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
from pipelex.cogt.model_backends.model_type import ModelType
from pipelex.cogt.models.model_deck import ModelDeck
+from pipelex.cogt.search.search_depth import SearchDepth
from pipelex.cogt.usage.cost_category import CostCategory
from pipelex.system.runtime import ProblemReaction
@@ -56,6 +57,9 @@ class TestModelDeckGetOptionalInferenceModel:
img_gen_waterfalls={},
img_gen_presets={},
img_gen_choice_default="gen_image_basic",
+ # Search-specific
+ search_default_depth=SearchDepth.STANDARD,
+ search_choice_default="@default-search",
model_deck_config=ModelDeckConfig(is_model_fallback_enabled=is_model_fallback_enabled, missing_presets_reaction=ProblemReaction.NONE),
)
@@ -331,6 +335,9 @@ class TestModelDeckPrefixedAliasReferences:
img_gen_waterfalls={},
img_gen_presets={},
img_gen_choice_default="gen_image_basic",
+ # Search-specific
+ search_default_depth=SearchDepth.STANDARD,
+ search_choice_default="@default-search",
model_deck_config=ModelDeckConfig(is_model_fallback_enabled=is_model_fallback_enabled, missing_presets_reaction=ProblemReaction.NONE),
)
@@ -482,6 +489,9 @@ class TestModelDeckGetLLMSettingWithPresets:
img_gen_waterfalls={},
img_gen_presets={},
img_gen_choice_default="gen_image_basic",
+ # Search-specific
+ search_default_depth=SearchDepth.STANDARD,
+ search_choice_default="@default-search",
model_deck_config=ModelDeckConfig(is_model_fallback_enabled=False, missing_presets_reaction=ProblemReaction.NONE),
)
diff --git a/tests/unit/pipelex/cogt/models/test_model_deck_references.py b/tests/unit/pipelex/cogt/models/test_model_deck_references.py
index a612ec92c..cd60574df 100644
--- a/tests/unit/pipelex/cogt/models/test_model_deck_references.py
+++ b/tests/unit/pipelex/cogt/models/test_model_deck_references.py
@@ -18,6 +18,7 @@ from pipelex.cogt.models.model_deck import (
from pipelex.cogt.models.model_deck_loader import load_model_deck_blueprint
from pipelex.cogt.models.model_manager import ModelManager
from pipelex.cogt.models.model_reference import ModelReference, ModelReferenceKind
+from pipelex.cogt.search.search_setting import SearchSetting
from pipelex.system.configuration.config_loader import config_manager
from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher
from pipelex.tools.misc.file_utils import find_files_in_dir
@@ -114,7 +115,7 @@ class TestModelDeckReferences:
def _find_invalid_preset_references(
self,
- presets: dict[str, LLMSetting] | dict[str, ExtractSetting] | dict[str, ImgGenSetting],
+ presets: dict[str, LLMSetting] | dict[str, ExtractSetting] | dict[str, ImgGenSetting] | dict[str, SearchSetting],
all_aliases: dict[str, str],
all_waterfalls: dict[str, list[str]],
known_model_handles: dict[str, ModelType],
@@ -175,6 +176,8 @@ class TestModelDeckReferences:
return model_deck_blueprint.extract
case ModelType.IMG_GEN:
return model_deck_blueprint.img_gen
+ case ModelType.SEARCH:
+ return model_deck_blueprint.search
@pytest.mark.parametrize(
("model_type", "deck_name"),
@@ -182,6 +185,7 @@ class TestModelDeckReferences:
(ModelType.LLM, "LLM"),
(ModelType.TEXT_EXTRACTOR, "Extract"),
(ModelType.IMG_GEN, "ImgGen"),
+ (ModelType.SEARCH, "Search"),
],
)
def test_aliases_reference_valid_targets(
@@ -214,6 +218,7 @@ class TestModelDeckReferences:
(ModelType.LLM, "LLM"),
(ModelType.TEXT_EXTRACTOR, "Extract"),
(ModelType.IMG_GEN, "ImgGen"),
+ (ModelType.SEARCH, "Search"),
],
)
def test_presets_reference_valid_models(
@@ -246,6 +251,7 @@ class TestModelDeckReferences:
(ModelType.LLM, "LLM"),
(ModelType.TEXT_EXTRACTOR, "Extract"),
(ModelType.IMG_GEN, "ImgGen"),
+ (ModelType.SEARCH, "Search"),
],
)
def test_waterfalls_contain_valid_models(
@@ -277,6 +283,7 @@ class TestModelDeckReferences:
(ModelType.LLM, "LLM"),
(ModelType.TEXT_EXTRACTOR, "Extract"),
(ModelType.IMG_GEN, "ImgGen"),
+ (ModelType.SEARCH, "Search"),
],
)
def test_aliases_no_circular_references(
diff --git a/tests/unit/pipelex/language/test_mthds_schema.py b/tests/unit/pipelex/language/test_mthds_schema.py
index 9b339973b..1b17254f1 100644
--- a/tests/unit/pipelex/language/test_mthds_schema.py
+++ b/tests/unit/pipelex/language/test_mthds_schema.py
@@ -98,6 +98,7 @@ class TestMthdsSchemaGeneration:
"PipeComposeBlueprint",
"PipeLLMBlueprint",
"PipeExtractBlueprint",
+ "PipeSearchBlueprint",
"PipeBatchBlueprint",
"PipeConditionBlueprint",
"PipeParallelBlueprint",
@@ -107,8 +108,8 @@ class TestMthdsSchemaGeneration:
for blueprint_name in expected_blueprint_names:
assert blueprint_name in definitions, f"{blueprint_name} should be present in schema definitions"
- # Also verify we have 9 pipe types matching the PipeType enum
- assert len(PipeType.value_list()) == 9, "Should have exactly 9 pipe types"
+ # Also verify we have 10 pipe types matching the PipeType enum
+ assert len(PipeType.value_list()) == 10, "Should have exactly 10 pipe types"
def test_construct_schema_matches_mthds_format(self, schema: dict[str, Any]) -> None:
"""Verify ConstructBlueprint uses additionalProperties, not 'fields' wrapper."""
diff --git a/uv.lock b/uv.lock
index 09433d4ab..9f9291240 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1876,6 +1876,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b2/c8/d148e041732d631fc76036f8b30fae4e77b027a1e95b7a84bb522481a940/librt-0.8.1-cp314-cp314t-win_arm64.whl", hash = "sha256:bf512a71a23504ed08103a13c941f763db13fb11177beb3d9244c98c29fb4a61", size = 48755, upload-time = "2026-02-17T16:12:47.943Z" },
]
+[[package]]
+name = "linkup-sdk"
+version = "0.12.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "httpx" },
+ { name = "pydantic" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/cb/bd/3b7a03430b25e971cc75242725e44e90373b116926918939a2132c94fed2/linkup_sdk-0.12.0.tar.gz", hash = "sha256:1ae72141d9576ed7442770d2d4adf65e22351869e97f8efba1250ead5bbfd0a1", size = 76083, upload-time = "2026-02-16T18:02:14.089Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/57/1c/52dfe0bf0cff747bbde6656293d1cf1eb9906a4b7dabf6fa5f2a994f25a6/linkup_sdk-0.12.0-py3-none-any.whl", hash = "sha256:8f675748ff6ab9ed62ee4e20377e8535f6f5c0bc3fba3b766b89ca0ad101c520", size = 11492, upload-time = "2026-02-16T18:02:12.427Z" },
+]
+
[[package]]
name = "lxml"
version = "6.0.2"
@@ -2393,7 +2406,7 @@ wheels = [
[[package]]
name = "mthds"
-version = "0.0.7"
+version = "0.1.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "backports-strenum", marker = "python_full_version < '3.11'" },
@@ -2404,9 +2417,9 @@ dependencies = [
{ name = "tomlkit" },
{ name = "typing-extensions" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/ba/09/9291d9dee7ea35a49eee3119a3ba26059038d0a9ed719aec76ba9d824b05/mthds-0.0.7.tar.gz", hash = "sha256:ef36899caa41d07a75662bc142d9068a789e2f5050ac94c96c6fa93baa80518b", size = 112046, upload-time = "2026-03-02T01:07:31.42Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/61/93/5b95749725fa69a764e6c10cb1c0e90a728f9ce2419c821dcee20dcfe8e3/mthds-0.1.0.tar.gz", hash = "sha256:010f1a7155251ddb6a86467564f4d9241fec8328ac4223f4dca348b4131a7c2c", size = 112115, upload-time = "2026-03-02T18:02:11.334Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/57/7b/c6919613a73480f6070f7eca2a23d69fa4b402548fd3fc427a2708c91ee3/mthds-0.0.7-py3-none-any.whl", hash = "sha256:a53565819f414c8d2f1f9af3ff64c23ad2fd7d96a1299a171750f666c2139eb9", size = 49165, upload-time = "2026-03-02T01:07:29.949Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/c1/573c636947bd7241d4a4116f8fe317f2dc44c268e5ccfaafa4339c0cd30d/mthds-0.1.0-py3-none-any.whl", hash = "sha256:f580a33b0b710dfd9d2c999ba996baf3307f8b4dbe5fbecabc0685730feebe83", size = 49143, upload-time = "2026-03-02T18:02:09.98Z" },
]
[[package]]
@@ -3392,6 +3405,9 @@ google-genai = [
huggingface = [
{ name = "huggingface-hub" },
]
+linkup = [
+ { name = "linkup-sdk" },
+]
mistralai = [
{ name = "mistralai" },
]
@@ -3423,6 +3439,7 @@ requires-dist = [
{ name = "jinja2", specifier = ">=3.1.4" },
{ name = "json2html", specifier = ">=1.3.0" },
{ name = "kajson", specifier = "==0.3.1" },
+ { name = "linkup-sdk", marker = "extra == 'linkup'", specifier = ">=0.12.0" },
{ name = "markdown", specifier = ">=3.6" },
{ name = "mike", marker = "extra == 'docs'", specifier = ">=2.1.3" },
{ name = "mistralai", marker = "extra == 'mistralai'", specifier = ">=1.12.0" },
@@ -3431,7 +3448,7 @@ requires-dist = [
{ name = "mkdocs-material", marker = "extra == 'docs'", specifier = ">=9.6.14" },
{ name = "mkdocs-meta-manager", marker = "extra == 'docs'", specifier = ">=1.1.0" },
{ name = "moto", extras = ["s3"], marker = "extra == 'dev'", specifier = ">=5.0.0" },
- { name = "mthds", specifier = ">=0.0.7" },
+ { name = "mthds", specifier = ">=0.1.0" },
{ name = "mypy", marker = "extra == 'dev'", specifier = "==1.19.1" },
{ name = "networkx", specifier = ">=3.4.2" },
{ name = "openai", specifier = ">=1.108.1" },
@@ -3440,7 +3457,7 @@ requires-dist = [
{ name = "opentelemetry-sdk" },
{ name = "opentelemetry-semantic-conventions" },
{ name = "pillow", specifier = ">=11.2.1" },
- { name = "pipelex-tools", specifier = ">=0.2.1" },
+ { name = "pipelex-tools", specifier = ">=0.2.3" },
{ name = "polyfactory", specifier = ">=2.21.0" },
{ name = "portkey-ai", specifier = ">=2.1.0" },
{ name = "posthog", specifier = ">=6.7.0" },
@@ -3471,21 +3488,21 @@ requires-dist = [
{ name = "types-pyyaml", marker = "extra == 'dev'", specifier = ">=6.0.12.20250326" },
{ name = "typing-extensions", specifier = ">=4.13.2" },
]
-provides-extras = ["anthropic", "bedrock", "docling", "fal", "gcp-storage", "google", "google-genai", "huggingface", "mistralai", "s3", "docs", "dev"]
+provides-extras = ["anthropic", "bedrock", "docling", "fal", "gcp-storage", "google", "google-genai", "huggingface", "linkup", "mistralai", "s3", "docs", "dev"]
[[package]]
name = "pipelex-tools"
-version = "0.2.1"
+version = "0.2.3"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/92/1e/499a5d8a4fbf1ac74a4cb1e9dbde9802e10b3eadca42fef00b1ee9caaea8/pipelex_tools-0.2.1.tar.gz", hash = "sha256:018a1ece8cd8e73cf2c236d150e7a74dc15359b00dc8183f58412e8d6c132f73", size = 149465, upload-time = "2026-02-28T01:01:58.508Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/e0/ca/668744389488c7f671bacb8ba0dd5f568a67e5b6324665a65f7383cc1b65/pipelex_tools-0.2.3.tar.gz", hash = "sha256:4b0d675fbc1a024105b1469365ce2c967e9673a87941d1c121209609584fd0ce", size = 155922, upload-time = "2026-03-02T11:26:56.683Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/8d/0d/585744f155be37d69c407dcc047677f68dfbc1ec0e13367cfdddb3366397/pipelex_tools-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:03b8277b6b0edb95fb3b8b0fb8358e2b230313e9e3115cfb50987866057a0ba4", size = 5097404, upload-time = "2026-02-28T01:01:45.439Z" },
- { url = "https://files.pythonhosted.org/packages/19/99/2a50094ab6fec077ffadcb09bf49369a836ebe326a19aa0aeb907677be1f/pipelex_tools-0.2.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:060761a144e2b5c5dc572ccf2ccc571156be7b8408dfa7c779688666480100e6", size = 4838895, upload-time = "2026-02-28T01:01:47.661Z" },
- { url = "https://files.pythonhosted.org/packages/fc/49/a3a3c246f50cc5cefb5518b72b946e86e963a87dc9385e5f97f7e72b35d0/pipelex_tools-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81604d90eab7bffb89b109e1ca18777db938ca4557adf45da8f3ac38ce90ae0d", size = 4978346, upload-time = "2026-02-28T01:01:49.788Z" },
- { url = "https://files.pythonhosted.org/packages/17/95/f3b60c8b90d2abeff46cc3e59b77071e4d258f2b35d5a3cce8b4a67eb525/pipelex_tools-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f2fc76f51ee65e29e0a673a780360935d40b55097e6f046b5fc5269b2bb2720", size = 5230424, upload-time = "2026-02-28T01:01:51.492Z" },
- { url = "https://files.pythonhosted.org/packages/72/c8/9b0cdf2ab4e9e6e87b70b78c46631022f5c27b8d025a88e1bc47cd83fbba/pipelex_tools-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cd7e1420f09740d2a28544c2d3d479f99499ba5ef4c9457e6f668ea2d348b3e4", size = 5235486, upload-time = "2026-02-28T01:01:53.453Z" },
- { url = "https://files.pythonhosted.org/packages/6c/7c/2c75321faa1441c843026a2dc048e87d3e5fc1feb5ba9ecedcbaf0839765/pipelex_tools-0.2.1-py3-none-win32.whl", hash = "sha256:3292c8685a2b8007f19f7a1be225d3c2ce57ddb86e28be69d77f7d32c61dd433", size = 4609751, upload-time = "2026-02-28T01:01:55Z" },
- { url = "https://files.pythonhosted.org/packages/52/d3/ae5f1cdf87fff4862b55ae169dd87ea0f2c0fc42f2eca06a0a2829a213cc/pipelex_tools-0.2.1-py3-none-win_amd64.whl", hash = "sha256:c5ec0c4d36052143e7b5cd5b89224abc8242bb75f6fae574610fa09583457aa8", size = 5414812, upload-time = "2026-02-28T01:01:56.772Z" },
+ { url = "https://files.pythonhosted.org/packages/ba/be/f3874fccffbc505398bf56e8c60be75c020fd66879d4b7d561c7705b95ce/pipelex_tools-0.2.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:69291f39de3b71f6a80c376e708b22bd4e7a4f039ff24aa02fb9c2adecc03840", size = 5115708, upload-time = "2026-03-02T11:26:43.034Z" },
+ { url = "https://files.pythonhosted.org/packages/46/04/a6e684e411fd4eaca2732482ce044aa96b22558189f0cade4b8e8bb78e45/pipelex_tools-0.2.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:2779d33e6e9edb9ef5ab19f32df6fa8fc92ffda0c231932021734bf98b4ccb26", size = 4853727, upload-time = "2026-03-02T11:26:45.151Z" },
+ { url = "https://files.pythonhosted.org/packages/99/ad/fb85576c8348ea96bc8051aa52adef6d2bb8430b5cfba51679eee7f9829d/pipelex_tools-0.2.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:159e3b96e9a74f0120aaaca95415f57c8a86f6ab4f47771662577dff9a1ad022", size = 4996364, upload-time = "2026-03-02T11:26:47.442Z" },
+ { url = "https://files.pythonhosted.org/packages/a3/97/eefa601badb2ff49913d22dd2ec03b73aabd6bcfade7b5af38e1db7a46ba/pipelex_tools-0.2.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed514649d4a3c2373b1f20d4c8fa2c6f85319d79fc86f36096046a8a5a05bb3e", size = 5243310, upload-time = "2026-03-02T11:26:49.521Z" },
+ { url = "https://files.pythonhosted.org/packages/83/5b/231cb448d42ac9266c01bfe8935c30d9e1961c1c48f66eefac16988da456/pipelex_tools-0.2.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:38a19f696d56e7ca84f353937ce915d883cb342e1124ec7fa599b0a2e33648b3", size = 5254906, upload-time = "2026-03-02T11:26:51.657Z" },
+ { url = "https://files.pythonhosted.org/packages/87/a0/6071eaf43f2f9848093d92aa852497266987977b18b039b92ffa86465577/pipelex_tools-0.2.3-py3-none-win32.whl", hash = "sha256:354cc786b3896755c4b14335cc946c76efe906400bae91a32cbd05d74d5b0dd5", size = 4623952, upload-time = "2026-03-02T11:26:53.3Z" },
+ { url = "https://files.pythonhosted.org/packages/70/40/7c1a020f8ec519dd401352782a78d143d3ea7df50535ebe91fa0218f6e59/pipelex_tools-0.2.3-py3-none-win_amd64.whl", hash = "sha256:682c210e3c028ffe586a70f13e26ed0ec5c11b2624da3a4a4c17e4f64c956a88", size = 5430191, upload-time = "2026-03-02T11:26:54.939Z" },
]
[[package]]