This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
We’re excited to announce that native support for evaluating Data Agents through the Fabric SDK is now available in Preview. You can now run structured evaluations of your agent’s responses using Python — directly from notebooks or your own automation pipelines.
Whether you're validating accuracy before deploying to production, tuning prompts for better performance, or benchmarking improvements over time, the new APIs in the Fabric Data Agents SDK will help you test and iterate with confidence.
This blog post will walk you through how to:
Before running evaluations with the SDK, ensure you have a Lakehouse set up and populated with sample data. We recommend using the AdventureWorks dataset for testing purposes. You can follow the official Microsoft Fabric guide to create a Lakehouse and load the required tables. This step is essential to ensure your Data Agent has access to a structured schema for answering questions.
For setup instructions, refer to: Create a Lakehouse with AdventureWorksLH
To evaluate agents programmatically, first install the fabric-data-agent-sdk in your notebook:
%pip install -U fabric-data-agent-sdk
Use the SDK to create a new agent or connect to an existing one:
from fabric.dataagent.client import create_data_agentdata_agent_name = "ProductSalesDataAgent" data_agent = create_data_agent(data_agent_name)
Once your agent is created, add the Lakehouse as a data source and select the relevant tables:
# Add Lakehouse (optional, if not already added)
data_agent.add_datasource("AdventureWorksLH", type="lakehouse")
datasource = data_agent.get_datasources()[0]
# Select tables from dbo schema
tables = [
"dimcustomer", "dimdate", "dimgeography", "dimproduct",
"dimproductcategory", "dimpromotion", "dimreseller",
"dimsalesterritory", "factinternetsales", "factresellersales"
]
for table in tables:
datasource.select("dbo", table)
# Publish the data agent
data_agent.publish()
Create a set of questions with the correct (expected) answers to evaluate how well your agent performs:
import pandas as pddf = pd.DataFrame(columns=["question", "expected_answer"], data=[ ["What were our total sales in 2014?", "45,694.7"], ["What is the most sold product?", "Mountain-200 Black, 42"], ["What are the most expensive items that have never been sold?", "Road-450 Red, 60"] ])
Call evaluate_data_agent() to run the test set against the agent. You can also specify where to store the output tables and what stage of the agent to test (e.g., sandbox😞
from fabric.dataagent.evaluation import evaluate_data_agenttable_name = "demo_evaluation_output" evaluation_id = evaluate_data_agent( df, data_agent_name, table_name=table_name, data_agent_stage="sandbox" )
print(f"Evaluation ID: {evaluation_id}")
Want more control over how correctness is judged? Pass in your own critic_prompt with {query}, {expected_answer}, and {actual_answer} placeholders:
critic_prompt = """ Given the following query, expected answer, and actual answer, please determine if the actual answer is equivalent to expected answer. If they are equivalent, respond with 'yes'.Query: {query}
Expected Answer: {expected_answer}
Actual Answer: {actual_answer}
Is the actual answer equivalent to the expected answer? """
evaluation_id = evaluate_data_agent( df, data_agent_name, critic_prompt=critic_prompt, table_name=table_name, data_agent_stage="sandbox" )
Use the built-in SDK functions to retrieve the results of your evaluation:
from fabric.dataagent.evaluation import get_evaluation_summaryeval_summary_df = get_evaluation_summary(table_name)
eval_summary_df
Dataframe_of_the_evaluation_summary_showing_the_number_of_true_false_and_unclear
from fabric.dataagent.evaluation import get_evaluation_detailseval_details_df = get_evaluation_details( evaluation_id, table_name, get_all_rows=True, verbose=True )
Dataframe_output_showing_the_details_for_a_given_evaluation_ID._This_shows_the_q
You can start evaluating your Data Agents in just a few steps:
These resources provide everything you need to build, test, and iterate on your Data Agents using the Fabric SDK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.