Skip to content

Commit 7289b1c

Browse files
Alfio GliozzoCristhianzl
authored andcommitted
Fix agentics components: add areduce_batch_size and atype parameters
- Add areduce_batch_size=100 to SemanticAggregator to prevent overwhelming LLM - Add atype parameter to AG initialization in SyntheticDataGenerator - Add null check for output_states in SyntheticDataGenerator - Return empty DataFrame if no output_states generated Co-authored-by: Alfio Gliozzo <gliozzo@us.ibm.com>
1 parent 60f39c1 commit 7289b1c

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

src/lfx/src/lfx/components/agentics/agenerate_component.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from lfx.schema.dataframe import DataFrame
1919

2020

21-
class AgenerateComponent(BaseAgenticComponent):
21+
class SyntheticDataGenerator(BaseAgenticComponent):
2222
"""Generate synthetic data using either example data or a defined schema.
2323
2424
This component creates realistic synthetic data by either:
@@ -69,10 +69,6 @@ class AgenerateComponent(BaseAgenticComponent):
6969
IntInput(
7070
name="batch_size",
7171
display_name="Number of Rows to Generate",
72-
info=(
73-
"Number of new synthetic rows to generate. When an Input Table is provided, "
74-
"the generated rows are appended to the original data."
75-
),
7672
value=10,
7773
advanced=False,
7874
),
@@ -106,12 +102,12 @@ async def aGenerate(self) -> DataFrame: # noqa: N802
106102
if self.source:
107103
source = AG.from_dataframe(DataFrame(self.source))
108104
atype = source.atype
109-
instructions = str(self.instructions) if self.instructions else "Generate similar data based on the examples provided."
110-
instructions += "\nHere are examples to take inspiration from:\n" + str(source.states[:50])
105+
instructions = str(self.instructions)
106+
instructions += "\nHere are examples to take inspiration from" + str(source.states[:50])
111107
elif self.schema != []:
112108
schema_fields = build_schema_fields(self.schema)
113109
atype = create_pydantic_model(schema_fields, name="GeneratedData")
114-
instructions = str(self.instructions) if self.instructions else "Generate realistic synthetic data following the provided schema."
110+
instructions = str(self.instructions)
115111
else:
116112
msg = "Synthetic data generation requires either a sample DataFrame or schema definition (but not both)."
117113
raise ValueError(msg)
@@ -122,14 +118,9 @@ async def aGenerate(self) -> DataFrame: # noqa: N802
122118
llm=llm,
123119
instructions=instructions,
124120
)
125-
# Ensure output_states is a list, not None
126-
if output_states is None:
127-
output_states = []
128-
129-
if self.source:
130-
output_states = source.states + output_states
131-
132-
output = AG(atype=atype, states=output_states)
133-
134-
return DataFrame(output.to_dataframe().to_dict(orient="records"))
135-
121+
if output_states:
122+
if self.source:
123+
output_states = source.states + output_states
124+
output = AG(atype=atype, states=output_states)
125+
return DataFrame(output.to_dataframe().to_dict(orient="records"))
126+
return DataFrame([])

src/lfx/src/lfx/components/agentics/areduce_component.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ async def aReduce(self) -> DataFrame: # noqa: N802
113113
else "\nGenerate a list of instances of the target type following those instructions : ."
114114
+ self.instructions,
115115
llm=llm,
116+
areduce_batch_size=100,
116117
)
117118

118119
output = await (target << source)

0 commit comments

Comments
 (0)