Building a Tool-calling Agent with LlamaIndex Workflow and MLflow
Welcome to this interactive tutorial designed to introduce you to LlamaIndex Workflow and its integration with MLflow. This tutorial is structured as a notebook to provide a hands-on, practical learning experience with Workflow, LlamaIndex's novel approach to design LLM applications, and managing the development process with MLflow.

What you will learn
By the end of this tutorial you will have:
- Created an MVP agentic application with tool calling functionality in a LlamaIndex Workflow.
- Observed the agent actions with MLflow Tracing.
- Logged that workflow to the MLflow Experiment.
- Loaded the model back and performed inference.
- Explored the MLflow UI to learn about logged artifacts.
Installation
MLflow's integration with LlamaIndex's Workflow API is available in MLflow >= 2.17.0 and LlamaIndex (core) >= 0.11.16. After installing the packages, you may need to restart the Python kernel to correctly load modules.
%pip install mlflow>=2.17.0 llama-index>=0.11.16 -qqqU
# Workflow util is required for rendering Workflow as HTML
%pip install llama-index-utils-workflow -qqqU
Choose your favorite LLM
By default, LlamaIndex uses OpenAI as the source for LLms and embedding models. If you are signing up with different LLM providers or using a local model, configure them for use by using the Settings object.
Option 1: OpenAI (default)
LlamaIndex by default uses OpenAI APIs for LLMs and embeddings models. To proceed with this setting, you just need to set the API key in the environment variable.
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_OPENAI_API_KEY>"
Option 2: Other Hosted LLMs
If you want to use other hosted LLMs,
- Download the integration package for the model provider of your choice.
- Set up required environment variables as specified in the integration documentation.
- Instantiate the LLM instance and set it to the global
Settingsobject.
The following cells show an example for using Databricks hosted LLMs (Llama3.1 70B instruct).
%pip install llama-index-llms-databricks
import os
os.environ["DATABRICKS_TOKEN"] = "<YOUR_DATABRICKS_API_TOKEN>"
os.environ["DATABRICKS_SERVING_ENDPOINT"] = "https://YOUR_DATABRICKS_HOST/serving-endpoints/"
from llama_index.core import Settings
from llama_index.llms.databricks import Databricks
llm = Databricks(model="databricks-meta-llama-3-1-70b-instruct")
Settings.llm = llm
Option 3: Local LLM
LlamaIndex also support locally hosted LLMs. Please refer to the Starter Tutorial (Local Models) for how to set them up.