Skip to content

Commit

Permalink
link filter to component id
Browse files Browse the repository at this point in the history
  • Loading branch information
lingyielia committed Jul 11, 2024
1 parent 62fd67e commit c99c9c2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions vizro-ai/src/vizro_ai/dashboard/nodes/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class Component(BaseModel):
"Keep the original relevant description AS IS. Keep any links as original links.",
)
component_id: str = Field(
pattern=r"^[a-z]+(_[a-z]+)?$", description="Small snake case description of this component"
pattern=r"^[a-z]+(_[a-z]+)?$", description="Small snake case description of this component."
)
page_id: str = Field(
...,
description="The page id where this component will be placed."
)
data_frame: str = Field(
...,
Expand All @@ -58,10 +62,13 @@ def create(self, model, df_metadata) -> Union[ComponentType, None]:

if self.component_type == "Graph":
return vm.Graph(
id=self.component_id+"_"+self.page_id,
figure=vizro_ai.plot(df=df_metadata[self.data_frame]["df"], user_input=self.component_description)
)
elif self.component_type == "AgGrid":
return vm.AgGrid(figure=dash_ag_grid(data_frame=self.data_frame))
return vm.AgGrid(
id=self.component_id+"_"+self.page_id,
figure=dash_ag_grid(data_frame=self.data_frame))
elif self.component_type == "Card":
return _get_proxy_model(
query=self.component_description, llm_model=model, result_model=vm.Card, df_metadata=df_metadata
Expand Down Expand Up @@ -93,9 +100,9 @@ def validate_column(v):
targets=(
List[str],
Field(
[],
description="Target component to be affected by filter. If none are given "
"then target all components on the page that use `column`.",
...,
description="Target component to be affected by filter. "
f"Must be one of {available_components}. ALWAYS REQUIRED.",
),
),
column=(str, Field(..., description="Column name of DataFrame to filter. ALWAYS REQUIRED.")),
Expand Down

0 comments on commit c99c9c2

Please sign in to comment.