11from typing import Any , Dict , Optional
22
33from pipelex .client .api_serializer import ApiSerializer
4- from pipelex .client .protocol import COMPACT_MEMORY_KEY , CompactMemory , PipelineRequest
4+ from pipelex .client .protocol import COMPACT_MEMORY_KEY , PipelineRequest
55from pipelex .core .pipe_run_params import PipeOutputMultiplicity
6- from pipelex .core .stuff_factory import StuffFactory
76from pipelex .core .working_memory import WorkingMemory
8- from pipelex .core .working_memory_factory import WorkingMemoryFactory
97
108
119class PipelineRequestFactory :
@@ -30,48 +28,16 @@ def make_from_working_memory(
3028 Returns:
3129 PipelineRequest with the working memory serialized to reduced format
3230 """
33- compact_memory = None
34- if working_memory is not None :
35- compact_memory = ApiSerializer .serialize_working_memory_for_api (working_memory )
3631
3732 return PipelineRequest (
38- compact_memory = compact_memory ,
33+ input_memory = ApiSerializer . serialize_working_memory_for_api ( working_memory ) ,
3934 output_name = output_name ,
4035 output_multiplicity = output_multiplicity ,
4136 dynamic_output_concept_code = dynamic_output_concept_code ,
4237 )
4338
4439 @staticmethod
45- def make_working_memory_from_reduced (compact_memory : Optional [CompactMemory ]) -> WorkingMemory :
46- """
47- Create a WorkingMemory from a reduced memory dictionary.
48-
49- Args:
50- compact_memory: Dictionary in the format from API
51-
52- Returns:
53- WorkingMemory object reconstructed from the reduced format
54- """
55- working_memory = WorkingMemoryFactory .make_empty ()
56- if compact_memory is None :
57- return working_memory
58-
59- for stuff_key , stuff_data in compact_memory .items ():
60- concept_code = stuff_data .get ("concept_code" , "" )
61- content_value = stuff_data .get ("content" , {})
62-
63- # Use API serializer to create content
64- content = ApiSerializer .make_stuff_content_from_api_data (concept_code = concept_code , value = content_value )
65-
66- # Create stuff directly
67- stuff = StuffFactory .make_stuff (concept_str = concept_code , name = stuff_key , content = content )
68-
69- working_memory .add_new_stuff (name = stuff_key , stuff = stuff )
70-
71- return working_memory
72-
73- @staticmethod
74- def make_request_from_body (request_body : Dict [str , Any ]) -> PipelineRequest :
40+ def make_from_body (request_body : Dict [str , Any ]) -> PipelineRequest :
7541 """
7642 Create a PipelineRequest from raw request body dictionary.
7743
@@ -82,7 +48,7 @@ def make_request_from_body(request_body: Dict[str, Any]) -> PipelineRequest:
8248 PipelineRequest object with dictionary working_memory
8349 """
8450 return PipelineRequest (
85- compact_memory = request_body .get (COMPACT_MEMORY_KEY ),
51+ input_memory = request_body .get (COMPACT_MEMORY_KEY ),
8652 output_name = request_body .get ("output_name" ),
8753 output_multiplicity = request_body .get ("output_multiplicity" ),
8854 dynamic_output_concept_code = request_body .get ("dynamic_output_concept_code" ),
0 commit comments