Skip to content

Commit 0d8e854

Browse files
author
Allaoua Benchikh
committed
Updated datalayers
1 parent d5324a1 commit 0d8e854

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

backend/chainlit/data/chainlit_data_layer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ async def create_step(self, step_dict: StepDict):
338338
query = """
339339
INSERT INTO "Step" (
340340
id, "threadId", "parentId", input, metadata, name, output,
341-
type, "startTime", "endTime", "showInput", "isError"
341+
type, "startTime", "endTime", "showInput", "isError", icon
342342
) VALUES (
343-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
343+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13
344344
)
345345
ON CONFLICT (id) DO UPDATE SET
346346
"parentId" = COALESCE(EXCLUDED."parentId", "Step"."parentId"),
@@ -359,7 +359,8 @@ async def create_step(self, step_dict: StepDict):
359359
"endTime" = COALESCE(EXCLUDED."endTime", "Step"."endTime"),
360360
"startTime" = LEAST(EXCLUDED."startTime", "Step"."startTime"),
361361
"showInput" = COALESCE(EXCLUDED."showInput", "Step"."showInput"),
362-
"isError" = COALESCE(EXCLUDED."isError", "Step"."isError")
362+
"isError" = COALESCE(EXCLUDED."isError", "Step"."isError"),
363+
icon = COALESCE(EXCLUDED.icon, "Step".icon)
363364
"""
364365

365366
timestamp = await self.get_current_timestamp()
@@ -380,6 +381,7 @@ async def create_step(self, step_dict: StepDict):
380381
"end_time": timestamp,
381382
"show_input": str(step_dict.get("showInput", "json")),
382383
"is_error": step_dict.get("isError", False),
384+
"icon": step_dict.get("icon"),
383385
}
384386
await self.execute_query(query, params)
385387

backend/chainlit/data/literalai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ async def create_step(self, step_dict: "StepDict"):
367367
waitForAnswer=step_dict.get("waitForAnswer"),
368368
language=step_dict.get("language"),
369369
showInput=step_dict.get("showInput"),
370+
icon=step_dict.get("icon"),
370371
)
371372

372373
step: LiteralStepDict = {

backend/chainlit/data/sql_alchemy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ async def create_step(self, step_dict: "StepDict"):
376376
if "showInput" in step_dict
377377
else None
378378
)
379+
# Note: This automatically includes all fields from StepDict including 'icon'
380+
# The dynamic column/value generation below will handle any new fields
379381
parameters = {
380382
key: value
381383
for key, value in step_dict.items()

backend/tests/data/test_literalai.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def test_step_dict(test_thread) -> StepDict:
8383
"waitForAnswer": True,
8484
"showInput": True,
8585
"language": "en",
86+
"icon": "search",
8687
}
8788

8889

@@ -179,6 +180,7 @@ async def test_create_step(
179180
"waitForAnswer": True,
180181
"language": "en",
181182
"showInput": True,
183+
"icon": "search",
182184
},
183185
"input": {"content": "test input"},
184186
"output": {"content": "test output"},
@@ -768,6 +770,7 @@ async def test_update_step(
768770
"waitForAnswer": True,
769771
"language": "en",
770772
"showInput": True,
773+
"icon": "search",
771774
},
772775
"input": {"content": "test input"},
773776
"output": {"content": "test output"},

backend/tests/data/test_sql_alchemy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ async def data_layer(mock_storage_client: BaseStorageClient, tmp_path: Path):
7575
"generation" JSONB,
7676
"showInput" TEXT,
7777
"language" TEXT,
78+
"icon" TEXT,
7879
"indent" INT
7980
);
8081
"""

0 commit comments

Comments
 (0)