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.

fix start as well

thomashebrarde88380b960dc
diff --git a/pipelex/builder/runner_code.py b/pipelex/builder/runner_code.py
index ee18434e5..d27a9c01a 100644
--- a/pipelex/builder/runner_code.py
+++ b/pipelex/builder/runner_code.py
@@ -64,7 +64,7 @@ def value_to_python_code(value: Any, indent_level: int = 0) -> str:
def generate_compact_memory_entry(var_name: str, concept: Concept) -> str:
- """Generate the implicit_memory dictionary entry for a given input."""
+ """Generate the pipeline_inputs dictionary entry for a given input."""
example_value = concept.get_compact_memory_example(var_name)
# Convert the example value to a Python code string
diff --git a/pipelex/client/api_serializer.py b/pipelex/client/api_serializer.py
index 5519696f3..580a86351 100644
--- a/pipelex/client/api_serializer.py
+++ b/pipelex/client/api_serializer.py
@@ -26,20 +26,20 @@ class ApiSerializer:
PipelineInputs ready for API transmission with datetime strings and no __class__/__module__.
"""
- implicit_memory: PipelineInputs = {}
+ pipeline_inputs: PipelineInputs = {}
if working_memory is None:
- return implicit_memory
+ return pipeline_inputs
for stuff_name, stuff in working_memory.root.items():
content_dict = stuff.content.model_dump(serialize_as_any=True)
clean_content = cls._clean_and_format_content(content_dict)
- implicit_memory[stuff_name] = {
+ pipeline_inputs[stuff_name] = {
"concept": stuff.concept.code,
"content": clean_content,
}
- return implicit_memory
+ return pipeline_inputs
@classmethod
def _clean_and_format_content(cls, content: Any) -> Any:
diff --git a/pipelex/client/client.py b/pipelex/client/client.py
index ff9495340..dd507e092 100644
--- a/pipelex/client/client.py
+++ b/pipelex/client/client.py
@@ -92,7 +92,7 @@ class PipelexClient(PipelexProtocol):
raise ValueError(msg)
if inputs is not None:
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=inputs)
pipeline_request = PipelineRequestFactory.make_from_working_memory(
working_memory=working_memory,
@@ -119,7 +119,7 @@ class PipelexClient(PipelexProtocol):
raise ValueError(msg)
if inputs is not None:
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=inputs)
pipeline_request = PipelineRequestFactory.make_from_working_memory(
working_memory=working_memory,
diff --git a/pipelex/client/protocol.py b/pipelex/client/protocol.py
index 2249129d6..88fe1233b 100644
--- a/pipelex/client/protocol.py
+++ b/pipelex/client/protocol.py
@@ -12,7 +12,7 @@ from pipelex.core.stuffs.stuff_content import StuffContent
from pipelex.pipe_run.pipe_run_params import PipeOutputMultiplicity
from pipelex.types import StrEnum
-# StuffContentOrData represents all possible formats for implicit memory input:
+# StuffContentOrData represents all possible formats for pipeline inputs input:
# Case 1: Direct content (no 'concept' key)
# - 1.1: str (simple string)
# - 1.2: Sequence[str] (list of strings)
@@ -78,7 +78,7 @@ class PipelineRequest(BaseModel):
"""
- inputs: Annotated[PipelineInputs | WorkingMemory | None, SkipValidation] = None
+ inputs: Annotated[PipelineInputs | None, SkipValidation] = None
output_name: str | None = None
output_multiplicity: PipeOutputMultiplicity | None = None
dynamic_output_concept_code: str | None = None
diff --git a/pipelex/core/memory/working_memory_factory.py b/pipelex/core/memory/working_memory_factory.py
index a16bd0ba9..0d3c06cf0 100644
--- a/pipelex/core/memory/working_memory_factory.py
+++ b/pipelex/core/memory/working_memory_factory.py
@@ -123,15 +123,15 @@ class WorkingMemoryFactory(BaseModel):
return WorkingMemory(root={})
@classmethod
- def make_from_implicit_memory(
+ def make_from_pipeline_inputs(
cls,
- implicit_memory: PipelineInputs,
+ pipeline_inputs: PipelineInputs,
search_domains: list[str] | None = None,
) -> WorkingMemory:
- """Create a WorkingMemory from a implicit memory dictionary.
+ """Create a WorkingMemory from a pipeline inputs dictionary.
Args:
- implicit_memory: Dictionary in the format from API serialization
+ pipeline_inputs: Dictionary in the format from API serialization
search_domains: List of domains to search for concepts
Returns:
@@ -140,7 +140,7 @@ class WorkingMemoryFactory(BaseModel):
"""
working_memory = cls.make_empty()
- for stuff_key, stuff_content_or_data in implicit_memory.items():
+ for stuff_key, stuff_content_or_data in pipeline_inputs.items():
stuff = StuffFactory.make_stuff_from_stuff_content_or_data(
name=stuff_key,
stuff_content_or_data=stuff_content_or_data,
diff --git a/pipelex/core/stuffs/stuff_factory.py b/pipelex/core/stuffs/stuff_factory.py
index c40ab416a..472c0e5f7 100644
--- a/pipelex/core/stuffs/stuff_factory.py
+++ b/pipelex/core/stuffs/stuff_factory.py
@@ -128,7 +128,7 @@ class StuffFactory:
code: str | None = None,
search_domains: list[str] | None = None,
) -> Stuff:
- """Create a Stuff from StuffContentOrData covering all implicit memory cases.
+ """Create a Stuff from StuffContentOrData covering all pipeline inputs cases.
Case 1: Direct content (no 'concept' key)
1.1: str → TextContent with Text concept
diff --git a/pipelex/pipeline/execute.py b/pipelex/pipeline/execute.py
index 70ae7af99..5a241f60b 100644
--- a/pipelex/pipeline/execute.py
+++ b/pipelex/pipeline/execute.py
@@ -39,7 +39,7 @@ async def execute_pipeline(
pipe_code:
The code of the pipe to execute.
inputs:
- Optional implicit memory or working memory to pass to the pipe.
+ Optional pipeline inputs or working memory to pass to the pipe.
output_name:
Name of the output slot to write to.
output_multiplicity:
@@ -71,8 +71,8 @@ async def execute_pipeline(
if isinstance(inputs, WorkingMemory):
working_memory = inputs
else:
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(
- implicit_memory=inputs,
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(
+ pipeline_inputs=inputs,
search_domains=search_domains,
)
diff --git a/pipelex/pipeline/start.py b/pipelex/pipeline/start.py
index f5c4e58af..0438e51fc 100644
--- a/pipelex/pipeline/start.py
+++ b/pipelex/pipeline/start.py
@@ -4,7 +4,6 @@ from pipelex.client.protocol import PipelineInputs
from pipelex.core.memory.working_memory import WorkingMemory
from pipelex.core.memory.working_memory_factory import WorkingMemoryFactory
from pipelex.core.pipes.pipe_output import PipeOutput
-from pipelex.exceptions import StartPipelineError
from pipelex.hub import get_pipe_router, get_pipeline_manager, get_report_delegate, get_required_pipe
from pipelex.pipe_run.pipe_job_factory import PipeJobFactory
from pipelex.pipe_run.pipe_run_params import PipeOutputMultiplicity, PipeRunMode
@@ -14,8 +13,7 @@ from pipelex.pipeline.job_metadata import JobMetadata
async def start_pipeline(
pipe_code: str,
- working_memory: WorkingMemory | None = None,
- inputs: PipelineInputs | None = None,
+ inputs: PipelineInputs | WorkingMemory | None = None,
output_name: str | None = None,
output_multiplicity: PipeOutputMultiplicity | None = None,
dynamic_output_concept_code: str | None = None,
@@ -32,10 +30,8 @@ async def start_pipeline(
----------
pipe_code:
The code of the pipe to execute.
- working_memory:
- Optional ``WorkingMemory`` instance passed to the pipe.
inputs:
- Optional implicit memory to pass to the pipe.
+ Optional pipeline inputs or working memory to pass to the pipe.
output_name:
Name of the output slot to write to.
output_multiplicity:
@@ -52,12 +48,13 @@ async def start_pipeline(
can be awaited to get the pipe output.
"""
- if working_memory and inputs:
- msg = f"Cannot pass both working_memory and inputs to `start_pipeline` {pipe_code=}"
- raise StartPipelineError(msg)
+ working_memory: WorkingMemory | None = None
if inputs:
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)
+ if isinstance(inputs, WorkingMemory):
+ working_memory = inputs
+ else:
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=inputs)
pipeline = get_pipeline_manager().add_new_pipeline()
pipeline_run_id = pipeline.pipeline_run_id
diff --git a/tests/integration/pipelex/core/memory/test_working_memory_factory.py b/tests/integration/pipelex/core/memory/test_working_memory_factory.py
index 08b547e4c..89a73aae1 100644
--- a/tests/integration/pipelex/core/memory/test_working_memory_factory.py
+++ b/tests/integration/pipelex/core/memory/test_working_memory_factory.py
@@ -13,14 +13,14 @@ if TYPE_CHECKING:
class TestWorkingMemoryFactory:
def test_make_from_compact_memory_with_text_content(self):
- implicit_memory: PipelineInputs = {
+ pipeline_inputs: PipelineInputs = {
"text_item": {
"concept": NativeConceptCode.TEXT,
"content": "Hello, world!",
},
}
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=pipeline_inputs)
assert working_memory is not None
assert "text_item" in working_memory.root
@@ -32,7 +32,7 @@ class TestWorkingMemoryFactory:
def test_make_from_compact_memory_with_complex_nested_content(self):
"""Test deserialization of compact memory with complex nested structured content."""
- implicit_memory: PipelineInputs = {
+ pipeline_inputs: PipelineInputs = {
"complex_page": {
"concept": NativeConceptCode.PAGE,
"content": {
@@ -60,7 +60,7 @@ class TestWorkingMemoryFactory:
},
}
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=pipeline_inputs)
assert working_memory is not None
assert "complex_page" in working_memory.root
@@ -113,16 +113,16 @@ class TestWorkingMemoryFactory:
def test_make_from_compact_memory_empty(self):
"""Test deserialization of empty compact memory."""
- implicit_memory: PipelineInputs = {}
+ pipeline_inputs: PipelineInputs = {}
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=pipeline_inputs)
assert working_memory is not None
assert len(working_memory.root) == 0
def test_make_from_compact_memory_multiple_items(self):
"""Test deserialization of compact memory with multiple items."""
- implicit_memory: PipelineInputs = {
+ pipeline_inputs: PipelineInputs = {
"text1": {
"concept": NativeConceptCode.TEXT,
"content": "First text",
@@ -133,7 +133,7 @@ class TestWorkingMemoryFactory:
},
}
- working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)
+ working_memory = WorkingMemoryFactory.make_from_pipeline_inputs(pipeline_inputs=pipeline_inputs)
assert working_memory is not None
assert len(working_memory.root) == 2
diff --git a/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py b/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py
index c13050b01..ddd228013 100644
--- a/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py
+++ b/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py
@@ -64,7 +64,7 @@ def setup_test_concept():
class TestStuffFactoryImplicitMemory:
- """Test StuffFactory with implicit memory input formats.
+ """Test StuffFactory with pipeline inputs input formats.
This covers cases where stuff_content_or_data is:
- Case 1: Direct content (no 'concept' key)
diff --git a/tests/unit/pipelex/client/test_api_serialization.py b/tests/unit/pipelex/client/test_api_serialization.py
index 416445ba9..188891bb4 100644
--- a/tests/unit/pipelex/client/test_api_serialization.py
+++ b/tests/unit/pipelex/client/test_api_serialization.py
@@ -90,14 +90,14 @@ class TestApiSerialization:
return WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
def test_serialize_working_memory_with_datetime(self, datetime_content_memory: WorkingMemory):
- implicit_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)
+ pipeline_inputs = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)
# Should have one entry for the datetime content
- assert len(implicit_memory) == 1
- assert "project_meeting" in implicit_memory
+ assert len(pipeline_inputs) == 1
+ assert "project_meeting" in pipeline_inputs
# Check the dict structure
- datetime_blueprint = implicit_memory["project_meeting"]
+ datetime_blueprint = pipeline_inputs["project_meeting"]
assert isinstance(datetime_blueprint, dict)
assert datetime_blueprint["concept"] == "DateTimeEvent"
@@ -122,14 +122,14 @@ class TestApiSerialization:
assert "__class__" not in content
def test_api_serialized_memory_is_json_serializable(self, datetime_content_memory: WorkingMemory):
- implicit_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)
+ pipeline_inputs = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)
# This should NOT raise an exception now
- json_string = json.dumps(implicit_memory)
+ json_string = json.dumps(pipeline_inputs)
roundtrip = json.loads(json_string)
# Verify roundtrip works
- assert roundtrip == implicit_memory
+ assert roundtrip == pipeline_inputs
# Verify datetime fields are strings
content = roundtrip["project_meeting"]["content"]
@@ -138,22 +138,22 @@ class TestApiSerialization:
assert isinstance(content["created_at"], str)
def test_serialize_text_content(self, text_content_memory: WorkingMemory):
- implicit_memory = ApiSerializer.serialize_working_memory_for_api(text_content_memory)
+ pipeline_inputs = ApiSerializer.serialize_working_memory_for_api(text_content_memory)
- assert len(implicit_memory) == 1
- assert "sample_text" in implicit_memory
+ assert len(pipeline_inputs) == 1
+ assert "sample_text" in pipeline_inputs
- text_blueprint = cast("dict[str, Any]", implicit_memory["sample_text"])
+ text_blueprint = cast("dict[str, Any]", pipeline_inputs["sample_text"])
assert text_blueprint["concept"] == NativeConceptCode.TEXT
assert text_blueprint["content"] == {"text": "Sample text content"}
def test_serialize_number_content(self, number_content_memory: WorkingMemory):
- implicit_memory = ApiSerializer.serialize_working_memory_for_api(number_content_memory)
+ pipeline_inputs = ApiSerializer.serialize_working_memory_for_api(number_content_memory)
- assert len(implicit_memory) == 1
- assert "pi_value" in implicit_memory
+ assert len(pipeline_inputs) == 1
+ assert "pi_value" in pipeline_inputs
- number_blueprint = cast("dict[str, Any]", implicit_memory["pi_value"])
+ number_blueprint = cast("dict[str, Any]", pipeline_inputs["pi_value"])
assert number_blueprint["concept"] == NativeConceptCode.NUMBER
assert isinstance(number_blueprint["content"], dict)
assert number_blueprint["content"]["number"] == 3.14159