Skip to content

Commit

Permalink
Merge pull request #1112 from dimagi/cs/passthrough_nodes
Browse files Browse the repository at this point in the history
Make ExtractParticipantData node passthrough
  • Loading branch information
SmittieC authored Jan 31, 2025
2 parents d81dbd8 + c0b77a7 commit 324c647
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/pipelines/nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def _process(self, input, state: PipelineState, node_id: str, **kwargs) -> Pipel
new_reference_data = self.update_reference_data(output, reference_data)

self.post_extraction_hook(new_reference_data, state)
output = json.dumps(new_reference_data)
output = input if self.is_passthrough else json.dumps(new_reference_data)
return PipelineState.from_node_output(node_name=self.name, node_id=node_id, output=output)

def post_extraction_hook(self, output, state):
Expand Down Expand Up @@ -598,6 +598,10 @@ class ExtractStructuredData(ExtractStructuredDataNodeMixin, LLMResponse, Structu
json_schema_extra=UiSchema(widget=Widgets.expandable_text),
)

@property
def is_passthrough(self) -> bool:
return False


class ExtractParticipantData(ExtractStructuredDataNodeMixin, LLMResponse, StructuredDataSchemaValidatorMixin):
"""Extract structured data and saves it as participant data"""
Expand All @@ -616,6 +620,10 @@ class ExtractParticipantData(ExtractStructuredDataNodeMixin, LLMResponse, Struct
)
key_name: str = ""

@property
def is_passthrough(self) -> bool:
return True

def get_reference_data(self, state) -> dict:
"""Returns the participant data as reference. If there is a `key_name`, the value in the participant data
corresponding to that key will be returned insteadg
Expand Down

0 comments on commit 324c647

Please sign in to comment.