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.
Compact Memory to DictMemory
thomashebrarda6d2d45ca0b6
diff --git a/pipelex/builder/builder_loop.py b/pipelex/builder/builder_loop.pyindex a703e492d..c38d5df5a 100644--- a/pipelex/builder/builder_loop.py+++ b/pipelex/builder/builder_loop.py@@ -24,7 +24,7 @@ class BuilderLoop:pretty_print(f"Building and fixing with {pipe_code}")pipe_output = await execute_pipeline(pipe_code=pipe_code,- input_memory=input_memory,+ inputs=input_memory,)pretty_print(pipe_output, title="Pipe Output")diff --git a/pipelex/builder/runner_code.py b/pipelex/builder/runner_code.pyindex 4234f55aa..ee18434e5 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 compact_memory dictionary entry for a given input."""+ """Generate the implicit_memory dictionary entry for a given input."""example_value = concept.get_compact_memory_example(var_name)# Convert the example value to a Python code stringdiff --git a/pipelex/cli/commands/build_cmd.py b/pipelex/cli/commands/build_cmd.pyindex ebf3d875c..b8f7213a2 100644--- a/pipelex/cli/commands/build_cmd.py+++ b/pipelex/cli/commands/build_cmd.py@@ -253,7 +253,7 @@ def build_one_shot_cmd(pipe_output = await execute_pipeline(pipe_code="pipe_builder",- input_memory={"brief": brief},+ inputs={"brief": brief},)pretty_print(pipe_output, title="Pipe Output")@@ -308,7 +308,7 @@ def build_partial_cmd(pipe_output = await execute_pipeline(pipe_code="pipe_builder",- input_memory={"brief": brief},+ inputs={"brief": brief},)# Save to file unless explicitly disabled with --no-outputif no_output:diff --git a/pipelex/cli/commands/run_cmd.py b/pipelex/cli/commands/run_cmd.pyindex b69f7f26f..477ab712f 100644--- a/pipelex/cli/commands/run_cmd.py+++ b/pipelex/cli/commands/run_cmd.py@@ -148,7 +148,7 @@ def run_cmd(pipe_output = await execute_pipeline(pipe_code=pipe_code,- input_memory=input_memory,+ inputs=input_memory,)# Pretty print main_stuff unless disableddiff --git a/pipelex/client/api_serializer.py b/pipelex/client/api_serializer.pyindex 64fbc017b..03a0f0934 100644--- a/pipelex/client/api_serializer.py+++ b/pipelex/client/api_serializer.py@@ -4,7 +4,7 @@ from enum import Enumfrom pathlib import Pathfrom typing import TYPE_CHECKING, Any, cast-from pipelex.client.protocol import CompactMemory+from pipelex.client.protocol import DictMemoryfrom pipelex.core.concepts.concept_native import NativeConceptCodefrom pipelex.core.memory.working_memory import WorkingMemoryfrom pipelex.core.pipes.pipe_output import PipeOutput@@ -21,19 +21,20 @@ class ApiSerializer:FIELDS_TO_SKIP = ("__class__", "__module__")@classmethod- def serialize_working_memory_for_api(cls, working_memory: WorkingMemory | None = None) -> CompactMemory:+ def serialize_working_memory_for_api(cls, working_memory: WorkingMemory | None = None) -> DictMemory:"""Convert WorkingMemory to API-ready format using kajson with proper datetime handling.Args:working_memory: The WorkingMemory to serializeReturns:- Dict ready for API transmission with datetime strings and no __class__/__module__+ ImplicitMemory ready for API transmission with datetime strings and no __class__/__module__.+ Its"""- compact_memory: CompactMemory = {}+ dict_memory: DictMemory = {}if working_memory is None:- return compact_memory+ return dict_memoryfor stuff_name, stuff in working_memory.root.items():if NativeConceptCode.is_text_concept(concept_code=stuff.concept.code):@@ -51,12 +52,12 @@ class ApiSerializer:"content": clean_content,}- compact_memory[stuff_name] = item_dict+ dict_memory[stuff_name] = item_dict- return compact_memory+ return dict_memory@classmethod- def serialize_pipe_output_for_api(cls, pipe_output: PipeOutput) -> CompactMemory:+ def serialize_pipe_output_for_api(cls, pipe_output: PipeOutput) -> DictMemory:"""Convert PipeOutput to API-ready format.Args:@@ -66,7 +67,7 @@ class ApiSerializer:Dict ready for API transmission"""- return {"compact_memory": cls.serialize_working_memory_for_api(pipe_output.working_memory)}+ return {"dict_memory": cls.serialize_working_memory_for_api(pipe_output.working_memory)}@classmethoddef _clean_and_format_content(cls, content: Any) -> Any:diff --git a/pipelex/client/client.py b/pipelex/client/client.pyindex f1bb0beb1..ed3e488b6 100644--- a/pipelex/client/client.py+++ b/pipelex/client/client.py@@ -5,7 +5,7 @@ from typing_extensions import overridefrom pipelex.client.pipeline_request_factory import PipelineRequestFactoryfrom pipelex.client.pipeline_response_factory import PipelineResponseFactory-from pipelex.client.protocol import CompactMemory, PipelexProtocol, PipelineResponse+from pipelex.client.protocol import ImplicitMemory, PipelexProtocol, PipelineResponsefrom pipelex.core.memory.working_memory import WorkingMemoryfrom pipelex.core.memory.working_memory_factory import WorkingMemoryFactoryfrom pipelex.exceptions import ClientAuthenticationError@@ -81,17 +81,17 @@ class PipelexClient(PipelexProtocol):self,pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: CompactMemory | None = None,+ inputs: ImplicitMemory | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,dynamic_output_concept_code: str | None = None,) -> PipelineResponse:- if working_memory and input_memory:- msg = f"working_memory and input_memory cannot be provided together to the API execute_pipeline {pipe_code=}"+ if working_memory and inputs:+ msg = f"working_memory and inputs cannot be provided together to the API execute_pipeline {pipe_code=}"raise ValueError(msg)- if input_memory is not None:- working_memory = WorkingMemoryFactory.make_from_compact_memory(input_memory)+ if inputs is not None:+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)pipeline_request = PipelineRequestFactory.make_from_working_memory(working_memory=working_memory,@@ -107,17 +107,17 @@ class PipelexClient(PipelexProtocol):self,pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: CompactMemory | None = None,+ inputs: ImplicitMemory | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,dynamic_output_concept_code: str | None = None,) -> PipelineResponse:- if working_memory and input_memory:- msg = f"working_memory and input_memory cannot be provided together to the API start_pipeline {pipe_code=}"+ if working_memory and inputs:+ msg = f"working_memory and inputs cannot be provided together to the API start_pipeline {pipe_code=}"raise ValueError(msg)- if input_memory is not None:- working_memory = WorkingMemoryFactory.make_from_compact_memory(input_memory)+ if inputs is not None:+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)pipeline_request = PipelineRequestFactory.make_from_working_memory(working_memory=working_memory,diff --git a/pipelex/client/implicit_memory.py b/pipelex/client/implicit_memory.pyindex d1f3637d5..939d17940 100644--- a/pipelex/client/implicit_memory.py+++ b/pipelex/client/implicit_memory.py@@ -1,11 +1,9 @@-from unittest import suite-from pipelex.core.stuffs.stuff import Stufffrom pipelex.core.concepts.concept_factory import ConceptFactoryfrom pipelex.core.concepts.concept_native import NativeConceptCode-from pipelex.core.stuffs.text_content import TextContentfrom pipelex.core.stuffs.list_content import ListContentfrom pipelex.core.stuffs.structured_content import StructuredContent-from pipelex.core.stuffs.json_content import JSONContent+from pipelex.core.stuffs.stuff import Stuff+from pipelex.core.stuffs.text_content import TextContentclass MySubClass(StructuredContent):@@ -82,7 +80,7 @@ stuff14 = Stuff()####################################################################################################-## CASE 2: Here, we HAVE the key "concept_string" AND the key "content".+## CASE 2: Here, we HAVE the key "concept_string" AND the key "content".# The value of the "content" key can Either be a:# 2.1: a string.# 2.2: a list of strings.@@ -94,43 +92,37 @@ stuff14 = Stuff(# 2.1: Content is a string-stuff_data21 = {- "concept": "concept_string",- "content": "my text"-}+stuff_data21 = {"concept": "concept_string", "content": "my text"}-# Here, the concept can either be Text, native.Text or any other concept. But if its any other concept, it should be stricly compatible with the concept native.Text.+# Here, the concept can either be Text, native.Text or any other concept. But if its any other concept,+# it should be stricly compatible with the concept native.Text.stuff21 = Stuff(stuff_code="stuff_code",stuff_name="stuff_name",- concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT), # Or else+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT), # Or elsecontent=TextContent(text="my text"),)# 2.2: Content is a list of strings-stuff_data22 = {- "concept": "concept_string",- "content": ["text1", "text2", "text3"]-}+stuff_data22 = {"concept": "concept_string", "content": ["text1", "text2", "text3"]}-# Here, the concept can either be Text, native.Text or any other concept. But if its any other concept, it should be stricly compatible with the concept native.Text.+# Here, the concept can either be Text, native.Text or any other concept. But if its any other concept,+# it should be stricly compatible with the concept native.Text.stuff22 = Stuff(stuff_code="stuff_code",stuff_name="stuff_name",- concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT), # Or else+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT), # Or elsecontent=ListContent(items=[TextContent(text="text1"), TextContent(text="text2"), TextContent(text="text3")]),)# 2.3: Content is a StuffContent object-stuff_data23 = {- "concept": "concept_string",- "content": MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4"))-}+stuff_data23 = {"concept": "concept_string", "content": MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4"))}# For the concept mentioned: If no domain is specified, it should look in all the library for the concept with the same name.-# If no search domains are provided and we find 2 or more concepts with the same name, it should raise an error and ask the user to specify the domain.+# If no search domains are provided and we find 2 or more concepts with the same name, it should raise an error+# and ask the user to specify the domain.# If the domain is specified or found, it should check that the structure corresponds with the given content.# Otherwise it should raise an error.@@ -144,10 +136,7 @@ stuff23 = Stuff(# 2.4: Content is a list of StuffContent objectsstuff_data24 = {"concept": "concept_string",- "content": [- MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),- MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4"))- ],+ "content": [MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")), MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4"))],}stuff24 = Stuff(@@ -160,19 +149,11 @@ stuff24 = Stuff()# 2.5: Content is a dict-stuff_data25 = {- "concept": "concept_string",- "content": {- "arg1": "something",- "arg2": 1,- "arg3": {- "arg4": "something else else"- }- }-}+stuff_data25 = {"concept": "concept_string", "content": {"arg1": "something", "arg2": 1, "arg3": {"arg4": "something else else"}}}# For the concept mentioned: If no domain is specified, it should look in all the library for the concept with the same name.-# If no search domains are provided and we find 2 or more concepts with the same name, it should raise an error and ask the user to specify the domain.+# If no search domains are provided and we find 2 or more concepts with the same name, it should raise an error+# and ask the user to specify the domain.# If the domain is specified or found, it should check that the structure corresponds with the given content by validating the model.# Otherwise it should raise an error.@@ -187,25 +168,14 @@ stuff25 = Stuff(stuff_data26 = {"concept": "concept_string","content": [- {- "arg1": "something",- "arg2": 1,- "arg3": {- "arg4": "something else else"- }- },- {- "arg1": "something else",- "arg2": 2,- "arg3": {- "arg4": "something else else else"- }- }+ {"arg1": "something", "arg2": 1, "arg3": {"arg4": "something else else"}},+ {"arg1": "something else", "arg2": 2, "arg3": {"arg4": "something else else else"}},],}# For the concept mentioned: If no domain is specified, it should look in all the library for the concept with the same name.-# If no search domains are provided and we find 2 or more concepts with the same name, it should raise an error and ask the user to specify the domain.+# If no search domains are provided and we find 2 or more concepts with the same name, it+# should raise an error and ask the user to specify the domain.# If the domain is specified or found, it should check that the structure corresponds with the given content by validating the model.# Otherwise it should raise an error.diff --git a/pipelex/client/pipeline_request_factory.py b/pipelex/client/pipeline_request_factory.pyindex ae2112553..dbd9683ef 100644--- a/pipelex/client/pipeline_request_factory.py+++ b/pipelex/client/pipeline_request_factory.py@@ -1,7 +1,7 @@from typing import Anyfrom pipelex.client.api_serializer import ApiSerializer-from pipelex.client.protocol import COMPACT_MEMORY_KEY, PipelineRequest+from pipelex.client.protocol import ImplicitMemory, PipelineRequestfrom pipelex.core.memory.working_memory import WorkingMemoryfrom pipelex.pipe_run.pipe_run_params import PipeOutputMultiplicity@@ -29,7 +29,7 @@ class PipelineRequestFactory:"""return PipelineRequest(- input_memory=ApiSerializer.serialize_working_memory_for_api(working_memory),+ inputs=ImplicitMemory(ApiSerializer.serialize_working_memory_for_api(working_memory=working_memory)),output_name=output_name,output_multiplicity=output_multiplicity,dynamic_output_concept_code=dynamic_output_concept_code,@@ -47,7 +47,7 @@ class PipelineRequestFactory:"""return PipelineRequest(- input_memory=request_body.get(COMPACT_MEMORY_KEY),+ inputs=request_body.get("inputs", {}),output_name=request_body.get("output_name"),output_multiplicity=request_body.get("output_multiplicity"),dynamic_output_concept_code=request_body.get("dynamic_output_concept_code"),diff --git a/pipelex/client/pipeline_response_factory.py b/pipelex/client/pipeline_response_factory.pyindex 1d1d947fa..a4872e1a8 100644--- a/pipelex/client/pipeline_response_factory.py+++ b/pipelex/client/pipeline_response_factory.py@@ -2,6 +2,7 @@ from typing import Anyfrom pipelex.client.api_serializer import ApiSerializerfrom pipelex.client.protocol import PipelineResponse, PipelineState+from pipelex.core.memory.working_memory import MAIN_STUFF_NAMEfrom pipelex.core.pipes.pipe_output import PipeOutput@@ -10,7 +11,7 @@ class PipelineResponseFactory:@staticmethoddef make_from_pipe_output(- pipe_output: PipeOutput | None = None,+ pipe_output: PipeOutput,pipeline_run_id: str = "",created_at: str = "",pipeline_state: PipelineState = PipelineState.COMPLETED,@@ -35,9 +36,7 @@ class PipelineResponseFactory:PipelineResponse with the pipe output serialized to reduced format"""- compact_output = None- if pipe_output is not None:- compact_output = ApiSerializer.serialize_pipe_output_for_api(pipe_output=pipe_output)+ compact_output = ApiSerializer.serialize_pipe_output_for_api(pipe_output=pipe_output)return PipelineResponse(pipeline_run_id=pipeline_run_id,@@ -45,6 +44,7 @@ class PipelineResponseFactory:pipeline_state=pipeline_state,finished_at=finished_at,pipe_output=compact_output,+ main_stuff_name=pipe_output.working_memory.aliases.get(MAIN_STUFF_NAME, MAIN_STUFF_NAME),status=status,message=message,error=error,diff --git a/pipelex/client/protocol.py b/pipelex/client/protocol.pyindex 8d91b6d98..7c3d42a1c 100644--- a/pipelex/client/protocol.py+++ b/pipelex/client/protocol.py@@ -9,10 +9,29 @@ from pipelex.core.stuffs.stuff_content import StuffContentfrom pipelex.pipe_run.pipe_run_params import PipeOutputMultiplicityfrom pipelex.types import StrEnum-StuffContentOrData = dict[str, Any] | StuffContent | list[Any] | str+# StuffContentOrData represents all possible formats for implicit memory input:+# Case 1: Direct content (no 'concept' key)+# - 1.1: str (simple string)+# - 1.2: list[str] (list of strings)+# - 1.3: StuffContent (a StuffContent object)+# - 1.4: list[StuffContent] (list of StuffContent objects)+# Case 2: Dict with 'concept' AND 'content' keys+# - 2.1: {"concept": str, "content": str}+# - 2.2: {"concept": str, "content": list[str]}+# - 2.3: {"concept": str, "content": StuffContent}+# - 2.4: {"concept": str, "content": list[StuffContent]}+# - 2.5: {"concept": str, "content": dict[str, Any]}+# - 2.6: {"concept": str, "content": list[dict[str, Any]]}+DictStuffContent = dict[str, Any]+StuffContentOrData = (+ str # Case 1.1+ | list[str] # Case 1.2+ | StuffContent # Case 1.3+ | list[StuffContent] # Case 1.4+ | DictStuffContent # Case 2.1, 2.2, 2.3, 2.4, 2.5, 2.6+)ImplicitMemory = dict[str, StuffContentOrData]-CompactMemory = dict[str, dict[str, Any]]-COMPACT_MEMORY_KEY = "compact_memory"+DictMemory = dict[str, DictStuffContent] # Special case of ImplicitMemoryclass PipelineState(StrEnum):@@ -45,14 +64,14 @@ class PipelineRequest(BaseModel):"""Request for executing a pipeline.Attributes:- input_memory (CompactMemory | None): In the format of WorkingMemory.to_compact_memory()+ inputs (ImplicitMemory | None): Inputs in the format of WorkingMemory.to_implicit_memory()output_name (str | None): Name of the output slot to write tooutput_multiplicity (PipeOutputMultiplicity | None): Output multiplicity settingdynamic_output_concept_code (str | None): Override for the dynamic output concept code"""- input_memory: CompactMemory | None = None+ inputs: ImplicitMemory | None = Noneoutput_name: str | None = Noneoutput_multiplicity: PipeOutputMultiplicity | None = Nonedynamic_output_concept_code: str | None = None@@ -62,47 +81,20 @@ class PipelineResponse(ApiResponse):"""Response for pipeline execution requests.Attributes:- pipeline_run_id (str): Unique identifier for the pipeline runcreated_at (str): Timestamp when the pipeline was createdpipeline_state (PipelineState): Current state of the pipelinefinished_at (str | None): Timestamp when the pipeline finished, if completed- pipe_output (CompactMemory | None): Output data from the pipeline execution as raw dict, if available-- Example of pipe_output:- "pipe_output": {- "input_memory": {- "text": {- "concept_code": "native.Text",- "content": "Some text........"- },- "question": {- "concept_code": "answer.Question",- "content": {- "text": "What are aerodynamic features?"- }- },- "main_stuff": {- "concept_code": "retrieve.RetrievedExcerpt",- "content": {- "items": [- {- "text": "What we're seeing isn't just an incremental...",- "justification": "This excerpt directly mentions the 'aerodynamic profile' of ...."- },- ...- ]- }- }- }- }-+ pipeline_run_id (str): Unique identifier for the pipeline run+ pipe_output (DictMemory | None): Output data from the pipeline execution as raw dict, if available+ main_stuff_name (str): Name of the main stuff in the pipeline output"""- pipeline_run_id: strcreated_at: strpipeline_state: PipelineStatefinished_at: str | None = None- pipe_output: CompactMemory | None = None+ pipeline_run_id: str+ pipe_output: DictMemory | None = None+ main_stuff_name: str@runtime_checkable@@ -126,7 +118,7 @@ class PipelexProtocol(Protocol):self,pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: CompactMemory | None = None,+ inputs: ImplicitMemory | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,dynamic_output_concept_code: str | None = None,@@ -136,7 +128,7 @@ class PipelexProtocol(Protocol):Args:pipe_code (str): The code identifying the pipeline to executeworking_memory (WorkingMemory | None): Memory context passed to the pipeline- input_memory (CompactMemory | None): Input memory passed to the pipeline+ inputs (ImplicitMemory | None): Inputs passed to the pipelineoutput_name (str | None): Target output slot nameoutput_multiplicity (PipeOutputMultiplicity | None): Output multiplicity settingdynamic_output_concept_code (str | None): Override for dynamic output concept@@ -155,7 +147,7 @@ class PipelexProtocol(Protocol):self,pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: CompactMemory | None = None,+ inputs: ImplicitMemory | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,dynamic_output_concept_code: str | None = None,@@ -165,7 +157,7 @@ class PipelexProtocol(Protocol):Args:pipe_code (str): The code identifying the pipeline to executeworking_memory (WorkingMemory | None): Memory context passed to the pipeline- input_memory (CompactMemory | None): Input memory passed to the pipeline+ inputs (ImplicitMemory | None): Inputs passed to the pipelineoutput_name (str | None): Target output slot nameoutput_multiplicity (PipeOutputMultiplicity | None): Output multiplicity settingdynamic_output_concept_code (str | None): Override for dynamic output conceptdiff --git a/pipelex/core/concepts/concept_library.py b/pipelex/core/concepts/concept_library.pyindex 807184ead..9ae9b2da4 100644--- a/pipelex/core/concepts/concept_library.py+++ b/pipelex/core/concepts/concept_library.py@@ -123,6 +123,30 @@ class ConceptLibrary(RootModel[ConceptLibraryRoot], ConceptLibraryAbstract):)return is_image_class or refines_image+ @override+ def get_required_concept_from_concept_string_or_code(self, concept_string_or_code: str, search_domains: list[str] | None = None) -> Concept:+ if "." in concept_string_or_code:+ return self.get_required_concept(concept_string=concept_string_or_code)+ elif NativeConceptCode.is_native_concept(concept_code=concept_string_or_code):+ return self.get_native_concept(native_concept=NativeConceptCode(concept_string_or_code))+ else:+ if search_domains is None:+ msg = f"Concept '{concept_string_or_code}' not found in the library and no search domains were provided"+ raise ConceptLibraryConceptNotFoundError(msg)+ found_concepts: list[Concept] = []+ for domain in search_domains:+ if found_concept := self.get_required_concept(+ concept_string=ConceptFactory.make_concept_string_with_domain(domain=domain, concept_code=concept_string_or_code),+ ):+ found_concepts.append(found_concept)+ if len(found_concepts) == 0:+ msg = f"Concept '{concept_string_or_code}' not found in the library and no search domains were provided"+ raise ConceptLibraryConceptNotFoundError(msg)+ if len(found_concepts) > 1:+ msg = f"Multiple concepts found for '{concept_string_or_code}': {found_concepts}. Please specify the domain."+ raise ConceptLibraryConceptNotFoundError(msg)+ return found_concepts[0]+@overridedef search_for_concept_in_domains(self, concept_code: str, search_domains: list[str]) -> Concept | None:ConceptBlueprint.validate_concept_code(concept_code=concept_code)diff --git a/pipelex/core/concepts/concept_library_abstract.py b/pipelex/core/concepts/concept_library_abstract.pyindex 386e895a3..ae2a0ae30 100644--- a/pipelex/core/concepts/concept_library_abstract.py+++ b/pipelex/core/concepts/concept_library_abstract.py@@ -61,3 +61,7 @@ class ConceptLibraryAbstract(ABC):@abstractmethoddef get_native_concept(self, native_concept: NativeConceptCode) -> Concept:pass++ @abstractmethod+ def get_required_concept_from_concept_string_or_code(self, concept_string_or_code: str, search_domains: list[str] | None = None) -> Concept:+ passdiff --git a/pipelex/core/memory/working_memory_factory.py b/pipelex/core/memory/working_memory_factory.pyindex 68ada701e..40e092f61 100644--- a/pipelex/core/memory/working_memory_factory.py+++ b/pipelex/core/memory/working_memory_factory.py@@ -1,4 +1,4 @@-from typing import Any, cast+from typing import Anyimport shortuuidfrom polyfactory.factories.pydantic_factory import ModelFactory@@ -132,7 +132,7 @@ class WorkingMemoryFactory(BaseModel):Args:implicit_memory: Dictionary in the format from API serialization- search_domains: List of search domains to use when making stuff+ search_domains: List of domains to search for conceptsReturns:WorkingMemory object reconstructed from the implicit format@@ -140,15 +140,13 @@ class WorkingMemoryFactory(BaseModel):"""working_memory = cls.make_empty()- for stuff_key, compact_stuff_content in implicit_memory.items():- stuff = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ for stuff_key, stuff_content_or_data in implicit_memory.items():+ stuff = StuffFactory.make_stuff_from_stuff_content_or_data(name=stuff_key,stuff_content_or_data=stuff_content_or_data,- search_domains=search_domains or [],+ search_domains=search_domains,)-working_memory.add_new_stuff(name=stuff_key, stuff=stuff)-return working_memory@classmethoddiff --git a/pipelex/core/stuffs/stuff_factory.py b/pipelex/core/stuffs/stuff_factory.pyindex c495e7090..c0d2db11d 100644--- a/pipelex/core/stuffs/stuff_factory.py+++ b/pipelex/core/stuffs/stuff_factory.py@@ -7,6 +7,7 @@ from pipelex.client.protocol import StuffContentOrDatafrom pipelex.core.concepts.concept import Conceptfrom pipelex.core.concepts.concept_blueprint import ConceptBlueprintfrom pipelex.core.concepts.concept_factory import ConceptFactory+from pipelex.core.concepts.concept_library import ConceptLibraryConceptNotFoundErrorfrom pipelex.core.concepts.concept_native import NativeConceptCodefrom pipelex.core.stuffs.list_content import ListContentfrom pipelex.core.stuffs.stuff import Stuff@@ -119,149 +120,286 @@ class StuffFactory:)@classmethod- def make_stuff_using_concept_name_and_search_domains(+ def make_stuff_from_stuff_content_or_data(cls,- concept_name: str,- search_domains: list[str],- content: StuffContent,+ stuff_content_or_data: StuffContentOrData,name: str | None = None,code: str | None = None,+ search_domains: list[str] | None = None,) -> Stuff:- # TODO: Add unit tests for this method+ """Create a Stuff from StuffContentOrData covering all implicit memory cases.++ Case 1: Direct content (no 'concept' key)+ 1.1: str → TextContent with Text concept+ 1.2: list[str] → ListContent[TextContent] with Text concept+ 1.3: StuffContent → Use the StuffContent, infer concept from class name+ 1.4: list[StuffContent] → ListContent[StuffContent], infer concept from first item++ Case 2: Dict with 'concept' AND 'content' keys+ 2.1/2.1b: {"concept": "Text"/"native.Text", "content": str} → TextContent with Text concept+ 2.1c: {"concept": "domain.Concept", "content": str} → TextContent with that concept (if compatible)+ 2.2/2.2b: {"concept": "...", "content": list[str]} → ListContent[TextContent]+ 2.3: {"concept": "...", "content": StuffContent} → Use the StuffContent+ 2.4: {"concept": "...", "content": list[StuffContent]} → ListContent[StuffContent]+ 2.5: {"concept": "...", "content": dict} → Create StuffContent from dict+ 2.6: {"concept": "...", "content": list[dict]} → ListContent[StuffContent] from dicts+ """concept_library = get_concept_library()- concept = concept_library.search_for_concept_in_domains(- concept_code=concept_name,- search_domains=search_domains,- )- if not concept:- msg = f"Could not find a concept named '{concept_name}' in domains {search_domains}"- raise StuffFactoryError(msg)- return cls.make_stuff(concept=concept, content=content, name=name, code=code)- @classmethod- def make_stuff_from_stuff_content_using_search_domains(- cls,- name: str,- stuff_content_or_data: StuffContentOrData,- search_domains: list[str],- stuff_code: str | None = None,- ) -> Stuff:- # TODO: Add unit tests for this method- content: StuffContent- concept_name: str- if isinstance(stuff_content_or_data, ListContent):- content = cast("ListContent[Any]", stuff_content_or_data)- if len(content.items) == 0:- msg = "ListContent in compact memory has no items"- raise StuffFactoryError(msg)- concept_name = type(content.items[0]).__name__- try:- return cls.make_stuff_using_concept_name_and_search_domains(- concept_name=concept_name,- search_domains=search_domains,- content=content,+ # ==================== CASE 1: Direct content (no concept key) ====================+ if not isinstance(stuff_content_or_data, dict):+ # Case 1.1: str → TextContent with Text concept+ if isinstance(stuff_content_or_data, str):+ return cls.make_stuff(+ concept=get_native_concept(native_concept=NativeConceptCode.TEXT),+ content=TextContent(text=stuff_content_or_data),name=name,- code=stuff_code,+ code=code,)- except StuffFactoryError as exc:- msg = f"Could not make stuff for ListContent '{name}': {exc}"- raise StuffFactoryError(msg) from exc- elif isinstance(stuff_content_or_data, StuffContent):- content = stuff_content_or_data- concept_class_name = type(content).__name__- native_concept_class_names = NativeConceptCode.native_concept_class_names()-- if concept_class_name in native_concept_class_names:- concept = get_native_concept(native_concept=NativeConceptCode(concept_class_name.split("Content")[0]))++ # Case 1.3: StuffContent object → Infer concept from class name+ if issubclass(type(stuff_content_or_data), StuffContent):+ # Get the concept from the StuffContent class name+ content_class_name = stuff_content_or_data.__class__.__name__++ # Check if it's a native concept+ if "Content" in content_class_name and NativeConceptCode.is_native_concept(concept_code=content_class_name.split("Content")[0]):+ # It's a native concept like TextContent, ImageContent, etc.+ concept = get_native_concept(native_concept=NativeConceptCode(content_class_name.split("Content")[0]))+ else:+ try:+ # It's a custom StuffContent, try to find the concept+ concept = concept_library.get_required_concept(concept_string=content_class_name)+ except ConceptLibraryConceptNotFoundError as exc:+ msg = f"Trying to create a Stuff '{name}' from a custom StuffContent '{content_class_name}' "+ "but the concept of name '{content_class_name}' is not found in the library"+ raise StuffFactoryError(msg) from exc++ # Case 1.2 or 1.4: list → ListContent+ if isinstance(stuff_content_or_data, list):+ if len(stuff_content_or_data) == 0:+ msg = f"Cannot create Stuff '{name}' from empty list"+ raise StuffFactoryError(msg)++ first_item = stuff_content_or_data[0]++ # Case 1.2: list[str] → ListContent[TextContent] with Text concept+ if isinstance(first_item, str):+ for item in stuff_content_or_data:+ if not isinstance(item, str):+ msg = f"Trying to create a Stuff '{name}' from a list of strings but the item {item} is not a string."+ "Every items of the list should be a identical type. If its a string, everything should be a string."+ raise StuffFactoryError(msg)++ items = [TextContent(text=item) for item in cast("list[str]", stuff_content_or_data)]+ return cls.make_stuff(+ concept=get_native_concept(native_concept=NativeConceptCode.TEXT),+ content=ListContent(items=items),+ name=name,+ code=code,+ )++ # Case 1.4: list[StuffContent] → ListContent[StuffContent]+ if isinstance(first_item, StuffContent):+ # Get the concept from the first item's class name+ content_class_name = type(first_item).__name__++ # Check all items are of the same type+ for item in stuff_content_or_data:+ if not isinstance(item, type(first_item)):+ msg = f"Trying to create a Stuff '{name}' from a list of '{type(first_item).__name__}' "+ f"but the items are not of the same type. Especially, items {item} is of type {type(item).__name__}"+ "Every items of the list should be a identical type. If its a string, everything should be a string."+ raise StuffFactoryError(msg)++ # Check if it's a native concept+ if "Content" in content_class_name and NativeConceptCode.is_native_concept(concept_code=content_class_name.split("Content")[0]):+ concept = get_native_concept(native_concept=NativeConceptCode(content_class_name.split("Content")[0]))+ else:+ try:+ concept = concept_library.get_required_concept(concept_string=content_class_name)+ except ConceptLibraryConceptNotFoundError as exc:+ msg = f"Trying to create a Stuff '{name}' from a list of StuffContent but"+ "the concept of name '{content_class_name}' is not found in the library"+ raise StuffFactoryError(msg) from exc++ return cls.make_stuff(+ concept=concept,+ content=ListContent(items=cast("list[StuffContent]", stuff_content_or_data)),+ name=name,+ code=code,+ )++ msg = f"Cannot create Stuff from list of {type(first_item)}"+ raise StuffFactoryError(msg)++ # ==================== CASE 2: Dict with 'concept' AND 'content' keys ====================+ if not isinstance(stuff_content_or_data, dict):+ msg = f"Unexpected type for stuff_content_or_data: {type(stuff_content_or_data)}.Type should be {StuffContentOrData}."+ raise StuffFactoryError(msg)++ # Check if it's a dict with concept and content keys+ if "concept" not in stuff_content_or_data:+ msg = f"Trying to create a Stuff '{name}' from a dict that should represent a StuffContentOrData but does not have a 'concept' key."+ raise StuffFactoryError(msg)++ if "content" not in stuff_content_or_data:+ msg = f"Trying to create a Stuff '{name}' from a dict that should represent a StuffContentOrData but does not have a 'content' key."+ raise StuffFactoryError(msg)++ if len(stuff_content_or_data) != 2:+ msg = (+ f"Trying to create a Stuff '{name}' from a dict that should represent a StuffContentOrData but does not have "+ "exactly keys 'concept' and 'content'."+ )+ raise StuffFactoryError(msg)++ concept_string = stuff_content_or_data["concept"]+ content = stuff_content_or_data["content"]++ # Get the concept from the library+ try:+ concept = concept_library.get_required_concept_from_concept_string_or_code(+ concept_string_or_code=concept_string, search_domains=search_domains+ )+ except ConceptLibraryConceptNotFoundError as exc:+ msg = f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a dict that should represent a StuffContentOrData "+ f"but the concept of name '{concept_string}' is not found in the library"+ raise StuffFactoryError(msg) from exc++ # Case 2.1: content is a string+ if isinstance(content, str):+ # Check if concept is compatible with Text+ text_concept = get_native_concept(native_concept=NativeConceptCode.TEXT)+ if concept_library.is_compatible(tested_concept=concept, wanted_concept=text_concept):return cls.make_stuff(concept=concept,- content=content,+ content=TextContent(text=content),name=name,- code=stuff_code,+ code=code,)- # For non-native StuffContent, we need to define concept_name- concept_name = concept_class_name.split("Content")[0]- try:- return cls.make_stuff_using_concept_name_and_search_domains(- concept_name=concept_name,- search_domains=search_domains,- content=content,- name=name,- code=stuff_code,++ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a dict that should represent a StuffContentOrData "+ f"but the concept of name '{concept_string}' is not compatible with text content"+ )+ raise StuffFactoryError(msg)++ # Case 2.3: content is a StuffContent object+ if isinstance(content, StuffContent):+ if concept.structure_class_name != content.__class__.__name__:+ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a dict that should represent a StuffContentOrData "+ f"but the concept of name '{concept_string}' is not compatible with the content of type {content.__class__.__name__}")- except StuffFactoryError as exc:- msg = f"Could not make stuff for StuffContent '{name}': {exc}"- raise StuffFactoryError(msg) from exc- elif isinstance(stuff_content_or_data, list):- items = stuff_content_or_data- if len(items) == 0:- msg = "List in compact memory has no items"raise StuffFactoryError(msg)- first_item = items[0]- concept_name = type(first_item).__name__- content = ListContent[Any](items=items)- try:- return cls.make_stuff_using_concept_name_and_search_domains(- concept_name=concept_name,- search_domains=search_domains,- content=content,- name=name,- code=stuff_code,++ return cls.make_stuff(+ concept=concept,+ content=content,+ name=name,+ code=code,+ )++ # Case 2.5: content is a dict+ if isinstance(content, dict):+ the_class = get_class_registry().get_class(name=concept.structure_class_name)+ if the_class is None:+ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a dict that should represent a StuffContentOrData "+ f"but the concept of name '{concept_string}' is not compatible with a dict content")- except StuffFactoryError as exc:- msg = f"Could not make stuff for list of StuffContent '{name}': {exc}"- raise StuffFactoryError(msg) from exc- elif isinstance(stuff_content_or_data, str):- str_stuff: str = stuff_content_or_data- return StuffFactory.make_stuff(- concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),- content=TextContent(text=str_stuff),+ raise StuffFactoryError(msg)++ return cls.make_stuff(name=name,+ code=code,+ concept=concept,+ content=the_class.model_validate(obj=content),)- else:- stuff_content_dict: dict[str, Any] = stuff_content_or_data- try:- concept_string = stuff_content_dict.get("concept") or stuff_content_dict.get("concept_code")- if not concept_string:- msg = "Stuff content data dict is badly formed: no concept code"- raise StuffFactoryError(msg)- content_value = stuff_content_dict["content"]- if NativeConceptCode.get_validated_native_concept_string(concept_string_or_code=concept_string):- concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode(concept_string.split(".")[-1]))- content = StuffContentFactory.make_stuff_content_from_concept_with_fallback(- concept=concept,- value=content_value,- )- return StuffFactory.make_stuff(++ # Case 2.2/2.2b/2.4/2.5/2.6: content is a list+ if isinstance(content, list):+ list_content = cast("list[Any]", content)+ if len(list_content) == 0:+ msg = "Cannot create Stuff from empty list in content"+ raise StuffFactoryError(msg)++ first_item = list_content[0]++ # Case 2.2/2.2b: list[str]+ if isinstance(first_item, str):+ for item in list_content:+ if not isinstance(item, str):+ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a list of strings but the item {item} "+ "is not a string. Every items of the list should be a identical type. If its a string, everything should be a string."+ )+ raise StuffFactoryError(msg)++ text_concept = get_native_concept(native_concept=NativeConceptCode.TEXT)+ if concept_library.is_compatible(tested_concept=concept, wanted_concept=text_concept):+ items = [TextContent(text=item) for item in list_content]+ return cls.make_stuff(concept=concept,+ content=ListContent(items=items),name=name,- content=content,- code=stuff_code,+ code=code,)- except KeyError as exc:- msg = f"Stuff content data dict is badly formed: {exc}"- raise StuffFactoryError(msg) from exc- concept_library = get_concept_library()- concept = concept_library.get_required_concept(concept_string=concept_string)+ msg = f"Concept '{concept_string}' is not compatible with list of text content"+ raise StuffFactoryError(msg)++ # Case 2.4: list[StuffContent]+ if isinstance(first_item, StuffContent):+ for item in list_content:+ if not isinstance(item, type(first_item)):+ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a list of StuffContent "+ "but the items are not of the same type. Every items of the list should be a identical type. "+ f"If its a '{type(first_item).__name__}', everything should be a '{type(first_item).__name__}'."+ )+ raise StuffFactoryError(msg)- if isinstance(content_value, StuffContent):- return StuffFactory.make_stuff(+ return cls.make_stuff(concept=concept,+ content=ListContent(items=cast("list[StuffContent]", list_content)),name=name,- content=content_value,- code=stuff_code,+ code=code,)- content = StuffContentFactory.make_stuff_content_from_concept_with_fallback(- concept=concept,- value=content_value,- )- return StuffFactory.make_stuff(- concept=concept,- name=name,- content=content,- code=stuff_code,- )++ # Case 2.6: list[dict]+ if isinstance(first_item, dict):+ for item_dict in list_content:+ if not isinstance(item_dict, dict):+ msg = (+ f"Trying to create a Stuff '{name}' in the inputs of your pipe, from a list of dicts but "+ f"the item {item_dict} is not a dict. Every items of the list should be a identical type. "+ "If its a dict, everything should be a dict."+ )+ raise StuffFactoryError(msg)++ # Create StuffContent objects from dicts+ stuff_items: list[StuffContent] = []+ for item_dict in list_content:+ stuff_content = StuffContentFactory.make_stuff_content_from_concept_with_fallback(+ concept=concept,+ value=item_dict,+ )+ stuff_items.append(stuff_content)++ return cls.make_stuff(+ concept=concept,+ content=ListContent(items=stuff_items),+ name=name,+ code=code,+ )++ msg = f"Cannot create Stuff from list of {type(first_item)} in content"+ raise StuffFactoryError(msg)++ msg = f"Unexpected type for content value: {type(content)}"+ raise StuffFactoryError(msg)class StuffContentFactoryError(PipelexException):diff --git a/pipelex/pipeline/execute.py b/pipelex/pipeline/execute.pyindex ed0d789a7..8e63e6293 100644--- a/pipelex/pipeline/execute.py+++ b/pipelex/pipeline/execute.py@@ -23,7 +23,7 @@ from pipelex.system.environment import get_optional_envasync def execute_pipeline(pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: ImplicitMemory | None = None,+ inputs: ImplicitMemory | None = None,search_domains: list[str] | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,@@ -42,8 +42,8 @@ async def execute_pipeline(The code of the pipe to execute.working_memory:Optional ``WorkingMemory`` instance passed to the pipe.- input_memory:- Optional compact memory to pass to the pipe.+ inputs:+ Optional implicit memory to pass to the pipe.output_name:Name of the output slot to write to.output_multiplicity:@@ -69,13 +69,13 @@ async def execute_pipeline(if pipe.domain not in search_domains:search_domains.insert(0, pipe.domain)- # Can be either working_memory or compact_memory or neither, but not both- if working_memory and input_memory:- msg = f"Cannot pass both working_memory and input_memory to `execute_pipeline` {pipe_code=}"+ # Can be either working_memory or implicit_memory or neither, but not both+ if working_memory and inputs:+ msg = f"Cannot pass both working_memory and inputs to `execute_pipeline` {pipe_code=}"raise PipelineInputError(msg)- if input_memory:+ if inputs:working_memory = WorkingMemoryFactory.make_from_implicit_memory(- implicit_memory=input_memory,+ implicit_memory=inputs,search_domains=search_domains,)diff --git a/pipelex/pipeline/start.py b/pipelex/pipeline/start.pyindex 9ebd0ee15..862c97713 100644--- a/pipelex/pipeline/start.py+++ b/pipelex/pipeline/start.py@@ -1,6 +1,6 @@import asyncio-from pipelex.client.protocol import CompactMemory+from pipelex.client.protocol import ImplicitMemoryfrom pipelex.core.memory.working_memory import WorkingMemoryfrom pipelex.core.memory.working_memory_factory import WorkingMemoryFactoryfrom pipelex.core.pipes.pipe_output import PipeOutput@@ -15,7 +15,7 @@ from pipelex.pipeline.job_metadata import JobMetadataasync def start_pipeline(pipe_code: str,working_memory: WorkingMemory | None = None,- input_memory: CompactMemory | None = None,+ inputs: ImplicitMemory | None = None,output_name: str | None = None,output_multiplicity: PipeOutputMultiplicity | None = None,dynamic_output_concept_code: str | None = None,@@ -34,8 +34,8 @@ async def start_pipeline(The code of the pipe to execute.working_memory:Optional ``WorkingMemory`` instance passed to the pipe.- input_memory:- Optional compact memory to pass to the pipe.+ inputs:+ Optional implicit memory to pass to the pipe.output_name:Name of the output slot to write to.output_multiplicity:@@ -52,12 +52,12 @@ async def start_pipeline(can be awaited to get the pipe output."""- if working_memory and input_memory:- msg = f"Cannot pass both working_memory and input_memory to `start_pipeline` {pipe_code=}"+ if working_memory and inputs:+ msg = f"Cannot pass both working_memory and inputs to `start_pipeline` {pipe_code=}"raise StartPipelineError(msg)- if input_memory:- working_memory = WorkingMemoryFactory.make_from_compact_memory(input_memory)+ if inputs:+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=inputs)pipeline = get_pipeline_manager().add_new_pipeline()pipeline_run_id = pipeline.pipeline_run_iddiff --git a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.pyindex 999a06e31..a08b69b06 100644--- a/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py+++ b/tests/e2e/pipelex/pipes/pipe_controller/pipe_sequence/test_pipe_sequence_with_input_memory.py@@ -94,7 +94,7 @@ class TestPipeSequenceWithInputMemory:# Execute the pipeline using input_memorypipe_output = await execute_pipeline(pipe_code="optimize_tweet_sequence",- input_memory={+ inputs={"draft_tweet": {"concept": "tech_tweet.DraftTweet","content": SAMPLE_DRAFT_TWEET,diff --git a/tests/e2e/pipelex/pipes/pipe_operators/test_pipe_llm_vision.py b/tests/e2e/pipelex/pipes/pipe_operators/test_pipe_llm_vision.pyindex 614108a0b..bdd849c44 100644--- a/tests/e2e/pipelex/pipes/pipe_operators/test_pipe_llm_vision.py+++ b/tests/e2e/pipelex/pipes/pipe_operators/test_pipe_llm_vision.py@@ -19,7 +19,7 @@ class TestPipeLLMVision:# Execute the pipeline with an imagepipe_output = await execute_pipeline(pipe_code="describe_image",- input_memory={+ inputs={"image": ImageContent(url=LLMVisionTestCases.PATH_IMG_GANTT_1),},)@@ -52,7 +52,7 @@ class TestPipeLLMVision:# Execute the pipeline with an imagepipe_output = await execute_pipeline(pipe_code=pipe_code,- input_memory={+ inputs={"imageA": ImageContent(url=LLMVisionTestCases.PATH_IMG_GANTT_1),"imageB": ImageContent(url=LLMVisionTestCases.PATH_IMG_JPEG_3),},@@ -66,7 +66,7 @@ class TestPipeLLMVision:# Execute the pipeline with a complex imagepipe_output = await execute_pipeline(pipe_code="vision_analysis",- input_memory={+ inputs={"image": ImageContent(url=LLMVisionTestCases.PATH_IMG_GANTT_1),},)diff --git a/tests/integration/pipelex/client/test_client.py b/tests/integration/pipelex/client/test_client.pyindex 24bd36665..b85f9c22e 100644--- a/tests/integration/pipelex/client/test_client.py+++ b/tests/integration/pipelex/client/test_client.py@@ -3,7 +3,7 @@ from pydantic import BaseModelfrom pipelex import pretty_printfrom pipelex.client.client import PipelexClient-from pipelex.client.protocol import COMPACT_MEMORY_KEY, PipelineState+from pipelex.client.protocol import PipelineStatefrom pipelex.core.concepts.concept_factory import ConceptFactoryfrom pipelex.core.concepts.concept_native import NativeConceptCodefrom pipelex.core.domains.domain import SpecialDomain@@ -116,7 +116,7 @@ class TestPipelexApiClient:assert pipeline_reponse.pipeline_state == PipelineState.COMPLETEDassert pipeline_reponse.pipe_output is not None- working_memory = pipeline_reponse.pipe_output[COMPACT_MEMORY_KEY]+ working_memory = pipeline_reponse.pipe_output["dict_memory"]# Verify question structureassert working_memory["question"] == {diff --git a/tests/integration/pipelex/core/memory/test_working_memory_factory.py b/tests/integration/pipelex/core/memory/test_working_memory_factory.pyindex e83835511..4035e9824 100644--- a/tests/integration/pipelex/core/memory/test_working_memory_factory.py+++ b/tests/integration/pipelex/core/memory/test_working_memory_factory.py@@ -8,19 +8,19 @@ from pipelex.core.stuffs.text_and_images_content import TextAndImagesContentfrom pipelex.core.stuffs.text_content import TextContentif TYPE_CHECKING:- from pipelex.client.protocol import CompactMemory+ from pipelex.client.protocol import ImplicitMemoryclass TestWorkingMemoryFactory:def test_make_from_compact_memory_with_text_content(self):- compact_memory: CompactMemory = {+ implicit_memory: ImplicitMemory = {"text_item": {"concept_code": NativeConceptCode.TEXT,"content": "Hello, world!",},}- working_memory = WorkingMemoryFactory.make_from_compact_memory(compact_memory)+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)assert working_memory is not Noneassert "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."""- compact_memory: CompactMemory = {+ implicit_memory: ImplicitMemory = {"complex_page": {"concept_code": NativeConceptCode.PAGE,"content": {@@ -60,7 +60,7 @@ class TestWorkingMemoryFactory:},}- working_memory = WorkingMemoryFactory.make_from_compact_memory(compact_memory)+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)assert working_memory is not Noneassert "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."""- compact_memory: CompactMemory = {}+ implicit_memory: ImplicitMemory = {}- working_memory = WorkingMemoryFactory.make_from_compact_memory(compact_memory)+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)assert working_memory is not Noneassert len(working_memory.root) == 0def test_make_from_compact_memory_multiple_items(self):"""Test deserialization of compact memory with multiple items."""- compact_memory: CompactMemory = {+ implicit_memory: ImplicitMemory = {"text1": {"concept_code": NativeConceptCode.TEXT,"content": "First text",@@ -133,7 +133,7 @@ class TestWorkingMemoryFactory:},}- working_memory = WorkingMemoryFactory.make_from_compact_memory(compact_memory)+ working_memory = WorkingMemoryFactory.make_from_implicit_memory(implicit_memory=implicit_memory)assert working_memory is not Noneassert len(working_memory.root) == 2diff --git a/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py b/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.pynew file mode 100644index 000000000..e4ff3fc16--- /dev/null+++ b/tests/unit/core/stuffs/test_stuff_factory_implicit_memory.py@@ -0,0 +1,462 @@+import os+from typing import Any++import pytest+from pydantic import Field++from pipelex import log+from pipelex.client.protocol import StuffContentOrData+from pipelex.core.concepts.concept_blueprint import ConceptBlueprint+from pipelex.core.concepts.concept_factory import ConceptFactory+from pipelex.core.concepts.concept_native import NativeConceptCode+from pipelex.core.stuffs.list_content import ListContent+from pipelex.core.stuffs.structured_content import StructuredContent+from pipelex.core.stuffs.stuff import Stuff+from pipelex.core.stuffs.stuff_factory import StuffFactory+from pipelex.core.stuffs.text_content import TextContent+from pipelex.hub import get_concept_library+from pipelex.system.registries.class_registry_utils import ClassRegistryUtils+++class MySubClass(StructuredContent):+ arg4: str = Field(description="Test argument 4")+++class MyConcept(StructuredContent):+ arg1: str = Field(description="Test argument 1")+ arg2: int = Field(description="Test argument 2")+ arg3: MySubClass = Field(description="Test argument 3")+++def setup_test_concept():+ # Register the class in the class registry+ ClassRegistryUtils.register_classes_in_file(+ file_path=os.path.join(os.path.dirname(__file__), "test_stuff_factory_implicit_memory.py"),+ base_class=StructuredContent,+ is_include_imported=False,+ )++ # Create and register the test concept+ concept_library = get_concept_library()++ # Create the concept+ concept = ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ )+ # Register it in the library+ concept_library.add_new_concept(concept=concept)++ # Create a concept that is not native.Text but initiable by str+ concept_not_native_text = ConceptFactory.make_from_blueprint(+ domain="test_domain",+ concept_code="MyConceptNotNativeText",+ blueprint=ConceptBlueprint(+ description="Test concept for unit tests",+ ),+ )+ concept_library.add_new_concept(concept=concept_not_native_text)++ yield concept++ # Cleanup after test+ concept_library.remove_concepts_by_codes(concept_codes=["MyConcept", "MyConceptNotNativeText"])+++class TestStuffFactoryImplicitMemory:+ """Test Case 1: Direct content without 'concept' key.++ This covers cases where stuff_content_or_data is directly:+ - A string (1.1)+ - A list of strings (1.2)+ - A StuffContent object (1.3)+ - A list of StuffContent objects (1.4)+ """++ @pytest.mark.parametrize(+ ("test_name", "stuff_content_or_data", "stuff_name", "stuff_code", "expected_stuff"),+ [+ # Case 1.1: Content is a string+ pytest.param(+ "case-1.1-string",+ "Lorem Ipsum",+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),+ content=TextContent(text="Lorem Ipsum"),+ ),+ ),+ # Case 1.2: Content is a list of strings+ pytest.param(+ "case-1.2-list-of-strings",+ ["Lorem Ipsum 1", "Lorem Ipsum 2", "Lorem Ipsum 3"],+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),+ content=ListContent(+ items=[+ TextContent(text="Lorem Ipsum 1"),+ TextContent(text="Lorem Ipsum 2"),+ TextContent(text="Lorem Ipsum 3"),+ ]+ ),+ ),+ ),+ # Case 1.3: Content is a StuffContent object+ pytest.param(+ "case-1.3-stuff-content-object",+ MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ ),+ ),+ # Case 1.4: Content is a list of StuffContent objects+ pytest.param(+ "case-1.4-list-of-stuff-content-objects",+ [+ MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ MyConcept(arg1="arg1_2", arg2=2, arg3=MySubClass(arg4="arg4_2")),+ ],+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=ListContent(+ items=[+ MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ MyConcept(arg1="arg1_2", arg2=2, arg3=MySubClass(arg4="arg4_2")),+ ]+ ),+ ),+ ),+ ],+ )+ def test_case1_direct_content(+ self,+ setup_test_concept: Any,+ test_name: str,+ stuff_content_or_data: StuffContentOrData,+ stuff_name: str,+ stuff_code: str,+ expected_stuff: Stuff,+ ):+ log.info(f"Test Case 1: Direct content without concept key. {test_name}")+ log.debug(f"setup_test_concept: {setup_test_concept}")+ result = StuffFactory.make_stuff_from_stuff_content_or_data(+ name=stuff_name,+ code=stuff_code,+ stuff_content_or_data=stuff_content_or_data,+ )+ assert result == expected_stuff++ @pytest.mark.parametrize(+ ("test_name", "stuff_content_or_data", "stuff_name", "stuff_code", "expected_stuff"),+ [+ # Case 2.1: Content is a string+ pytest.param(+ "case-2.1-dict-with-string-content",+ {"concept": "Text", "content": "my text"},+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),+ content=TextContent(text="my text"),+ ),+ ),+ # Case 2.1b: Content is a string with native prefix+ pytest.param(+ "case-2.1b-dict-with-string-content-native-prefix",+ {"concept": "native.Text", "content": "my text"},+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),+ content=TextContent(text="my text"),+ ),+ ),+ # case 2.1c: Content is a string but the concept is not native.Text, but a concept initiable by str+ pytest.param(+ "case-2.1c-dict-with-string-content-not-native-text",+ {"concept": "test_domain.MyConceptNotNativeText", "content": "my text"},+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make_from_blueprint(+ domain="test_domain",+ concept_code="MyConceptNotNativeText",+ blueprint=ConceptBlueprint(+ description="Test concept for unit tests",+ ),+ ),+ content=TextContent(text="my text"),+ ),+ ),+ # Case 2.2: Content is a list of strings+ pytest.param(+ "case-2.2-dict-with-list-of-strings",+ {"concept": "Text", "content": ["text1", "text2", "text3"]},+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT),+ content=ListContent(+ items=[+ TextContent(text="text1"),+ TextContent(text="text2"),+ TextContent(text="text3"),+ ]+ ),+ ),+ ),+ # case 2.2b: Content is a list of strings but the concept is not native.Text, but a concept initiable by str+ pytest.param(+ "case-2.2b-dict-with-list-of-strings-not-native-text",+ {"concept": "test_domain.MyConceptNotNativeText", "content": ["text1", "text2", "text3"]},+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make_from_blueprint(+ domain="test_domain",+ concept_code="MyConceptNotNativeText",+ blueprint=ConceptBlueprint(+ description="Test concept for unit tests",+ ),+ ),+ content=ListContent(+ items=[+ TextContent(text="text1"),+ TextContent(text="text2"),+ TextContent(text="text3"),+ ]+ ),+ ),+ ),+ # Case 2.3: Content is a StuffContent object+ pytest.param(+ "case-2.3-dict-with-stuff-content-object",+ {+ "concept": "test_domain.MyConcept",+ "content": MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ },+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ ),+ ),+ # Case 2.4: Content is a list of StuffContent objects+ pytest.param(+ "case-2.4-dict-with-list-of-stuff-content-objects",+ {+ "concept": "test_domain.MyConcept",+ "content": [+ MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ MyConcept(arg1="arg1_2", arg2=2, arg3=MySubClass(arg4="arg4_2")),+ ],+ },+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=ListContent(+ items=[+ MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+ MyConcept(arg1="arg1_2", arg2=2, arg3=MySubClass(arg4="arg4_2")),+ ]+ ),+ ),+ ),+ # Case 2.5: Content is a dict+ pytest.param(+ "case-2.5-dict-with-dict-content",+ {+ "concept": "test_domain.MyConcept",+ "content": {+ "arg1": "something",+ "arg2": 1,+ "arg3": {"arg4": "something else else"},+ },+ },+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_code="stuff_code",+ stuff_name="stuff_name",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=MyConcept(arg1="something", arg2=1, arg3=MySubClass(arg4="something else else")),+ ),+ ),+ # Case 2.6: Content is a list of dicts+ pytest.param(+ "case-2.6-dict-with-list-of-dicts",+ {+ "concept": "test_domain.MyConcept",+ "content": [+ {+ "arg1": "something",+ "arg2": 1,+ "arg3": {"arg4": "something else else"},+ },+ {+ "arg1": "something else",+ "arg2": 2,+ "arg3": {"arg4": "something else else else"},+ },+ ],+ },+ "stuff_name",+ "stuff_code",+ Stuff(+ stuff_name="stuff_name",+ stuff_code="stuff_code",+ concept=ConceptFactory.make(+ concept_code="MyConcept",+ domain="test_domain",+ description="Test concept for unit tests",+ structure_class_name="MyConcept",+ ),+ content=ListContent(+ items=[+ MyConcept(arg1="something", arg2=1, arg3=MySubClass(arg4="something else else")),+ MyConcept(arg1="something else", arg2=2, arg3=MySubClass(arg4="something else else else")),+ ]+ ),+ ),+ ),+ ],+ )+ def test_case2_dict_with_concept_and_content(+ self,+ setup_test_concept: Any,+ test_name: str,+ stuff_content_or_data: StuffContentOrData,+ stuff_name: str,+ stuff_code: str,+ expected_stuff: Stuff,+ ):+ """Test Case 2: Dict with concept and content keys."""+ log.info(f"Test Case 2: Dict with concept and content keys. {test_name}")+ log.debug(f"setup_test_concept: {setup_test_concept}")+ result = StuffFactory.make_stuff_from_stuff_content_or_data(+ name=stuff_name,+ code=stuff_code,+ stuff_content_or_data=stuff_content_or_data,+ )+ assert result == expected_stuff+++# class TestStuffFactoryImplicitMemoryEdgeCases:+# """Test edge cases and error conditions."""++# def test_empty_list_raises_error(self):+# """Test that empty list raises appropriate error."""+# with pytest.raises(Exception) as exc_info:+# StuffFactory.make_stuff_from_stuff_content_using_search_domains(+# name="test_stuff",+# stuff_content_or_data=[],+# search_domains=["test_domain"],+# )+# assert "no items" in str(exc_info.value).lower()++# def test_dict_without_concept_raises_error(self):+# """Test that dict without concept key raises appropriate error."""+# with pytest.raises(Exception) as exc_info:+# StuffFactory.make_stuff_from_stuff_content_using_search_domains(+# name="test_stuff",+# stuff_content_or_data={"content": "some content"},+# search_domains=["test_domain"],+# )+# assert "concept" in str(exc_info.value).lower()++# def test_dict_without_content_raises_error(self):+# """Test that dict without content key raises appropriate error."""+# with pytest.raises(Exception) as exc_info:+# StuffFactory.make_stuff_from_stuff_content_using_search_domains(+# name="test_stuff",+# stuff_content_or_data={"concept": "Text"},+# search_domains=["test_domain"],+# )+# assert "content" in str(exc_info.value).lower()++# def test_concept_not_found_raises_error(self, setup_test_concept):+# """Test that non-existent concept raises appropriate error."""+# with pytest.raises(Exception) as exc_info:+# StuffFactory.make_stuff_from_stuff_content_using_search_domains(+# name="test_stuff",+# stuff_content_or_data={+# "concept": "NonExistentConcept",+# "content": {"some": "data"},+# },+# search_domains=["test_domain"],+# )+# # Should raise error about concept not found++# def test_list_with_mixed_types_raises_error(self, setup_test_concept):+# """Test that list with mixed StuffContent types raises error."""+# # This should ideally raise an error or at least log a warning+# # The current implementation might not catch this, but it should+# with pytest.raises(Exception):+# StuffFactory.make_stuff_from_stuff_content_using_search_domains(+# name="test_stuff",+# stuff_content_or_data=[+# MyConcept(arg1="arg1", arg2=1, arg3=MySubClass(arg4="arg4")),+# TextContent(text="different type"), # Different type!+# ],+# search_domains=["test_domain"],+# )diff --git a/tests/unit/pipelex/client/test_api_serialization.py b/tests/unit/pipelex/client/test_api_serialization.pyindex aa944220d..154bb5c5f 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):- compact_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)+ implicit_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)# Should have one entry for the datetime content- assert len(compact_memory) == 1- assert "project_meeting" in compact_memory+ assert len(implicit_memory) == 1+ assert "project_meeting" in implicit_memory# Check the dict structure- datetime_blueprint = compact_memory["project_meeting"]+ datetime_blueprint = implicit_memory["project_meeting"]assert isinstance(datetime_blueprint, dict)assert datetime_blueprint["concept_code"] == "DateTimeEvent"@@ -122,14 +122,14 @@ class TestApiSerialization:assert "__class__" not in contentdef test_api_serialized_memory_is_json_serializable(self, datetime_content_memory: WorkingMemory):- compact_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)+ implicit_memory = ApiSerializer.serialize_working_memory_for_api(datetime_content_memory)# This should NOT raise an exception now- json_string = json.dumps(compact_memory)+ json_string = json.dumps(implicit_memory)roundtrip = json.loads(json_string)# Verify roundtrip works- assert roundtrip == compact_memory+ assert roundtrip == implicit_memory# Verify datetime fields are stringscontent = roundtrip["project_meeting"]["content"]@@ -138,23 +138,23 @@ class TestApiSerialization:assert isinstance(content["created_at"], str)def test_serialize_text_content(self, text_content_memory: WorkingMemory):- compact_memory = ApiSerializer.serialize_working_memory_for_api(text_content_memory)+ implicit_memory = ApiSerializer.serialize_working_memory_for_api(text_content_memory)- assert len(compact_memory) == 1- assert "sample_text" in compact_memory+ assert len(implicit_memory) == 1+ assert "sample_text" in implicit_memory- text_blueprint = compact_memory["sample_text"]+ text_blueprint = implicit_memory["sample_text"]assert text_blueprint["concept_code"] == NativeConceptCode.TEXTassert isinstance(text_blueprint["content"], str)assert text_blueprint["content"] == "Sample text content"def test_serialize_number_content(self, number_content_memory: WorkingMemory):- compact_memory = ApiSerializer.serialize_working_memory_for_api(number_content_memory)+ implicit_memory = ApiSerializer.serialize_working_memory_for_api(number_content_memory)- assert len(compact_memory) == 1- assert "pi_value" in compact_memory+ assert len(implicit_memory) == 1+ assert "pi_value" in implicit_memory- number_blueprint = compact_memory["pi_value"]+ number_blueprint = implicit_memory["pi_value"]assert number_blueprint["concept_code"] == NativeConceptCode.NUMBERassert isinstance(number_blueprint["content"], dict)assert number_blueprint["content"]["number"] == 3.14159diff --git a/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py b/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.pyindex fd18cc96e..e007b5ed4 100644--- a/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py+++ b/tests/unit/pipelex/core/stuffs/test_stuff_factory_make_stuff_from_content.py@@ -58,11 +58,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mock_make = mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=list_content,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -76,8 +76,8 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:def test_listcontent_with_empty_items_raises_error(self):"""Test ListContent with empty items raises StuffFactoryError."""- with pytest.raises(StuffFactoryError, match="ListContent in compact memory has no items"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ with pytest.raises(StuffFactoryError, match="Cannot create Stuff 'test_stuff' from empty list"):+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.EMPTY_LIST_CONTENT,search_domains=TestData.SEARCH_DOMAINS,@@ -91,7 +91,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", side_effect=original_error)with pytest.raises(StuffFactoryError, match="Could not make stuff for ListContent 'test_stuff': Original error"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=list_content,search_domains=TestData.SEARCH_DOMAINS,@@ -107,11 +107,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=text_content,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -124,7 +124,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mock_make = mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=custom_content,search_domains=TestData.SEARCH_DOMAINS,@@ -146,11 +146,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mock_make = mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=test_list,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -163,7 +163,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:def test_list_with_empty_items_raises_error(self):"""Test plain list with empty items raises StuffFactoryError."""with pytest.raises(StuffFactoryError, match="List in compact memory has no items"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=[],search_domains=TestData.SEARCH_DOMAINS,@@ -177,7 +177,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", side_effect=original_error)with pytest.raises(StuffFactoryError, match="Could not make stuff for list of StuffContent 'test_stuff': Original error"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=test_list,search_domains=TestData.SEARCH_DOMAINS,@@ -192,7 +192,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.TEXT_STRING,search_domains=TestData.SEARCH_DOMAINS,@@ -220,11 +220,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.NATIVE_TEXT_DICT,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -244,11 +244,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=test_dict,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -268,11 +268,11 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.CUSTOM_CONCEPT_DICT,search_domains=TestData.SEARCH_DOMAINS,- stuff_code=TestData.STUFF_CODE,+ code=TestData.STUFF_CODE,)assert result == mock_stuff@@ -296,7 +296,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.CUSTOM_CONCEPT_CODE_DICT,search_domains=TestData.SEARCH_DOMAINS,@@ -307,7 +307,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:def test_dict_missing_concept_raises_error(self):"""Test dictionary missing concept field raises StuffFactoryError."""with pytest.raises(StuffFactoryError, match="Stuff content data dict is badly formed: no concept code"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.MISSING_CONCEPT_DICT,search_domains=TestData.SEARCH_DOMAINS,@@ -316,7 +316,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:def test_dict_missing_content_raises_error(self):"""Test dictionary missing content field raises StuffFactoryError."""with pytest.raises(StuffFactoryError, match="Stuff content data dict is badly formed: 'content'"):- StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.MISSING_CONTENT_DICT,search_domains=TestData.SEARCH_DOMAINS,@@ -331,7 +331,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mocker.patch.object(StuffFactory, "make_stuff", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=TestData.TEXT_STRING,search_domains=TestData.SEARCH_DOMAINS,@@ -346,7 +346,7 @@ class TestMakeStuffFromStuffContentUsingSearchDomains:mock_stuff = mocker.Mock(spec=Stuff)mock_make = mocker.patch.object(StuffFactory, "make_stuff_using_concept_name_and_search_domains", return_value=mock_stuff)- result = StuffFactory.make_stuff_from_stuff_content_using_search_domains(+ result = StuffFactory.make_stuff_from_stuff_content_or_data(name=TestData.STUFF_NAME,stuff_content_or_data=list_content,search_domains=[],