Skip to content

Commit

Permalink
chore(wren-ai-service): support deleting sql pairs using project id (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyeh authored Feb 17, 2025
1 parent 03d3579 commit 947e8c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wren-ai-service/src/pipelines/indexing/sql_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ async def clean(
sql_pairs: List[SqlPair],
embedding: Dict[str, Any],
project_id: Optional[str] = "",
delete_all: bool = False,
) -> Dict[str, Any]:
sql_pair_ids = [sql_pair.id for sql_pair in sql_pairs]
if sql_pair_ids:
if sql_pair_ids or delete_all:
await cleaner.run(sql_pair_ids=sql_pair_ids, project_id=project_id)

return embedding
Expand Down Expand Up @@ -216,12 +217,14 @@ async def clean(
self,
sql_pairs: List[SqlPair],
project_id: Optional[str] = None,
delete_all: bool = False,
) -> None:
await clean(
sql_pairs=sql_pairs,
embedding={"documents": []},
cleaner=self._components["cleaner"],
project_id=project_id,
delete_all=delete_all,
)


Expand Down
6 changes: 6 additions & 0 deletions wren-ai-service/src/web/v1/services/semantics_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ async def delete_semantics(self, project_id: str):
tasks = [
self._pipelines[name].clean(project_id=project_id)
for name in ["db_schema", "historical_question", "table_description"]
] + [
self._pipelines["sql_pairs"].clean(
sql_pairs=[],
project_id=project_id,
delete_all=True,
)
]

await asyncio.gather(*tasks)

0 comments on commit 947e8c3

Please sign in to comment.