2:
Install dependencies
Note: you may need to restart the kernel using %restart_python or dbutils.library.restartPython() to use updated packages.
4
6
Writing hello_world_agent.py
8
9
ChatAgentResponse(messages=[ChatAgentMessage(role='assistant', content='To monitor your GenAI app, you can use Lakehouse Monitoring for GenAI, which allows you to track quality and operational performance, including latency, request volume, and errors. Additionally, you can run LLM-based evaluations on production traffic to detect drift or regressions, and deep dive into individual requests to debug and improve agent responses. This feature also enables you to transform real-world logs into evaluation sets to drive continuous improvements.', name=None, id='chatcmpl_986a61f3-873b-4ebd-8f9b-8de066e3c9f8', tool_calls=None, tool_call_id=None, attachments=None)], finish_reason=None, custom_outputs=None, usage=None)
Trace(request_id=tr-6259e3860b964eeab635f07fe72e82db)
10
2025/03/13 13:19:58 INFO mlflow.pyfunc: Predicting on input example to validate output
11
2025/03/13 13:20:08 INFO mlflow.models.flavor_backend_registry: Selected backend for flavor 'python_function'
2025/03/13 13:20:09 INFO mlflow.utils.virtualenv: Creating a new environment in /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43 with python version 3.12.3 using uv
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43
Activate with: source /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43/bin/activate
2025/03/13 13:20:10 INFO mlflow.utils.virtualenv: Installing dependencies
Using Python 3.12.3 environment at: /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43
Resolved 3 packages in 84ms
Downloading pip (2.0MiB)
Downloading setuptools (1.2MiB)
Downloaded pip
Downloaded setuptools
Prepared 3 packages in 173ms
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
If the cache and target directories are on different filesystems, hardlinking may not be supported.
If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 3 packages in 44ms
+ pip==24.0
+ setuptools==74.0.0
+ wheel==0.43.0
Using Python 3.12.3 environment at: /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43
Resolved 120 packages in 850ms
Downloading mlflow (26.6MiB)
Downloading matplotlib (8.2MiB)
Downloading cryptography (4.0MiB)
Downloading kiwisolver (1.4MiB)
Downloading grpcio (5.6MiB)
Downloading pandas (12.1MiB)
Downloading fonttools (4.6MiB)
Downloading numpy (17.1MiB)
Downloading pillow (4.3MiB)
Downloading scipy (35.6MiB)
Downloading pyarrow (40.1MiB)
Downloading zstandard (5.2MiB)
Downloading sqlalchemy (3.1MiB)
Downloading botocore (12.8MiB)
Downloading tiktoken (1.1MiB)
Downloading scikit-learn (12.5MiB)
Downloading mlflow-skinny (5.8MiB)
Downloading pydantic-core (1.9MiB)
Downloading databricks-connect (2.3MiB)
Downloaded tiktoken
Downloaded kiwisolver
Downloaded pydantic-core
Downloaded sqlalchemy
Downloaded databricks-connect
Downloaded pillow
Downloaded cryptography
Downloaded fonttools
Downloaded zstandard
Downloaded grpcio
Downloaded matplotlib
Downloaded mlflow-skinny
Downloaded scikit-learn
Downloaded numpy
Downloaded pandas
Downloaded mlflow
Downloaded botocore
Downloaded scipy
Downloaded pyarrow
Prepared 119 packages in 3.88s
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
If the cache and target directories are on different filesystems, hardlinking may not be supported.
If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 119 packages in 668ms
+ alembic==1.15.1
+ annotated-types==0.7.0
+ anyio==4.8.0
+ azure-core==1.32.0
+ azure-storage-blob==12.25.0
+ azure-storage-file-datalake==12.19.0
+ backoff==2.2.1
+ blinker==1.9.0
+ boto3==1.37.11
+ botocore==1.37.11
+ cachetools==5.5.2
+ certifi==2025.1.31
+ cffi==1.17.1
+ charset-normalizer==3.4.1
+ click==8.1.8
+ cloudpickle==3.1.1
+ contourpy==1.3.1
+ cryptography==44.0.2
+ cycler==0.12.1
+ databricks-agents==0.17.2
+ databricks-connect==16.2.0
+ databricks-sdk==0.46.0
+ dataclasses-json==0.6.7
+ deprecated==1.2.18
+ distro==1.9.0
+ docker==7.1.0
+ fastapi==0.115.11
+ flask==3.1.0
+ fonttools==4.56.0
+ gitdb==4.0.12
+ gitpython==3.1.44
+ google-api-core==2.24.2
+ google-auth==2.38.0
+ google-cloud-core==2.4.3
+ google-cloud-storage==3.1.0
+ google-crc32c==1.6.0
+ google-resumable-media==2.7.2
+ googleapis-common-protos==1.69.1
+ graphene==3.4.3
+ graphql-core==3.2.6
+ graphql-relay==3.2.0
+ greenlet==3.1.1
+ grpcio==1.71.0
+ grpcio-status==1.71.0
+ gunicorn==23.0.0
+ h11==0.14.0
+ httpcore==1.0.7
+ httpx==0.28.1
+ idna==3.10
+ importlib-metadata==8.6.1
+ isodate==0.7.2
+ itsdangerous==2.2.0
+ jinja2==3.1.6
+ jiter==0.9.0
+ jmespath==1.0.1
+ joblib==1.4.2
+ jsonpatch==1.33
+ jsonpointer==3.0.0
+ kiwisolver==1.4.8
+ langchain-core==0.3.45rc1
+ langchain-openai==0.3.9rc1
+ langsmith==0.3.14rc1
+ mako==1.3.9
+ markdown==3.7
+ markupsafe==3.0.2
+ marshmallow==3.26.1
+ matplotlib==3.10.1
+ mlflow==2.21.0rc0
+ mlflow-skinny==2.21.0rc0
+ mypy-extensions==1.0.0
+ numpy==1.26.4
+ openai==1.66.3
+ opentelemetry-api==1.31.0
+ opentelemetry-sdk==1.31.0
+ opentelemetry-semantic-conventions==0.52b0
+ orjson==3.10.15
+ packaging==24.2
+ pandas==2.2.3
+ pillow==11.1.0
+ proto-plus==1.26.1
+ protobuf==5.29.3
+ py4j==0.10.9.7
+ pyarrow==19.0.1
+ pyasn1==0.6.1
+ pyasn1-modules==0.4.1
+ pycparser==2.22
+ pydantic==2.11.0b1
+ pydantic-core==2.31.1
+ pyparsing==3.2.1
+ python-dateutil==2.9.0.post0
+ pytz==2025.1
+ pyyaml==6.0.2
+ regex==2024.11.6
+ requests==2.32.3
+ requests-toolbelt==1.0.0
+ rsa==4.9
+ s3transfer==0.11.4
+ scikit-learn==1.6.1
+ scipy==1.15.2
+ six==1.17.0
+ smmap==5.0.2
+ sniffio==1.3.1
+ sqlalchemy==2.0.39
+ sqlparse==0.5.3
+ starlette==0.46.1
+ tenacity==9.0.0
+ threadpoolctl==3.5.0
+ tiktoken==0.9.0
+ tqdm==4.67.1
+ typing-extensions==4.12.2
+ typing-inspect==0.9.0
+ typing-inspection==0.4.0
+ tzdata==2025.1
+ urllib3==2.3.0
+ uvicorn==0.34.0
+ werkzeug==3.1.3
+ wrapt==1.17.2
+ zipp==3.21.0
+ zstandard==0.23.0
2025/03/13 13:20:16 INFO mlflow.utils.environment: === Running command '['bash', '-c', 'source /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43/bin/activate && python -c ""']'
2025/03/13 13:20:16 INFO mlflow.utils.environment: === Running command '['bash', '-c', 'source /local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-1958f-7bf95-0/mlflow/envs/virtualenv_envs/mlflow-97a0af8652bd98e99256b2e6911ea0243c4c1e43/bin/activate && python /local_disk0/.ephemeral_nfs/envs/pythonEnv-86a069c3-b27e-497b-b901-ef7491e429e3/lib/python3.12/site-packages/mlflow/pyfunc/_mlflow_pyfunc_backend_predict.py --model-uri file:///local_disk0/repl_tmp_data/ReplId-1958f-7bf95-0/tmpjz26fq6b/agent --content-type json --input-path /local_disk0/repl_tmp_data/ReplId-1958f-7bf95-0/tmpk7cne3jf/input.json']'
2025/03/13 13:20:23 WARNING mlflow.tracing.processor.mlflow: Creating a trace within the default experiment with id '0'. It is strongly recommended to not use the default experiment to log traces due to ambiguous search results and probable performance issues over time due to directory table listing performance degradation with high volumes of directories within a specific path. To avoid performance and disambiguation issues, set the experiment for your environment using `mlflow.set_experiment()` API.
2025/03/13 13:20:23 WARNING mlflow.tracking.client: Failed to start trace Completions: RESOURCE_DOES_NOT_EXIST: Experiment with id '0' does not exist.. For full traceback, set logging level to debug.
{"messages": [{"role": "assistant", "content": "To monitor your GenAI app, you can use Lakehouse Monitoring for GenAI, which allows you to track quality and operational performance, including latency, request volume, and errors. Additionally, you can run LLM-based evaluations on production traffic to detect drift or regressions and deep dive into individual requests to debug and improve agent responses. This tool also enables you to transform real-world logs into evaluation sets to drive continuous improvements.", "id": "chatcmpl_6458e833-bf5d-416f-a66f-8eaed74b99ed"}]}
12
Successfully registered model 'agents_demo.playground.my_demo_agent'.
Created version '1' of model 'agents_demo.playground.my_demo_agent'.
/local_disk0/.ephemeral_nfs/envs/pythonEnv-86a069c3-b27e-497b-b901-ef7491e429e3/lib/python3.12/site-packages/mlflow/pyfunc/utils/data_validation.py:168: UserWarning: Add type hints to the `predict` method to enable data validation and automatic signature inference during model logging. Check https://mlflow.org/docs/latest/model/python_model.html#type-hint-usage-in-pythonmodel for more details.
color_warning(
Deployment of agents_demo.playground.my_demo_agent version 1 initiated. This can take up to 15 minutes and the Review App & Query Endpoint will not work until this deployment finishes.
View status: https://e2-demo-field-eng.cloud.databricks.com/ml/endpoints/agents_agents_demo-playground-my_demo_agent
Review App: https://e2-demo-field-eng.cloud.databricks.com/ml/review-v2/a4aefeb7246c4dca87409eeb1ed2575b/chat
Monitor: https://e2-demo-field-eng.cloud.databricks.com/ml/experiments/1315887243144609/evaluation-monitoring?endpointName=agents_agents_demo-playground-my_demo_agent
13
Waiting for endpoint to deploy. This can take 10 - 20 minutes.
READY!
16
Updated monitor for endpoint "agents_agents_demo-playground-my_demo_agent".
View monitoring page: https://e2-demo-field-eng.cloud.databricks.com/ml/experiments/1315887243144609/evaluation-monitoring?endpointName=agents_agents_demo-playground-my_demo_agent
19
Question 1: What is Mosaic AI Agent Evaluation?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "0693d8bc-fc31-4536-b81f-4ce4dd6a45a2", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 2: How do you use MLflow with Databricks for experiment tracking?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "4eccc481-eeb6-4bdf-978e-4eb296396fc0", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 3: What should I use Databricks Feature Store for?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "3d4c781b-b20a-4709-8fcc-26f68e48108b", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 4: How does AutoML work in Databricks?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "90bd6f75-96da-44c5-a3e9-aa9d2532ade6", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 5: What is Model Serving in Databricks and what are its deployment options?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "799e227c-164f-4ae8-8311-bf6d104ad6ee", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 6: How does Databricks handle distributed deep learning training?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "4ea9668a-b41a-4fe3-805f-92e3ff401ae4", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 7: Does Unity Catalog support models?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "36e7e158-c1dc-4a30-8d95-acb76dfd8468", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 8: What is the Databricks Lakehouse?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "226fc72e-7cec-4a5a-86a7-3e4f21ea46a1", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 9: Which Llama models are supported on Databricks?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "3ca3f1ea-d192-493d-bb41-64da548dc67c", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
Question 10: How does Databricks integrate with popular ML frameworks like PyTorch and TensorFlow?
Attaching feedback: {"dataframe_records": [{"source": {"id": "fake.user@databricks.com", "type": "human"}, "request_id": "e8b382bb-4001-4e8d-91bd-9e1373a2839f", "text_assessments": [{"ratings": {"answer_correct": {"value": "positive"}}, "free_text_comment": "", "suggested_output": ""}], "retrieval_assessments": []}]}
22
26
28