-
Notifications
You must be signed in to change notification settings - Fork 128
LLM assisted rules generation #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
aedf6ae
LLM assisted rules generation code
souravg-db2 a081731
added change for tests
souravg-db2 985d80c
Addressed fmt issues
souravg-db2 40d0b6c
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 353222c
refactor
mwojtyczka c2ee51e
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka e7b94ce
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 4fddaef
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 0e37f34
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 015bff3
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 82cfcff
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka cdf231c
added few changes
souravg-db2 032a18c
Removed removed which was not needed
souravg-db2 34d9782
Merge branch 'main' into feature_370_llm_prompt_prep_3
souravg-db2 ed42bc9
Added changes to call llm rules generation from generator
souravg-db2 4993453
Add schema inference for no-schema provided DQ rule generation
vb-dbrks a4d73e6
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 0602e16
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka ab89982
Addressed some review comments
souravg-db2 cea51d7
Changes per review comments
souravg-db2 17482be
Changes per review comments
souravg-db2 14cad77
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 5edde34
updated clean up of lakebase instances
mwojtyczka 4377f05
updated clean up of lakebase instances
mwojtyczka 834c0b6
refactor
mwojtyczka d555fe4
revert change
mwojtyczka 1a2591f
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 894c7b5
added documentation and updated default model
souravg-db2 85d1089
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka 9794464
Merge branch 'main' into feature_370_llm_prompt_prep_3
mwojtyczka f4aa2c2
refactor
mwojtyczka 8cea7cc
test
mwojtyczka 772ca69
refactor
mwojtyczka 35eba0c
added sql query and schema validation examples
mwojtyczka 7988b08
added comments
mwojtyczka d7e06ab
added unit and integration tests
mwojtyczka a5256cf
added llm assisted rule generation to profiler workflow
mwojtyczka a828231
refactor
mwojtyczka e6c9902
changed test catalog
mwojtyczka 6fe4a7b
added demo notebook fo ai assisted feature
souravg-db2 0dded6f
removed extra cells
souravg-db2 d214aee
updated ai demo
mwojtyczka bb1d63e
updated ai demo
mwojtyczka 576010c
updated ai demo
mwojtyczka 17f9b48
Fixed the pip install
souravg-db2 e00c4e4
added integration tests, load api keys in workflows from secrets
mwojtyczka 0e53c6c
updated docs and fixed logger
mwojtyczka f88bd06
copilot code review implementation
mwojtyczka 86feb5c
copilot code review implementation
mwojtyczka d1f84d0
updated telemetry
mwojtyczka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Databricks notebook source | ||
| # MAGIC %md | ||
| # MAGIC # DQX - AI Assisted Checks Generation Demo | ||
| # MAGIC | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # MAGIC %md | ||
| # MAGIC # Install DQX with LLM extras | ||
| # MAGIC | ||
| # MAGIC To use DQX AI Assisted features, DQX has to be installed with `llm` extras: | ||
| # MAGIC | ||
| # MAGIC `%pip install databricks-labs-dqx[llm]` | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| dbutils.widgets.text("test_library_ref", "", "Test Library Ref") | ||
|
|
||
| if dbutils.widgets.get("test_library_ref") != "": | ||
| %pip install 'databricks-labs-dqx[llm] @ {dbutils.widgets.get("test_library_ref")}' | ||
| else: | ||
| %pip install databricks-labs-dqx[llm] | ||
|
|
||
| %restart_python | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| model_name = "databricks/databricks-claude-sonnet-4-5" | ||
| default_user_input = "customername should not start with s and account balance should be positive" | ||
| default_table_name = "samples.tpch.customer" | ||
|
|
||
| dbutils.widgets.text("model_name", model_name, "Model Name") | ||
| dbutils.widgets.text("user_requirement", default_user_input, "User Requirement") | ||
| dbutils.widgets.text("table_name", default_table_name, "Table Name") | ||
|
|
||
| model_name = dbutils.widgets.get("model_name") | ||
| user_requirement = dbutils.widgets.get("user_requirement") | ||
| table_name = dbutils.widgets.get("table_name") | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| import os, yaml | ||
| from databricks.labs.dqx.profiler.generator import DQGenerator | ||
| from databricks.labs.dqx.config import LLMModelConfig | ||
| from databricks.labs.dqx.engine import DQEngine | ||
| from databricks.sdk import WorkspaceClient | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # Instantiate DQX engine | ||
| ws = WorkspaceClient() | ||
| dq_engine = DQEngine(ws, spark) | ||
|
|
||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # MAGIC %md | ||
| # MAGIC ## Generating DQX Rules with AI Assistance | ||
| # MAGIC | ||
| # MAGIC DQX supports AI-assisted rule generation based on user requirements. The following configurations are available: | ||
| # MAGIC | ||
| # MAGIC - **Model Serving Endpoint**: | ||
| # MAGIC By default, DQX uses the `databricks/databricks-claude-sonnet-4-5` model serving endpoint to generate rules. However, users can specify a different model endpoint if they prefer to use another one. | ||
| # MAGIC | ||
| # MAGIC - **Table Name**: | ||
| # MAGIC Users can optionally provide the fully qualified name of a table. DQX will use the table's schema to generate rules. If no table name is provided, the schema will be inferred based on the user's input. | ||
| # MAGIC | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # Creating model config with optional model name (default Databricks Foundational model endpoint is used if not provided) | ||
| llm_model_config = LLMModelConfig(model_name=model_name) | ||
| generator = DQGenerator(ws, llm_model_config=llm_model_config) | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # MAGIC %md | ||
| # MAGIC ### Generate DQ rules using AI-Assisted approach using user requirement | ||
| # MAGIC | ||
| # MAGIC Schema of the data will be guessed. | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| checks = generator.generate_dq_rules_ai_assisted(user_input=user_requirement) | ||
| print("======== Generated checks =========") | ||
| print(checks) | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| # MAGIC %md | ||
| # MAGIC ### Generate DQ rules using AI-Assisted approach using user requirement and user specified table name | ||
| # MAGIC | ||
| # MAGIC Schema will be fetched from the table specified by the user. | ||
| # MAGIC | ||
|
|
||
| # COMMAND ---------- | ||
|
|
||
| checks = generator.generate_dq_rules_ai_assisted(user_input=user_requirement, table_name=table_name) | ||
| print("======== Generated checks =========") | ||
| print(checks) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| --- | ||
| sidebar_position: 9 | ||
| sidebar_position: 10 | ||
| --- | ||
|
|
||
| import Admonition from '@theme/Admonition'; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.