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.

feature/pipelex-client-and-rename-report-delegate (#52)

Thomas Hebrard7b7b939dada7
diff --git a/.env.example b/.env.example
index fb1897997..b0db2e3f1 100644
--- a/.env.example
+++ b/.env.example
@@ -1,5 +1,8 @@
PYRIGHT_PYTHON_FORCE_VERSION=1.1.398
+PIPELEX_API_TOKEN=
+PIPELEX_API_BASE_URL=https://app.pipelex.ai/api/v1
+
OPENAI_API_KEY=
AWS_ACCESS_KEY_ID=
diff --git a/README.md b/README.md
index 3685af8fd..c22966a75 100644
--- a/README.md
+++ b/README.md
@@ -84,20 +84,28 @@ We **highly** recommend installing an extension for TOML files into your IDE of
### Optional Features
-The package supports additional features that can be installed separately:
+The package supports the following additional features:
+- `anthropic`: Anthropic/Claude support
+- `google`: Google models (Vertex) support
+- `mistralai`: Mistral AI support
+- `bedrock`: AWS Bedrock support
+- `fal`: Image generation with Black Forest Labs "FAL" service
+
+Install all extras:
+
+Using `pip`:
```bash
-# Using pip
-pip install "pipelex[anthropic]" # For Anthropic/Claude support
-pip install "pipelex[google]" # For Google API support
-pip install "pipelex[mistralai]" # For Mistral AI support
-pip install "pipelex[bedrock]" # For AWS Bedrock support
-pip install "pipelex[fal]" # For image generation with Black Forest Labs "FAL" service
+pip install "pipelex[anthropic,google,mistralai,bedrock,fal]"
+```
-# Using poetry
-poetry add "pipelex[anthropic,google,mistralai,bedrock,fal]" # Install all features
+Using `poetry`:
+```bash
+poetry add "pipelex[anthropic,google,mistralai,bedrock,fal]"
+```
-# Using uv
+Using `uv`:
+```bash
uv pip install "pipelex[anthropic,google,mistralai,bedrock,fal]"
```
@@ -105,6 +113,12 @@ uv pip install "pipelex[anthropic,google,mistralai,bedrock,fal]"
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started, including development setup and testing information.
+## 👥 Join the Community
+
+Join our vibrant Discord community to connect with other developers, share your experiences, and get help with your Pipelex projects!
+
+[![Discord](https://img.shields.io/badge/Discord-5865F2?logo=discord&logoColor=white)](https://discord.gg/SReshKQjWt)
+
## 💬 Support
- **GitHub Issues**: For bug reports and feature requests
@@ -115,10 +129,6 @@ We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.
If you find Pipelex helpful, please consider giving us a star! It helps us reach more developers and continue improving the tool.
-## 👥 Contributors
-
-Contributions are welcome, check out our [Contributing to Pipelex](CONTRIBUTING.md) guide.
-
## 📝 License
This project is licensed under the [MIT license](LICENSE). Runtime dependencies are distributed under their own licenses via PyPI.
diff --git a/doc/pages/Quick-start/Quick-start.md b/doc/pages/Quick-start/Quick-start.md
index 6038b060d..19203f3e3 100644
--- a/doc/pages/Quick-start/Quick-start.md
+++ b/doc/pages/Quick-start/Quick-start.md
@@ -208,7 +208,7 @@ Your task is to extract specific data from the following description.
```python
from pipelex.core.stuff_factory import StuffFactory
-from pipelex.run import run_pipe_code
+from pipelex.client.client import PipelexClient
from pipelex_libraries.pipeline.characters import Character, CharacterMetadata
async def process_existing_character():
@@ -236,7 +236,8 @@ async def process_existing_character():
stuff=character_stuff,
)
# Run the pipe identified by its pipe_code (it's the name of the pipe)
- pipe_output = await run_pipe_code(
+ pipelex_client = PipelexClient()
+ pipe_output = await pipelex_client.execute_pipeline(
pipe_code="extract_character_1",
working_memory=working_memory,
)
diff --git a/pipelex/client/api_client.py b/pipelex/client/api_client.py
deleted file mode 100644
index a395e642d..000000000
--- a/pipelex/client/api_client.py
+++ /dev/null
@@ -1,159 +0,0 @@
-from typing import Any, Optional, cast
-
-import httpx
-from kajson import kajson
-from typing_extensions import override
-
-from pipelex.client.protocol import (
- ApiResponse,
- PipelexProtocol,
- PipeRequest,
- PipeStartResponse,
- PipeStatus,
-)
-from pipelex.tools.environment import get_required_env
-
-
-class PipelexApiClient(PipelexProtocol):
- """
- A protocol-compliant client for interacting with Pipelex pipes via API.
-
- This client implements the PipelexProtocol interface for pure API communication.
- """
-
- def __init__(
- self,
- api_token: str,
- ):
- """
- Initialize the PipelexApiClient.
-
- Args:
- api_token: Authentication token for the API
- """
- self.api_token = api_token
- self.api_base_url = get_required_env("EV_API_BASE_URL")
-
- def start_client(self) -> "PipelexApiClient":
- self.client = httpx.AsyncClient(base_url=self.api_base_url, headers={"Authorization": f"Bearer {self.api_token}"})
- return self
-
- async def close(self):
- """Close the HTTP client."""
- await self.client.aclose()
-
- async def _make_api_call(self, endpoint: str, request: Optional[str] = None) -> Any:
- """Make an API call to the Pipelex server.
-
- Args:
- endpoint: The API endpoint to call, relative to the base URL
- request: A JSON-formatted string to send as the request body, or None if no body is needed
-
- Returns:
- Any: The JSON-decoded response from the server
-
- Raises:
- httpx.HTTPError: If the request fails or returns a non-200 status code
- """
- # Convert JSON string to UTF-8 bytes if not None
- content = request.encode("utf-8") if request is not None else None
- response = await self.client.post(f"/{endpoint}", content=content, headers={"Content-Type": "application/json"}, timeout=120.0)
- response.raise_for_status()
- return response.json()
-
- @override
- async def execute_pipe(
- self,
- pipe_code: str,
- request: PipeRequest,
- ) -> PipeStatus:
- """
- Execute a pipe with the given request and wait for completion.
-
- This is a blocking operation that does not return until the pipe execution
- is complete. For long-running pipes, consider using start_pipe instead.
-
- Args:
- pipe_code: The unique identifier for the pipe to execute
- request: PipeRequest containing memory and output concept
-
- Returns:
- PipeStatus with the final execution status and pipe output
-
- Raises:
- HTTPException: If the request fails or returns a non-200 status code
- """
- response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/execute", request=kajson.dumps(request))
- return cast(PipeStatus, kajson.loads(response))
-
- @override
- async def start_pipe(
- self,
- pipe_code: str,
- request: PipeRequest,
- ) -> PipeStartResponse:
- """
- Start a pipe execution in the background without waiting for completion.
-
- This is a non-blocking operation that returns immediately with an execution ID.
- The execution will continue in the background, and the status can be checked
- using get_pipe_status.
-
- Args:
- pipe_code: The unique identifier for the pipe to execute
- request: PipeRequest containing memory and output concept
-
- Returns:
- PipeStartResponse with the pipe_execution_id and created_at timestamp
-
- Raises:
- HTTPException: If the request fails or returns a non-200 status code
- """
- response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/start", request=kajson.dumps(request))
- return cast(PipeStartResponse, kajson.loads(response))
-
- @override
- async def get_pipe_status(
- self,
- pipe_execution_id: str,
- ) -> PipeStatus:
- """
- Get the current status of a pipe execution.
-
- This method allows checking the current status of a pipe execution
- that was started with start_pipe.
-
- Args:
- pipe_execution_id: The unique identifier for the pipe execution
-
- Returns:
- PipeStatus with the current execution status and pipe output if completed
-
- Raises:
- HTTPException: If the request fails or returns a non-200 status code
- """
- response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/status", request=None)
- return cast(PipeStatus, kajson.loads(response))
-
- @override
- async def cancel_pipe(
- self,
- pipe_execution_id: str,
- ) -> ApiResponse:
- """
- Cancel a running pipe execution.
-
- This method attempts to cancel a pipe execution that is currently in progress.
- Once cancelled, a pipe cannot be resumed and must be started again if needed.
-
- Args:
- pipe_execution_id: The unique identifier for the pipe execution
-
- Returns:
- ApiResponse indicating success or failure of the cancellation
-
- Raises:
- HTTPException: If the request fails or returns a non-200 status code
- """
- response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/cancel", request=None)
- return ApiResponse(**response)
diff --git a/pipelex/client/client.py b/pipelex/client/client.py
index e8ea401fd..7f7d322ee 100644
--- a/pipelex/client/client.py
+++ b/pipelex/client/client.py
@@ -1,137 +1,106 @@
-from typing import Optional
+from typing import Any, Optional, cast
-from pipelex.client.api_client import PipelexApiClient
-from pipelex.client.protocol import (
- PipeRequest,
- PipeStartResponse,
- PipeState,
- PipeStatus,
-)
+import httpx
+from kajson import kajson
+from typing_extensions import override
+
+from pipelex.client.protocol import PipelexProtocol, PipelineRequest, PipelineResponse
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity
+from pipelex.core.working_memory import WorkingMemory
from pipelex.exceptions import ClientAuthenticationError
-from pipelex.run import run_pipe_code
+from pipelex.tools.environment import get_required_env
-class PipelexClient:
+class PipelexClient(PipelexProtocol):
"""
- A high-level client for interacting with Pipelex pipes.
+ A client for interacting with Pipelex pipelines through the API.
- This client provides a user-friendly interface for executing pipes either locally
- or through the remote API, with automatic handling of both modes.
+ This client provides a user-friendly interface for executing pipelines through
+ the remote API.
+ Args:
+ api_token: The API token to use for authentication. If not provided, it will be loaded from the PIPELEX_API_TOKEN environment variable.
+ If the environment variable is not set, an error will be raised.
"""
def __init__(
self,
api_token: Optional[str] = None,
+ api_base_url: Optional[str] = None,
):
- """
- Initialize the PipelexClient.
-
- Args:
- api_token: Authentication token for the API
- """
- self.api_token = api_token
- self.api_client: Optional[PipelexApiClient] = None
+ self.api_token = api_token or get_required_env("PIPELEX_API_TOKEN")
- async def start_api_client(self) -> PipelexApiClient:
- """
- Start the API client.
- """
if not self.api_token:
raise ClientAuthenticationError("API token is required for API execution")
- self.api_client = PipelexApiClient(api_token=self.api_token).start_client()
- return self.api_client
-
- async def close_api_client(self):
- """
- Close the API client.
- """
- if self.api_client:
- await self.api_client.close()
- self.api_client = None
-
- async def execute_pipe(
- self,
- pipe_code: str,
- pipe_execute_request: PipeRequest,
- use_local_execution: bool = True,
- ) -> PipeStatus:
- """
- Execute a pipe with the given request and wait for completion.
+ self.api_base_url = api_base_url or get_required_env("PIPELEX_API_BASE_URL")
+ if not self.api_base_url:
+ raise ClientAuthenticationError("API base URL is required for API execution")
- Args:
- pipe_code: The code of the pipe to execute
- pipe_execute_request: The request containing memory and output concept
- use_local_execution: Whether to execute locally (True) or via API (False)
-
- Returns:
- PipeStatus with execution results and pipe output
- """
- # Local execution
- if use_local_execution:
- pipe_output = await run_pipe_code(
- pipe_code=pipe_code,
- working_memory=pipe_execute_request.memory,
- dynamic_output_concept_code=pipe_execute_request.dynamic_output_concept,
- )
- return PipeStatus(
- pipe_execution_id="local",
- pipe_code=pipe_code,
- state=PipeState.COMPLETED,
- pipe_output=pipe_output,
- )
- # api_client = await self.start_api_client()
- # return await api_client.execute_pipe(pipe_code, pipe_execute_request)
- raise NotImplementedError("Pipelex API functionality is coming soon!")
+ self.client: Optional[httpx.AsyncClient] = None
- async def start_pipe(
- self,
- pipe_code: str,
- pipe_execute_request: PipeRequest,
- ) -> PipeStartResponse:
- """
- Start a pipe execution in the background without waiting for completion.
+ def start_client(self) -> "PipelexClient":
+ """Initialize the HTTP client for API calls."""
+ self.client = httpx.AsyncClient(base_url=self.api_base_url, headers={"Authorization": f"Bearer {self.api_token}"})
+ return self
- This is a non-blocking operation that returns immediately with an execution ID.
- The execution will continue in the background, and the status can be checked
- using get_pipe_status. Note that this method always uses API execution.
+ async def close(self):
+ """Close the HTTP client."""
+ if self.client:
+ await self.client.aclose()
+ self.client = None
+ async def _make_api_call(self, endpoint: str, request: Optional[str] = None) -> Any:
+ """Make an API call to the Pipelex server.
Args:
- pipe_code: The code of the pipe to execute
- pipe_execute_request: The request containing memory and output concept
-
+ endpoint: The API endpoint to call, relative to the base URL
+ request: A JSON-formatted string to send as the request body, or None if no body is needed
Returns:
- PipeStartResponse with the pipe_execution_id and created_at timestamp
-
+ Any: The JSON-decoded response from the server
Raises:
- ValueError: If API token is not provided
- HTTPException: If the API request fails
+ httpx.HTTPError: If the request fails or returns a non-200 status code
"""
- # api_client = await self.start_api_client()
- # return await api_client.start_pipe(pipe_code, pipe_execute_request)
- raise NotImplementedError("Pipelex API functionality is coming soon!")
-
- async def get_pipe_status(
+ if not self.client:
+ self.start_client()
+ assert self.client is not None
+
+ # Convert JSON string to UTF-8 bytes if not None
+ content = request.encode("utf-8") if request is not None else None
+ response = await self.client.post(f"/{endpoint}", content=content, headers={"Content-Type": "application/json"}, timeout=1200)
+ response.raise_for_status()
+ return response.json()
+
+ @override
+ async def execute_pipeline(
self,
- pipe_execution_id: str,
- ) -> PipeStatus:
- """
- Get the current status of a pipe execution.
-
- This method allows checking the current status of a pipe execution
- that was started with start_pipe. Note that this method always uses
- API execution.
-
- Args:
- pipe_execution_id: The unique identifier for the pipe execution
-
- Returns:
- PipeStatus with the current execution status and pipe output if completed
-
- Raises:
- ValueError: If API token is not provided
- HTTPException: If the API request fails or the execution ID is invalid
- """
- # api_client = await self.start_api_client()
- # return await api_client.get_pipe_status(pipe_execution_id)
- raise NotImplementedError("Pipelex API functionality is coming soon!")
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ ) -> PipelineResponse:
+ pipeline_request = PipelineRequest(
+ working_memory=working_memory,
+ output_name=output_name,
+ output_multiplicity=output_multiplicity,
+ dynamic_output_concept_code=dynamic_output_concept_code,
+ )
+ response = await self._make_api_call(f"pipelex/v1/pipeline/{pipe_code}/execute", request=kajson.dumps(pipeline_request))
+ return cast(PipelineResponse, kajson.loads(response))
+
+ @override
+ async def start_pipeline(
+ self,
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ ) -> PipelineResponse:
+ pipeline_request = PipelineRequest(
+ working_memory=working_memory,
+ output_name=output_name,
+ output_multiplicity=output_multiplicity,
+ dynamic_output_concept_code=dynamic_output_concept_code,
+ )
+ response = await self._make_api_call(f"pipelex/v1/pipeline/{pipe_code}/start", request=kajson.dumps(pipeline_request))
+ return cast(PipelineResponse, kajson.loads(response))
diff --git a/pipelex/client/protocol.py b/pipelex/client/protocol.py
index fbfd722f6..fb77ee4aa 100644
--- a/pipelex/client/protocol.py
+++ b/pipelex/client/protocol.py
@@ -1,7 +1,7 @@
from abc import abstractmethod
from typing import Optional, Protocol
-from pydantic import BaseModel, Field
+from pydantic import BaseModel
from typing_extensions import runtime_checkable
from pipelex.core.pipe_output import PipeOutput
@@ -10,16 +10,17 @@ from pipelex.core.working_memory import WorkingMemory
from pipelex.types import StrEnum
-class PipeState(StrEnum):
+class PipelineState(StrEnum):
"""
Enum representing the possible states of a pipe execution.
"""
- RUNNING = "running"
- COMPLETED = "completed"
- FAILED = "failed"
- CANCELLED = "cancelled"
- ERROR = "error"
+ RUNNING = "RUNNING"
+ COMPLETED = "COMPLETED"
+ FAILED = "FAILED"
+ CANCELLED = "CANCELLED"
+ ERROR = "ERROR"
+ STARTED = "STARTED"
class ApiResponse(BaseModel):
@@ -27,69 +28,50 @@ class ApiResponse(BaseModel):
Base response class for Pipelex API calls.
Attributes:
- status: Status of the API call ("success", "error", etc.)
- message: Optional message providing additional information
- error: Optional error message when status is not "success"
+ status (Optional[str]): Status of the API call ("success", "error", etc.)
+ message (Optional[str]): Optional message providing additional information
+ error (Optional[str]): Optional error message when status is not "success"
"""
- status: str
+ status: Optional[str] = None
message: Optional[str] = None
error: Optional[str] = None
-class PipeStatus(BaseModel):
+class PipelineRequest(BaseModel):
"""
- Status information for a pipe execution.
+ Request for executing a pipeline.
Attributes:
- pipe_execution_id: Unique identifier for this execution
- pipe_code: Code of the pipe that was executed
- state: Current state of execution (running, completed, failed, etc.)
- created_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution started
- finished_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution finished,
- only populated for completed or failed executions
- result: Complete WorkingMemory with all results, only populated when execution is finished
- main_output: Primary output Stuff instance, only populated when execution is finished
+ working_memory (Optional[WorkingMemory]): WorkingMemory instance passed to the pipeline
+ output_name (Optional[str]): Name of the output slot to write to
+ output_multiplicity (Optional[PipeOutputMultiplicity]): Output multiplicity setting
+ dynamic_output_concept_code (Optional[str]): Override for the dynamic output concept code
"""
- pipe_execution_id: str
- pipe_code: str
- state: PipeState
- created_at: Optional[str] = None # ISO format timestamp, only populated when execution is finished
- finished_at: Optional[str] = None # ISO format timestamp, only populated when execution is finished
- pipe_output: Optional[PipeOutput] = None
+ working_memory: Optional[WorkingMemory] = None
+ output_name: Optional[str] = None
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None
+ dynamic_output_concept_code: Optional[str] = None
-class PipeStartResponse(ApiResponse):
+class PipelineResponse(ApiResponse):
"""
- Response for pipe execution requests when starting a pipe in non-blocking mode.
-
- This response is returned when a pipe execution is started but does not wait for completion.
- It contains only the minimal details needed to identify and track the execution.
- For results, the client must call get_pipe_status with the pipe_execution_id.
+ Response for pipeline execution requests.
Attributes:
- pipe_execution_id: Unique identifier for this execution, used to check status later
- created_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution started
-
- # Inherited from ApiResponse:
- status: Status of the API call ("success", "error", etc.)
- message: Optional message providing additional information
- error: Optional error message when status is not "success"
+ pipeline_run_id (str): Unique identifier for the pipeline run
+ created_at (str): Timestamp when the pipeline was created
+ pipeline_state (PipelineState): Current state of the pipeline
+ finished_at (Optional[str]): Timestamp when the pipeline finished, if completed
+ pipe_output (Optional[PipeOutput]): Output data from the pipeline execution, if available
"""
- pipe_execution_id: str
+ pipeline_run_id: str
created_at: str
-
-
-class PipeRequest(BaseModel):
- """
- Request model for executing a pipe.
- """
-
- memory: WorkingMemory = Field(..., description="Input memory for the pipe")
- dynamic_output_concept: Optional[str] = Field(default=None, description="Concept code of the output stuff")
- output_multiplicity: Optional[PipeOutputMultiplicity] = Field(default=None, description="Multiplicity of the output stuff")
+ pipeline_state: PipelineState
+ finished_at: Optional[str] = None
+ pipe_output: Optional[PipeOutput] = None
@runtime_checkable
@@ -98,83 +80,67 @@ class PipelexProtocol(Protocol):
Protocol defining the contract for the Pipelex API.
This protocol specifies the interface that any Pipelex API implementation must adhere to.
- The protocol includes methods for executing pipes both synchronously and asynchronously,
- as well as cancelling running executions.
- """
+ All methods are asynchronous and handle pipeline execution, monitoring, and control.
- @abstractmethod
- async def execute_pipe(self, pipe_code: str, request: PipeRequest) -> PipeStatus:
- """
- Execute a pipe with the given memory and wait for completion.
-
- This is a blocking operation that does not return until the pipe execution
- is complete. For long-running pipes, consider using start_pipe instead.
-
- Args:
- pipe_code: The unique identifier for the pipe to execute
- request: PipeRequest containing the input instances required by the pipe
-
- Returns:
- PipeStatus with the final execution status including complete results.
-
- Raises:
- HTTPException: If the execution fails or encounters an error
- """
- ...
-
- @abstractmethod
- async def start_pipe(self, pipe_code: str, request: PipeRequest) -> PipeStartResponse:
- """
- Start a pipe execution in the background without waiting for completion.
-
- This is a non-blocking operation that returns immediately with an execution ID.
-
- Args:
- pipe_code: The unique identifier for the pipe to execute
- request: PipeRequest containing the input instances required by the pipe
-
- Returns:
- PipeStartResponse with the pipe_execution_id and created_at timestamp.
+ Attributes:
+ api_token (Optional[str]): Authentication token for API access
+ api_base_url (Optional[str]): Base URL for the API
+ """
- Raises:
- HTTPException: If starting the execution fails
- """
- ...
+ api_token: str
+ api_base_url: str
@abstractmethod
- async def cancel_pipe(self, pipe_execution_id: str) -> ApiResponse:
+ async def execute_pipeline(
+ self,
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ ) -> PipelineResponse:
"""
- Cancel a running pipe execution.
-
- This method allows clients to stop a pipe execution that is currently in progress.
- Once cancelled, a pipe cannot be resumed and must be started again if needed.
+ Execute a pipeline synchronously and wait for its completion.
Args:
- pipe_execution_id: The unique identifier for the pipe execution
-
+ pipe_code (str): The code identifying the pipeline to execute
+ working_memory (Optional[WorkingMemory]): Memory context passed to the pipeline
+ output_name (Optional[str]): Target output slot name
+ output_multiplicity (Optional[PipeOutputMultiplicity]): Output multiplicity setting
+ dynamic_output_concept_code (Optional[str]): Override for dynamic output concept
Returns:
- ApiResponse indicating success or failure of the cancellation
+ PipelineResponse: Complete execution results including pipeline state and output
Raises:
- HTTPException: If the cancellation fails or the execution ID is invalid
+ HTTPException: On execution failure or error
+ ClientAuthenticationError: If API token is missing for API execution
"""
...
@abstractmethod
- async def get_pipe_status(self, pipe_execution_id: str) -> PipeStatus:
+ async def start_pipeline(
+ self,
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ ) -> PipelineResponse:
"""
- Get the current status of a pipe execution.
-
- This method allows clients to check the current status of a pipe execution
- that was started with start_pipe.
+ Start a pipeline execution asynchronously without waiting for completion.
Args:
- pipe_execution_id: The unique identifier for the pipe execution
+ pipe_code (str): The code identifying the pipeline to execute
+ working_memory (Optional[WorkingMemory]): Memory context passed to the pipeline
+ output_name (Optional[str]): Target output slot name
+ output_multiplicity (Optional[PipeOutputMultiplicity]): Output multiplicity setting
+ dynamic_output_concept_code (Optional[str]): Override for dynamic output concept
Returns:
- PipeStatus with the current execution status
+ PipelineResponse: Initial response with pipeline_run_id and created_at timestamp
Raises:
- HTTPException: If the status check fails or the execution ID is invalid
+ HTTPException: On pipeline start failure
+ ClientAuthenticationError: If API token is missing for API execution
"""
...
diff --git a/pipelex/cogt/exceptions.py b/pipelex/cogt/exceptions.py
index 18239c954..eec64b48e 100644
--- a/pipelex/cogt/exceptions.py
+++ b/pipelex/cogt/exceptions.py
@@ -15,7 +15,7 @@ class CostRegistryError(CogtError):
pass
-class InferenceReportManagerError(CogtError):
+class ReportingManagerError(CogtError):
pass
diff --git a/pipelex/cogt/imgg/imgg_worker_abstract.py b/pipelex/cogt/imgg/imgg_worker_abstract.py
index 384afec00..ce915d880 100644
--- a/pipelex/cogt/imgg/imgg_worker_abstract.py
+++ b/pipelex/cogt/imgg/imgg_worker_abstract.py
@@ -8,9 +8,9 @@ from pipelex import log
from pipelex.cogt.image.generated_image import GeneratedImage
from pipelex.cogt.imgg.imgg_engine import ImggEngine
from pipelex.cogt.imgg.imgg_job import ImggJob
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
from pipelex.pipeline.job_metadata import UnitJobId
+from pipelex.reporting.reporting_protocol import ReportingProtocol
F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
@@ -43,8 +43,8 @@ def imgg_job_func(func: F) -> F:
# Report job
imgg_job.imgg_job_after_complete()
- if self.report_delegate:
- self.report_delegate.report_inference_job(inference_job=imgg_job)
+ if self.reporting_delegate:
+ self.reporting_delegate.report_inference_job(inference_job=imgg_job)
return result
@@ -55,9 +55,9 @@ class ImggWorkerAbstract(InferenceWorkerAbstract):
def __init__(
self,
imgg_engine: ImggEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ InferenceWorkerAbstract.__init__(self, reporting_delegate=reporting_delegate)
self.imgg_engine = imgg_engine
#########################################################
diff --git a/pipelex/cogt/imgg/imgg_worker_factory.py b/pipelex/cogt/imgg/imgg_worker_factory.py
index 16fcb56ba..f9a822a98 100644
--- a/pipelex/cogt/imgg/imgg_worker_factory.py
+++ b/pipelex/cogt/imgg/imgg_worker_factory.py
@@ -4,11 +4,11 @@ from pipelex.cogt.exceptions import CogtError, MissingDependencyError
from pipelex.cogt.imgg.imgg_engine import ImggEngine
from pipelex.cogt.imgg.imgg_platform import ImggPlatform
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
from pipelex.cogt.plugin_manager import PluginHandle
from pipelex.hub import get_plugin_manager, get_secret
from pipelex.plugins.openai.openai_imgg_worker import OpenAIImggWorker
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
@@ -20,7 +20,7 @@ class ImggWorkerFactory:
def make_imgg_worker(
self,
imgg_engine: ImggEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
) -> ImggWorkerAbstract:
imgg_sdk_handle = PluginHandle.get_for_imgg_engine(imgg_platform=imgg_engine.imgg_platform)
plugin_manager = get_plugin_manager()
@@ -49,7 +49,7 @@ class ImggWorkerFactory:
imgg_worker = FalImggWorker(
sdk_instance=imgg_sdk_instance,
imgg_engine=imgg_engine,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case ImggPlatform.OPENAI:
from pipelex.plugins.openai.openai_factory import OpenAIFactory
@@ -62,7 +62,7 @@ class ImggWorkerFactory:
imgg_worker = OpenAIImggWorker(
sdk_instance=imgg_sdk_instance,
imgg_engine=imgg_engine,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
return imgg_worker
diff --git a/pipelex/cogt/inference/inference_manager.py b/pipelex/cogt/inference/inference_manager.py
index 5d9cf63b0..39c79b0da 100644
--- a/pipelex/cogt/inference/inference_manager.py
+++ b/pipelex/cogt/inference/inference_manager.py
@@ -72,7 +72,7 @@ class InferenceManager(InferenceManagerProtocol):
llm_engine = LLMEngineFactory.make_llm_engine(llm_engine_blueprint=llm_engine_blueprint)
llm_worker = LLMWorkerFactory.make_llm_worker(
llm_engine=llm_engine,
- report_delegate=get_report_delegate(),
+ reporting_delegate=get_report_delegate(),
)
self.llm_workers[llm_handle] = llm_worker
return llm_worker
@@ -118,7 +118,7 @@ class InferenceManager(InferenceManagerProtocol):
log.verbose(imgg_engine.desc, title=f"Setting up ImgEngine for '{imgg_handle}'")
imgg_worker = self.imgg_worker_factory.make_imgg_worker(
imgg_engine=imgg_engine,
- report_delegate=get_report_delegate(),
+ reporting_delegate=get_report_delegate(),
)
self.imgg_workers[imgg_handle] = imgg_worker
return imgg_worker
@@ -154,7 +154,7 @@ class InferenceManager(InferenceManagerProtocol):
log.verbose(ocr_engine.desc, title=f"Setting up OcrEngine for '{ocr_handle}'")
ocr_worker = self.ocr_worker_factory.make_ocr_worker(
ocr_engine=ocr_engine,
- report_delegate=get_report_delegate(),
+ reporting_delegate=get_report_delegate(),
)
self.ocr_workers[ocr_handle] = ocr_worker
return ocr_worker
diff --git a/pipelex/cogt/inference/inference_report_delegate.py b/pipelex/cogt/inference/inference_report_delegate.py
deleted file mode 100644
index 8d5d9bf09..000000000
--- a/pipelex/cogt/inference/inference_report_delegate.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from typing import Optional, Protocol
-
-from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
-
-
-class InferenceReportDelegate(Protocol):
- def open_registry(self, pipeline_run_id: str): ...
-
- def report_inference_job(self, inference_job: InferenceJobAbstract): ...
-
- def generate_report(self, pipeline_run_id: Optional[str] = None): ...
-
- def close_registry(self, pipeline_run_id: str): ...
diff --git a/pipelex/cogt/inference/inference_worker_abstract.py b/pipelex/cogt/inference/inference_worker_abstract.py
index 4e2062c45..989be63a4 100644
--- a/pipelex/cogt/inference/inference_worker_abstract.py
+++ b/pipelex/cogt/inference/inference_worker_abstract.py
@@ -1,15 +1,15 @@
from abc import ABC, abstractmethod
from typing import Optional
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.reporting.reporting_protocol import ReportingProtocol
class InferenceWorkerAbstract(ABC):
def __init__(
self,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- self.report_delegate = report_delegate
+ self.reporting_delegate = reporting_delegate
@property
@abstractmethod
diff --git a/pipelex/cogt/llm/llm_job_func.py b/pipelex/cogt/llm/llm_job_func.py
index aa4bbc53b..4da6d83a8 100644
--- a/pipelex/cogt/llm/llm_job_func.py
+++ b/pipelex/cogt/llm/llm_job_func.py
@@ -67,8 +67,8 @@ def llm_job_func(func: F) -> F:
# Report job
llm_job.llm_job_after_complete()
- if self.report_delegate:
- self.report_delegate.report_inference_job(inference_job=llm_job)
+ if self.reporting_delegate:
+ self.reporting_delegate.report_inference_job(inference_job=llm_job)
return result
diff --git a/pipelex/cogt/llm/llm_worker_abstract.py b/pipelex/cogt/llm/llm_worker_abstract.py
index a9ed94be4..6fa4e56d4 100644
--- a/pipelex/cogt/llm/llm_worker_abstract.py
+++ b/pipelex/cogt/llm/llm_worker_abstract.py
@@ -4,12 +4,12 @@ from typing import Optional, Type
from typing_extensions import override
from pipelex.cogt.exceptions import LLMCapabilityError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.pipeline.job_metadata import UnitJobId
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
from pipelex.types import StrEnum
@@ -24,7 +24,7 @@ class LLMWorkerAbstract(InferenceWorkerAbstract, ABC):
self,
llm_engine: LLMEngine,
structure_method: Optional[StructureMethod],
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
"""
Initialize the LLMWorker.
@@ -32,9 +32,9 @@ class LLMWorkerAbstract(InferenceWorkerAbstract, ABC):
Args:
llm_engine (LLMEngine): The LLM engine to be used by the worker.
structure_method (Optional[StructureMethod]): The structure method to be used by the worker.
- report_delegate (Optional[InferenceReportDelegate]): An optional report delegate for reporting unit jobs.
+ reporting_delegate (Optional[ReportingProtocol]): An optional report delegate for reporting unit jobs.
"""
- InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ InferenceWorkerAbstract.__init__(self, reporting_delegate=reporting_delegate)
self.llm_engine = llm_engine
self.structure_method = structure_method
diff --git a/pipelex/cogt/llm/llm_worker_factory.py b/pipelex/cogt/llm/llm_worker_factory.py
index 38f70d400..d21cf0f95 100644
--- a/pipelex/cogt/llm/llm_worker_factory.py
+++ b/pipelex/cogt/llm/llm_worker_factory.py
@@ -1,7 +1,6 @@
from typing import Optional
from pipelex.cogt.exceptions import MissingDependencyError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
@@ -9,13 +8,14 @@ from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.cogt.plugin_manager import PluginHandle
from pipelex.config import get_config
from pipelex.hub import get_plugin_manager
+from pipelex.reporting.reporting_protocol import ReportingProtocol
class LLMWorkerFactory:
@staticmethod
def make_llm_worker(
llm_engine: LLMEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
) -> LLMWorkerAbstract:
llm_sdk_handle = PluginHandle.get_for_llm_platform(llm_platform=llm_engine.llm_platform)
plugin_manager = get_plugin_manager()
@@ -39,7 +39,7 @@ class LLMWorkerFactory:
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
structure_method=structure_method,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case LLMPlatform.VERTEXAI:
try:
@@ -59,7 +59,7 @@ class LLMWorkerFactory:
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
structure_method=StructureMethod.INSTRUCTOR_VERTEX_JSON,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case LLMPlatform.CUSTOM_LLM:
from pipelex.plugins.openai.openai_factory import OpenAIFactory
@@ -74,7 +74,7 @@ class LLMWorkerFactory:
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
structure_method=StructureMethod.INSTRUCTOR_OPENAI_STRUCTURED,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case LLMPlatform.ANTHROPIC | LLMPlatform.BEDROCK_ANTHROPIC:
try:
@@ -100,7 +100,7 @@ class LLMWorkerFactory:
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
structure_method=StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case LLMPlatform.MISTRAL:
try:
@@ -126,7 +126,7 @@ class LLMWorkerFactory:
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
structure_method=StructureMethod.INSTRUCTOR_MISTRAL_TOOLS,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
case LLMPlatform.BEDROCK:
try:
@@ -148,6 +148,6 @@ class LLMWorkerFactory:
llm_worker = BedrockLLMWorker(
sdk_instance=llm_sdk_instance,
llm_engine=llm_engine,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
return llm_worker
diff --git a/pipelex/cogt/ocr/ocr_worker_abstract.py b/pipelex/cogt/ocr/ocr_worker_abstract.py
index 6d5df0f18..1746af50d 100644
--- a/pipelex/cogt/ocr/ocr_worker_abstract.py
+++ b/pipelex/cogt/ocr/ocr_worker_abstract.py
@@ -5,12 +5,12 @@ from typing import Any, Callable, Optional, TypeVar, cast
from typing_extensions import Awaitable, override
from pipelex import log
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
from pipelex.cogt.ocr.ocr_engine import OcrEngine
from pipelex.cogt.ocr.ocr_job import OcrJob
from pipelex.cogt.ocr.ocr_output import OcrOutput
from pipelex.pipeline.job_metadata import UnitJobId
+from pipelex.reporting.reporting_protocol import ReportingProtocol
F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
@@ -43,8 +43,8 @@ def ocr_job_func(func: F) -> F:
# Report job
ocr_job.ocr_job_after_complete()
- if self.report_delegate:
- self.report_delegate.report_inference_job(inference_job=ocr_job)
+ if self.reporting_delegate:
+ self.reporting_delegate.report_inference_job(inference_job=ocr_job)
return result
@@ -55,9 +55,9 @@ class OcrWorkerAbstract(InferenceWorkerAbstract):
def __init__(
self,
ocr_engine: OcrEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ InferenceWorkerAbstract.__init__(self, reporting_delegate=reporting_delegate)
self.ocr_engine = ocr_engine
#########################################################
diff --git a/pipelex/cogt/ocr/ocr_worker_factory.py b/pipelex/cogt/ocr/ocr_worker_factory.py
index 8d8b90ae5..d004c3d35 100644
--- a/pipelex/cogt/ocr/ocr_worker_factory.py
+++ b/pipelex/cogt/ocr/ocr_worker_factory.py
@@ -1,19 +1,19 @@
from typing import Optional
from pipelex.cogt.exceptions import MissingDependencyError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.ocr.ocr_engine import OcrEngine
from pipelex.cogt.ocr.ocr_platform import OcrPlatform
from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract
from pipelex.cogt.plugin_manager import PluginHandle
from pipelex.hub import get_plugin_manager
+from pipelex.reporting.reporting_protocol import ReportingProtocol
class OcrWorkerFactory:
def make_ocr_worker(
self,
ocr_engine: OcrEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
) -> OcrWorkerAbstract:
ocr_sdk_handle = PluginHandle.get_for_ocr_engine(ocr_platform=ocr_engine.ocr_platform)
plugin_manager = get_plugin_manager()
@@ -40,7 +40,7 @@ class OcrWorkerFactory:
ocr_worker = MistralOcrWorker(
sdk_instance=ocr_sdk_instance,
ocr_engine=ocr_engine,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
return ocr_worker
diff --git a/pipelex/hub.py b/pipelex/hub.py
index 95bf99731..124d470e4 100644
--- a/pipelex/hub.py
+++ b/pipelex/hub.py
@@ -5,7 +5,6 @@ from pipelex import log
from pipelex.cogt.content_generation.content_generator_protocol import ContentGeneratorProtocol
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
from pipelex.cogt.inference.inference_manager_protocol import InferenceManagerProtocol
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_models.llm_deck_abstract import LLMDeckAbstract
from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
from pipelex.cogt.llm.llm_models.llm_model_provider_abstract import LLMModelProviderAbstract
@@ -23,6 +22,7 @@ from pipelex.pipeline.activity.activity_manager_protocol import ActivityManagerP
from pipelex.pipeline.pipeline import Pipeline
from pipelex.pipeline.pipeline_manager_abstract import PipelineManagerAbstract
from pipelex.pipeline.track.pipeline_tracker_protocol import PipelineTrackerProtocol
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.config.manager import config_manager
from pipelex.tools.config.models import ConfigRoot
from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
@@ -48,7 +48,7 @@ class PipelexHub:
self._llm_deck_provider: Optional[LLMDeckAbstract] = None
self._plugin_manager: Optional[PluginManager] = None
self._inference_manager: InferenceManagerProtocol
- self._report_delegate: InferenceReportDelegate
+ self._report_delegate: ReportingProtocol
self._content_generator: Optional[ContentGeneratorProtocol] = None
# pipelex
@@ -126,8 +126,8 @@ class PipelexHub:
def set_inference_manager(self, inference_manager: InferenceManagerProtocol):
self._inference_manager = inference_manager
- def set_report_delegate(self, report_delegate: InferenceReportDelegate):
- self._report_delegate = report_delegate
+ def set_report_delegate(self, reporting_delegate: ReportingProtocol):
+ self._report_delegate = reporting_delegate
def set_content_generator(self, content_generator: ContentGeneratorProtocol):
self._content_generator = content_generator
@@ -210,7 +210,7 @@ class PipelexHub:
def get_inference_manager(self) -> InferenceManagerProtocol:
return self._inference_manager
- def get_report_delegate(self) -> InferenceReportDelegate:
+ def get_report_delegate(self) -> ReportingProtocol:
return self._report_delegate
def get_required_content_generator(self) -> ContentGeneratorProtocol:
@@ -335,7 +335,7 @@ def get_ocr_worker(
return get_inference_manager().get_ocr_worker(ocr_handle=ocr_handle)
-def get_report_delegate() -> InferenceReportDelegate:
+def get_report_delegate() -> ReportingProtocol:
return get_pipelex_hub().get_report_delegate()
diff --git a/pipelex/pipelex.py b/pipelex/pipelex.py
index 5a62d1c23..6e28e4161 100644
--- a/pipelex/pipelex.py
+++ b/pipelex/pipelex.py
@@ -11,7 +11,6 @@ from pipelex import log
from pipelex.cogt.content_generation.content_generator import ContentGenerator
from pipelex.cogt.content_generation.content_generator_protocol import ContentGeneratorProtocol
from pipelex.cogt.inference.inference_manager import InferenceManager
-from pipelex.cogt.inference.inference_report_manager import InferenceReportManager
from pipelex.cogt.llm.llm_models.llm_model import LATEST_VERSION_NAME
from pipelex.cogt.llm.llm_models.llm_model_library import LLMModelLibrary
from pipelex.cogt.plugin_manager import PluginManager
@@ -27,6 +26,7 @@ from pipelex.pipeline.activity.activity_manager_protocol import ActivityManagerN
from pipelex.pipeline.pipeline_manager import PipelineManager
from pipelex.pipeline.track.pipeline_tracker import PipelineTracker
from pipelex.pipeline.track.pipeline_tracker_protocol import PipelineTrackerNoOp, PipelineTrackerProtocol
+from pipelex.reporting.reporting_protocol import ReportingNoOp, ReportingProtocol
from pipelex.test_extras.registry_test_models import PipelexTestModels
from pipelex.tools.config.models import ConfigRoot
from pipelex.tools.func_registry import func_registry
@@ -56,6 +56,7 @@ class Pipelex:
pipeline_manager: Optional[PipelineManager] = None,
pipeline_tracker: Optional[PipelineTracker] = None,
activity_manager: Optional[ActivityManagerProtocol] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
) -> Self:
if cls._pipelex_instance is not None:
raise RuntimeError(
@@ -82,6 +83,7 @@ class Pipelex:
pipeline_manager: Optional[PipelineManager] = None,
pipeline_tracker: Optional[PipelineTracker] = None,
activity_manager: Optional[ActivityManagerProtocol] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
) -> None:
self.pipelex_hub = pipelex_hub or PipelexHub()
set_pipelex_hub(self.pipelex_hub)
@@ -119,8 +121,8 @@ class Pipelex:
self.inference_manager = inference_manager or InferenceManager()
self.pipelex_hub.set_inference_manager(self.inference_manager)
- self.report_manager = InferenceReportManager(report_config=get_config().cogt.cogt_report_config)
- self.pipelex_hub.set_report_delegate(self.report_manager)
+ self.reporting_delegate = reporting_delegate or ReportingNoOp()
+ self.pipelex_hub.set_report_delegate(self.reporting_delegate)
# pipelex libraries
self.library_manager = LibraryManager()
@@ -164,7 +166,7 @@ class Pipelex:
# cogt
self.pipelex_hub.set_content_generator(content_generator or ContentGenerator())
- self.report_manager.setup()
+ self.reporting_delegate.setup()
class_registry.register_classes(PipelexRegistryModels.get_all_models())
if runtime_manager.is_unit_testing:
log.debug("Registering test models for unit testing")
@@ -214,7 +216,7 @@ class Pipelex:
# cogt
self.inference_manager.teardown()
- self.report_manager.teardown()
+ self.reporting_delegate.teardown()
self.llm_model_provider.teardown()
# tools
diff --git a/pipelex/plugins/anthropic/anthropic_llm_worker.py b/pipelex/plugins/anthropic/anthropic_llm_worker.py
index f13621a50..40ae24dd6 100644
--- a/pipelex/plugins/anthropic/anthropic_llm_worker.py
+++ b/pipelex/plugins/anthropic/anthropic_llm_worker.py
@@ -6,7 +6,6 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.exceptions import LLMCompletionError, LLMEngineParameterError, SdkTypeError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
@@ -15,6 +14,7 @@ from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.config import get_config
from pipelex.plugins.anthropic.anthropic_factory import AnthropicFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
@@ -24,13 +24,13 @@ class AnthropicLLMWorker(LLMWorkerAbstract):
sdk_instance: Any,
llm_engine: LLMEngine,
structure_method: Optional[StructureMethod] = None,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
LLMWorkerAbstract.__init__(
self,
llm_engine=llm_engine,
structure_method=structure_method,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
self.default_max_tokens: int
if default_max_tokens := llm_engine.llm_model.max_tokens:
diff --git a/pipelex/plugins/bedrock/bedrock_llm_worker.py b/pipelex/plugins/bedrock/bedrock_llm_worker.py
index f6037759d..853fbba0f 100644
--- a/pipelex/plugins/bedrock/bedrock_llm_worker.py
+++ b/pipelex/plugins/bedrock/bedrock_llm_worker.py
@@ -4,7 +4,6 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.exceptions import LLMCapabilityError, LLMEngineParameterError, SdkTypeError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
@@ -12,6 +11,7 @@ from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.plugins.bedrock.bedrock_client_protocol import BedrockClientProtocol
from pipelex.plugins.bedrock.bedrock_factory import BedrockFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
@@ -21,13 +21,13 @@ class BedrockLLMWorker(LLMWorkerAbstract):
sdk_instance: Any,
llm_engine: LLMEngine,
structure_method: Optional[StructureMethod] = None,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
LLMWorkerAbstract.__init__(
self,
llm_engine=llm_engine,
structure_method=structure_method,
- report_delegate=report_delegate,
+ reporting_delegate=reporting_delegate,
)
if not isinstance(sdk_instance, BedrockClientProtocol):
diff --git a/pipelex/plugins/fal/fal_imgg_worker.py b/pipelex/plugins/fal/fal_imgg_worker.py
index edaad907b..31aa11973 100644
--- a/pipelex/plugins/fal/fal_imgg_worker.py
+++ b/pipelex/plugins/fal/fal_imgg_worker.py
@@ -9,8 +9,8 @@ from pipelex.cogt.image.generated_image import GeneratedImage
from pipelex.cogt.imgg.imgg_engine import ImggEngine
from pipelex.cogt.imgg.imgg_job import ImggJob
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract, imgg_job_func
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.plugins.fal.fal_factory import FalFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
class FalImggWorker(ImggWorkerAbstract):
@@ -18,9 +18,9 @@ class FalImggWorker(ImggWorkerAbstract):
self,
sdk_instance: Any,
imgg_engine: ImggEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- super().__init__(imgg_engine=imgg_engine, report_delegate=report_delegate)
+ super().__init__(imgg_engine=imgg_engine, reporting_delegate=reporting_delegate)
if not isinstance(sdk_instance, AsyncClient):
raise SdkTypeError(f"Provided Imgg sdk_instance is not of type fal_client.AsyncClient: it's a '{type(sdk_instance)}'")
diff --git a/pipelex/plugins/mistral/mistral_llm_worker.py b/pipelex/plugins/mistral/mistral_llm_worker.py
index 6c2e64113..7441a0263 100644
--- a/pipelex/plugins/mistral/mistral_llm_worker.py
+++ b/pipelex/plugins/mistral/mistral_llm_worker.py
@@ -7,13 +7,13 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.exceptions import LLMCompletionError, LLMEngineParameterError, SdkTypeError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.plugins.mistral.mistral_factory import MistralFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
@@ -23,9 +23,9 @@ class MistralLLMWorker(LLMWorkerAbstract):
sdk_instance: Any,
llm_engine: LLMEngine,
structure_method: Optional[StructureMethod] = None,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- super().__init__(llm_engine=llm_engine, structure_method=structure_method, report_delegate=report_delegate)
+ super().__init__(llm_engine=llm_engine, structure_method=structure_method, reporting_delegate=reporting_delegate)
if not isinstance(sdk_instance, Mistral):
raise SdkTypeError(f"Provided LLM sdk_instance for {self.__class__.__name__} is not of type Mistral: it's a '{type(sdk_instance)}'")
diff --git a/pipelex/plugins/mistral/mistral_ocr_worker.py b/pipelex/plugins/mistral/mistral_ocr_worker.py
index 84a725bf7..36f941d4e 100644
--- a/pipelex/plugins/mistral/mistral_ocr_worker.py
+++ b/pipelex/plugins/mistral/mistral_ocr_worker.py
@@ -5,7 +5,6 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.exceptions import OcrCapabilityError, SdkTypeError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.ocr.ocr_engine import OcrEngine
from pipelex.cogt.ocr.ocr_input import OcrInputError
from pipelex.cogt.ocr.ocr_job import OcrJob
@@ -13,6 +12,7 @@ from pipelex.cogt.ocr.ocr_output import OcrOutput
from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract, ocr_job_func
from pipelex.plugins.mistral.mistral_factory import MistralFactory
from pipelex.plugins.mistral.mistral_utils import upload_file_for_ocr
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.misc.base_64_utils import load_binary_as_base64_async
from pipelex.tools.misc.path_utils import clarify_path_or_url
@@ -22,9 +22,9 @@ class MistralOcrWorker(OcrWorkerAbstract):
self,
sdk_instance: Any,
ocr_engine: OcrEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- super().__init__(ocr_engine=ocr_engine, report_delegate=report_delegate)
+ super().__init__(ocr_engine=ocr_engine, reporting_delegate=reporting_delegate)
if not isinstance(sdk_instance, Mistral):
raise SdkTypeError(f"Provided OCR sdk_instance for {self.__class__.__name__} is not of type Mistral: it's a '{type(sdk_instance)}'")
diff --git a/pipelex/plugins/openai/openai_imgg_worker.py b/pipelex/plugins/openai/openai_imgg_worker.py
index 37cdada8c..8baca86c3 100644
--- a/pipelex/plugins/openai/openai_imgg_worker.py
+++ b/pipelex/plugins/openai/openai_imgg_worker.py
@@ -11,9 +11,9 @@ from pipelex.cogt.imgg.imgg_engine import ImggEngine
from pipelex.cogt.imgg.imgg_job import ImggJob
from pipelex.cogt.imgg.imgg_job_components import Quality
from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract, imgg_job_func
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.config import get_config
from pipelex.plugins.openai.openai_imgg_factory import OpenAIImggFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.misc.base_64_utils import save_base64_to_binary_file
from pipelex.tools.misc.file_utils import ensure_path
@@ -25,9 +25,9 @@ class OpenAIImggWorker(ImggWorkerAbstract):
self,
sdk_instance: Any,
imgg_engine: ImggEngine,
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- super().__init__(imgg_engine=imgg_engine, report_delegate=report_delegate)
+ super().__init__(imgg_engine=imgg_engine, reporting_delegate=reporting_delegate)
if not isinstance(sdk_instance, openai.AsyncOpenAI):
raise SdkTypeError(f"Provided Imgg sdk_instance is not of type openai.AsyncOpenAI: it's a '{type(sdk_instance)}'")
diff --git a/pipelex/plugins/openai/openai_llm_worker.py b/pipelex/plugins/openai/openai_llm_worker.py
index f027d3561..74eaeb968 100644
--- a/pipelex/plugins/openai/openai_llm_worker.py
+++ b/pipelex/plugins/openai/openai_llm_worker.py
@@ -8,7 +8,6 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.exceptions import LLMCompletionError, LLMEngineParameterError, LLMModelNotFoundError, SdkTypeError
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_job_func import llm_job_func
from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
@@ -16,6 +15,7 @@ from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
from pipelex.cogt.llm.structured_output import StructureMethod
from pipelex.plugins.openai.openai_factory import OpenAIFactory
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
@@ -25,9 +25,9 @@ class OpenAILLMWorker(LLMWorkerAbstract):
sdk_instance: Any,
llm_engine: LLMEngine,
structure_method: Optional[StructureMethod],
- report_delegate: Optional[InferenceReportDelegate] = None,
+ reporting_delegate: Optional[ReportingProtocol] = None,
):
- super().__init__(llm_engine=llm_engine, structure_method=structure_method, report_delegate=report_delegate)
+ super().__init__(llm_engine=llm_engine, structure_method=structure_method, reporting_delegate=reporting_delegate)
if not isinstance(sdk_instance, openai.AsyncOpenAI):
raise SdkTypeError(
diff --git a/pipelex/cogt/inference/inference_report_manager.py b/pipelex/reporting/reporting_manager.py
similarity index 90%
rename from pipelex/cogt/inference/inference_report_manager.py
rename to pipelex/reporting/reporting_manager.py
index 02f766cc9..77b991797 100644
--- a/pipelex/cogt/inference/inference_report_manager.py
+++ b/pipelex/reporting/reporting_manager.py
@@ -5,13 +5,13 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.config_cogt import CogtReportConfig
-from pipelex.cogt.exceptions import InferenceReportManagerError
+from pipelex.cogt.exceptions import ReportingManagerError
from pipelex.cogt.inference.cost_registry import CostRegistry
from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
-from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
from pipelex.cogt.llm.llm_job import LLMJob
from pipelex.cogt.llm.llm_report import LLMTokenCostReport, LLMTokensUsage
from pipelex.pipeline.pipeline_models import SpecialPipelineId
+from pipelex.reporting.reporting_protocol import ReportingProtocol
from pipelex.tools.misc.file_utils import ensure_path, get_incremental_file_path
LLMUsageRegistryRoot = List[LLMTokensUsage]
@@ -27,7 +27,7 @@ class UsageRegistry(RootModel[LLMUsageRegistryRoot]):
self.root.append(llm_tokens_usage)
-class InferenceReportManager(InferenceReportDelegate):
+class ReportingManager(ReportingProtocol):
def __init__(self, report_config: CogtReportConfig):
self._usage_registries: Dict[str, UsageRegistry] = {}
self._report_config = report_config
@@ -36,10 +36,12 @@ class InferenceReportManager(InferenceReportDelegate):
# Manager lifecycle
############################################################
+ @override
def setup(self):
self._usage_registries.clear()
self._usage_registries[SpecialPipelineId.UNTITLED] = UsageRegistry()
+ @override
def teardown(self):
self._usage_registries.clear()
@@ -49,7 +51,7 @@ class InferenceReportManager(InferenceReportDelegate):
def _get_registry(self, pipeline_run_id: str) -> UsageRegistry:
if pipeline_run_id not in self._usage_registries:
- raise InferenceReportManagerError(f"Registry for pipeline '{pipeline_run_id}' does not exist")
+ raise ReportingManagerError(f"Registry for pipeline '{pipeline_run_id}' does not exist")
return self._usage_registries[pipeline_run_id]
def _report_llm_job(self, llm_job: LLMJob):
@@ -71,13 +73,13 @@ class InferenceReportManager(InferenceReportDelegate):
log.verbose(llm_token_cost_report, title="Token Cost report")
############################################################
- # InferenceReportDelegate
+ # ReportingProtocol
############################################################
@override
def open_registry(self, pipeline_run_id: str):
if pipeline_run_id in self._usage_registries:
- raise InferenceReportManagerError(f"Registry for pipeline '{pipeline_run_id}' already exists")
+ raise ReportingManagerError(f"Registry for pipeline '{pipeline_run_id}' already exists")
self._usage_registries[pipeline_run_id] = UsageRegistry()
@override
diff --git a/pipelex/reporting/reporting_protocol.py b/pipelex/reporting/reporting_protocol.py
new file mode 100644
index 000000000..2c63e4d9a
--- /dev/null
+++ b/pipelex/reporting/reporting_protocol.py
@@ -0,0 +1,45 @@
+from typing import Optional, Protocol
+
+from typing_extensions import override
+
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+
+
+class ReportingProtocol(Protocol):
+ def open_registry(self, pipeline_run_id: str): ...
+
+ def report_inference_job(self, inference_job: InferenceJobAbstract): ...
+
+ def generate_report(self, pipeline_run_id: Optional[str] = None): ...
+
+ def close_registry(self, pipeline_run_id: str): ...
+
+ def setup(self): ...
+
+ def teardown(self): ...
+
+
+class ReportingNoOp(ReportingProtocol):
+ @override
+ def open_registry(self, pipeline_run_id: str):
+ pass
+
+ @override
+ def report_inference_job(self, inference_job: InferenceJobAbstract):
+ pass
+
+ @override
+ def generate_report(self, pipeline_run_id: Optional[str] = None):
+ pass
+
+ @override
+ def close_registry(self, pipeline_run_id: str):
+ pass
+
+ @override
+ def setup(self):
+ pass
+
+ @override
+ def teardown(self):
+ pass
diff --git a/pipelex/run.py b/pipelex/run.py
deleted file mode 100644
index 2b2924204..000000000
--- a/pipelex/run.py
+++ /dev/null
@@ -1,77 +0,0 @@
-from typing import Optional
-
-from pipelex import pretty_print
-from pipelex.core.pipe_abstract import PipeAbstract
-from pipelex.core.pipe_output import PipeOutput
-from pipelex.core.pipe_run_params import PipeOutputMultiplicity, PipeRunParams
-from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
-from pipelex.core.working_memory import WorkingMemory
-from pipelex.hub import get_pipe_router, get_required_pipe
-from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
-from pipelex.pipeline.job_metadata import JobMetadata
-
-
-async def run_pipe_code(
- pipe_code: str,
- working_memory: Optional[WorkingMemory] = None,
- output_name: Optional[str] = None,
- output_multiplicity: Optional[PipeOutputMultiplicity] = None,
- dynamic_output_concept_code: Optional[str] = None,
- job_id: Optional[str] = None,
-) -> PipeOutput:
- """
- Simple wrapper to run a pipe with a working memory using the default PipeRouter.
-
- Args:
- pipe_code: The code of the pipe to run
- working_memory: The working memory containing all necessary stuffs
- output_name: The name of the output for the main output of the pipe
- output_multiplicity: The multiplicity of the output
- output_concept_code: Optional output concept code to use for dynamic output concept
- job_id: Optional job ID (defaults to pipe_code)
-
- Returns:
- PipeOutput: The output of the pipe execution
- """
- pipe = get_required_pipe(pipe_code=pipe_code)
-
- job_metadata = JobMetadata(
- top_job_id=job_id or pipe_code,
- )
-
- pipe_run_params = PipeRunParamsFactory.make_run_params(
- output_multiplicity=output_multiplicity,
- dynamic_output_concept_code=dynamic_output_concept_code,
- )
-
- pretty_print(pipe, title=f"Running pipe '{pipe_code}'")
- if working_memory:
- working_memory.pretty_print_summary()
-
- pipe_job = PipeJobFactory.make_pipe_job(
- pipe=pipe,
- pipe_run_params=pipe_run_params,
- job_metadata=job_metadata,
- working_memory=working_memory,
- output_name=output_name,
- )
-
- return await get_pipe_router().run_pipe_job(pipe_job)
-
-
-async def run_pipe(
- pipe: PipeAbstract,
- pipe_run_params: PipeRunParams,
- job_metadata: JobMetadata,
- working_memory: Optional[WorkingMemory] = None,
- output_name: Optional[str] = None,
-) -> PipeOutput:
- pipe_job = PipeJobFactory.make_pipe_job(
- pipe=pipe,
- pipe_run_params=pipe_run_params,
- job_metadata=job_metadata,
- working_memory=working_memory,
- output_name=output_name,
- )
-
- return await get_pipe_router().run_pipe_job(pipe_job)
diff --git a/tests/pipelex/cogt/cogt_asynch/test_llm_engines.py b/tests/pipelex/cogt/cogt_asynch/test_llm_engines.py
index ffaa6474b..d58fcf149 100644
--- a/tests/pipelex/cogt/cogt_asynch/test_llm_engines.py
+++ b/tests/pipelex/cogt/cogt_asynch/test_llm_engines.py
@@ -57,7 +57,7 @@ class TestLLMEngines:
)
llm_worker = llm_worker_factory.make_llm_worker(
llm_engine=llm_engine,
- report_delegate=get_report_delegate(),
+ reporting_delegate=get_report_delegate(),
)
llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
system_text=None,
@@ -125,7 +125,7 @@ class TestLLMEngines:
)
llm_worker = llm_worker_factory.make_llm_worker(
llm_engine=llm_engine,
- report_delegate=get_report_delegate(),
+ reporting_delegate=get_report_delegate(),
)
llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
system_text=None,
diff --git a/tests/pipelex/pipelex_asynch/test_client.py b/tests/pipelex/pipelex_asynch/test_client.py
index c83b40bf4..8eee7ebb2 100644
--- a/tests/pipelex/pipelex_asynch/test_client.py
+++ b/tests/pipelex/pipelex_asynch/test_client.py
@@ -1,176 +1,114 @@
-import os
from typing import List
import pytest
from pydantic import BaseModel
+from pipelex import pretty_print
from pipelex.client.client import PipelexClient
-from pipelex.client.protocol import PipeRequest, PipeState
+from pipelex.client.protocol import PipelineState
from pipelex.core.stuff import Stuff
-from pipelex.core.stuff_content import ImageContent, TextContent
+from pipelex.core.stuff_content import TextContent
from pipelex.core.stuff_factory import StuffFactory
from pipelex.core.working_memory import WorkingMemory
-from pipelex import pretty_print
-
class Example(BaseModel):
pipe_code: str
- dynamic_output_concept: str
memory: List[Stuff]
@pytest.mark.llm
@pytest.mark.inference
@pytest.mark.asyncio(loop_scope="class")
-class TestPipelexClient:
+class TestPipelexApiClient:
@pytest.fixture
def examples(self) -> List[Example]:
"""
- Fixture providing test examples for API client tests.
-
- Returns:
- List[Example]: A list of test examples containing different pipe execution scenarios:
- - Text-based question answering with context and excerpts
- - Gantt chart image processing
+ Fixture providing test example for API client tests.
"""
return [
Example(
- pipe_code="retrieve_then_answer", # pipe_code
- dynamic_output_concept="contracts.Fees",
+ pipe_code="retrieve_excerpts",
memory=[
StuffFactory.make_stuff(
- concept_code="questions.ProjectContext",
- name="project_context",
+ concept_code="native.Text",
+ name="text",
content=TextContent(
- text="The project context is a licensing agreement between WebTech Solutions Inc. and DataAnalytics Corp for the use of WebTech's cloud-based data processing platform. The document contains various sections including licensing terms, service levels, and fee structures. The agreement was executed on January 15, 2023, and is valid for a period of 36 months."
+ text="""
+ The Dawn of Ultra-Rapid Transit: NextGen High-Speed Trains Redefine Travel
+ By Eliza Montgomery, Transportation Technology Reporter
+
+ In an era where time is increasingly precious, a revolution in rail transportation is quietly
+ transforming how we connect cities and regions. The emergence of ultra-high-speed train
+ networks, capable of speeds exceeding 350 mph, promises to render certain short-haul
+ flights obsolete while dramatically reducing carbon emissions.
+
+ QuantumRail's Breakthrough Technology
+ Leading this transportation revolution is QuantumRail Technologies, whose new MagLev-X
+ platform has shattered previous speed records during recent tests in Nevada's
+ Velocity Valley testinggrounds. The train achieved a remarkable 368 mph,
+ maintaining this speed for over fifteen minutes.
+
+ 'What we're seeing isn't just an incremental improvement—it's a fundamental shift
+ in transportationphysics,' explains Dr. Hiroshi Takahashi, Chief Engineer at
+ QuantumRail. 'The MagLev-X's superconducting magnets and aerodynamic profile
+ allow us to overcome limitations that have constrained train speeds for decades.'
+
+ Economic Implications
+ The introduction of these next-generation trains isn't merely a technical
+ achievement—it represents a potential economic windfall for connected regions.
+ The TransContinental Alliance, a consortium of cities supporting high-speed rail
+ development, estimates that new high-speed corridors could generate $87
+ billion in economic activity over the next decade.
+
+ 'When you can travel between Chicago and Detroit in under an hour,
+ you're essentially creating a single economic zone, notes Dr. Amara Washington,
+ economist at the Urban Mobility Institute. This transforms labor markets, housing
+ patterns, and business relationships.
+
+ WindStream's Competitive Response
+ Not to be outdone, European manufacturer WindStream Mobility has unveiled
+ its own ultra-high-speed platform, the AeroGlide TGV-7. Featuring a
+ distinctive bionic design inspired by peregrine falcons, the train uses an innovative
+ hybrid propulsion system that combines traditional electric motors with
+ compressed air boosters for acceleration phases.
+ """
),
),
StuffFactory.make_stuff(
concept_code="answer.Question",
name="question",
- content=TextContent(
- text="What are the transaction fees for using the WebTech Solutions data processing platform, and how are they calculated?"
- ),
- ),
- StuffFactory.make_stuff(
- concept_code="questions.TargetConcept",
- name="target_concept",
- content=TextContent(text="Fees"),
- ),
- StuffFactory.make_stuff(
- concept_code="basic.ClientInstructions",
- name="client_instructions",
- content=TextContent(
- text="Please focus on the standard transaction fees from Schedule B, not the implementation fees or monthly subscription costs. The client specifically wants to understand if there are percentage-based fees or fixed amount charges for each transaction and what currency they need to pay in. If there are tiered fees based on volume, please identify the standard tier (100,000 to 500,000 transactions)."
- ),
- ),
- StuffFactory.make_stuff(
- concept_code="native.Text",
- name="text",
- content=TextContent(
- text="""
-MASTER SERVICE AGREEMENT
-BETWEEN WEBTECH SOLUTIONS INC. AND DATAANALYTICS CORP
-
-EFFECTIVE DATE: January 15, 2023
-
-1. DEFINITIONS
-1.1 "Transaction" means each individual data processing request submitted by Licensee to the Platform.
-1.2 "Platform" refers to WebTech Solutions' proprietary cloud-based data processing infrastructure and software.
-1.3 "Fees" means all charges payable by the Licensee to WebTech as set forth in Schedule B.
-
-2. TERM AND TERMINATION
-2.1 This Agreement shall commence on the Effective Date and shall continue for a period of thirty-six (36) months ("Initial Term").
-
-7. PAYMENT TERMS
-7.1 Licensee shall pay all Fees in accordance with Schedule B.
-7.2 All Fees are exclusive of applicable taxes.
-7.3 WebTech shall invoice Licensee on a monthly basis for Transaction Fees incurred during the previous month.
-7.4 All invoices are payable within thirty (30) days of receipt.
-7.5 Late payments shall accrue interest at a rate of 1.5% per month or the maximum rate permitted by law, whichever is less.
-
-SCHEDULE B - FEE SCHEDULE
-
-1. IMPLEMENTATION FEES
-One-time implementation and integration fee: $25,000 USD
-
-2. SUBSCRIPTION FEES
-Monthly platform access: $5,000 USD per month
-
-3. TRANSACTION FEES
-3.1 Standard Pricing Model:
-- 0-100,000 transactions per month: 2.75% of transaction value
-- 100,001-500,000 transactions per month: 2.3% of transaction value
-- 500,001+ transactions per month: 1.9% of transaction value
-
-3.2 Alternative Fixed Fee Model (available upon request):
-- 0-100,000 transactions per month: $0.15 USD per transaction
-- 100,001-500,000 transactions per month: $0.12 USD per transaction
-- 500,001+ transactions per month: $0.09 USD per transaction
-
-3.3 All percentage-based transaction fees are calculated based on the monetary value of the data being processed.
-
-3.4 Minimum monthly transaction fee: $1,000 USD
-
-9. CURRENCY AND PAYMENT METHODS
-9.1 All fees specified in this Agreement are in United States Dollars (USD).
-9.2 Licensee may request to be billed in EUR or GBP, subject to WebTech's current exchange rates plus a 1% currency conversion fee.
-9.3 Payment methods accepted:
-- ACH transfer
-- Wire transfer
-- Corporate credit card (subject to a 2.5% processing fee)
-
-AMENDMENT 1 TO SCHEDULE B - EFFECTIVE MARCH 1, 2023
-
-Upon mutual agreement between WebTech Solutions Inc. and DataAnalytics Corp, the following modifications to the Transaction Fees in Schedule B are hereby implemented:
-
-For DataAnalytics Corp's European operations only:
-- Transaction fees shall be billed at a flat rate of 2.1% of transaction value for all volume tiers
-- Minimum monthly transaction fee reduced to €800 EUR
-- All European transactions shall be billed in Euros (EUR)
-
-This amendment applies only to transactions originating from DataAnalytics Corp's European business units and does not modify the fee structure for operations in other regions.
-
-"""
- ),
+ content=TextContent(text="Aerodynamic features?"),
),
],
),
]
- async def test_execute_pipe(
+ async def test_client_execute_pipe(
self,
examples: List[Example],
):
"""
- Test the execute_pipe method with different examples.
+ Test the execute_pipe method with the example.
Args:
examples: List of test examples from the fixture
"""
- # ruff: noqa
for example in examples:
# Create working memory from example data
memory = WorkingMemory()
for stuff in example.memory:
memory.add_new_stuff(name=stuff.stuff_name or stuff.concept_code, stuff=stuff)
- pipe_execute_request = PipeRequest(
- memory=memory,
- dynamic_output_concept=example.dynamic_output_concept,
- )
-
# Execute pipe
client = PipelexClient()
- result = await client.execute_pipe(
+ result = await client.execute_pipeline(
pipe_code=example.pipe_code,
- pipe_execute_request=pipe_execute_request,
- use_local_execution=True,
+ working_memory=memory,
)
pretty_print(result)
# Verify result
- assert result.pipe_code == example.pipe_code
- assert result.state == PipeState.COMPLETED
+ assert result.pipeline_run_id is not None
+ assert result.pipeline_state == PipelineState.COMPLETED
assert result.pipe_output is not None
diff --git a/tests/pipelex/pipelex_asynch/test_pipe_run.py b/tests/pipelex/pipelex_asynch/test_pipe_run.py
deleted file mode 100644
index df7ed7d82..000000000
--- a/tests/pipelex/pipelex_asynch/test_pipe_run.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from typing import cast
-
-import pytest
-
-from pipelex import log, pretty_print
-from pipelex.core.pipe_output import PipeOutput
-from pipelex.core.stuff_content import ListContent, TextContent
-from pipelex.core.working_memory_factory import WorkingMemoryFactory
-from pipelex.hub import get_report_delegate
-from pipelex.run import run_pipe_code
-from tests.pipelex.test_data import PipeTestCases
-
-
[email protected](loop_scope="class")
-class TestPipeRun:
- async def test_pipe_run(self):
- working_memory = WorkingMemoryFactory.make_from_text(
- text=PipeTestCases.USER_TEXT_COLORS,
- )
- pipe_output: PipeOutput = await run_pipe_code(
- pipe_code="extract_colors",
- working_memory=working_memory,
- )
-
- colors_list = cast(ListContent[TextContent], pipe_output.main_stuff.content)
- pretty_print(colors_list, title="colors_list")
- colors_list = pipe_output.main_stuff.as_list_of_fixed_content_type(item_type=TextContent)
- pretty_print(colors_list, title="colors_list")
- colors_list = pipe_output.main_stuff_as_list(item_type=TextContent)
- pretty_print(colors_list, title="colors_list")
-
- @pytest.mark.parametrize("pipe_code, input_concept_code, str_value", PipeTestCases.SIMPLE_PIPE_RUN_FROM_STR)
- async def test_execute_pipe_from_str(self, pipe_code: str, input_concept_code: str, str_value: str):
- working_memory = WorkingMemoryFactory.make_from_text(
- concept_code=input_concept_code,
- text=str_value,
- )
- pipe_output: PipeOutput = await run_pipe_code(
- pipe_code=pipe_code,
- working_memory=working_memory,
- )
-
- log.verbose(pipe_output, title="pipe_output")
- pretty_print(pipe_output, title="pipe_output")
- get_report_delegate().generate_report()