Supported Frameworks
It does not matter how you are using DSPy, nanomon suits you!
Step 1: Create a project in nanomon
Once you have your nanomon running (Self-Hosted or Cloud-Hosted), start by creating a project:
- Open nanomon UI home page
- Create a new Project
- Copy the project Client ID and Secret ID (you’ll need this to proper link the agent/flow with this project)
Step 2: Set the project credentials
Connect your agent/flow with the nanomon project you’ve just created in Step 1. To do that set the following environment variables in your DSPy project:
NANOMON_CLIENT_ID=<your_project_client_id>
NANOMON_SECRET_ID=<your_project_secret_id>
Step 3: Set the API Url (self-hosted only)
We know that when running locally we all want to have control about what are the ports to be used, why and when, because of that we allow you to change the nanomon API Url simply by setting, in your DSPy project the environment variable
NANOMON_API_URL=http://localhost:8000/api/v1 # Or the one you want to
This way the agents will report to the nanomon api that is running in that url you defined.
As the final step you just have to configure your agent/flow to send monitoring data to your nanomon project. All you have to do is to:
Install nanomon
Add this code snippet to your code
nanomon_context = NanomonRunContext(default_tags=["dev", "nanomon-tester"]) # add whatever tags you want
configure_nanomon(nanomon_context._sink)
lm = nanomon_context.instrument_lm(lm) # with lm being your regular DSPy lm
# Configure DSPy
dspy.configure(lm=lm)
# Wrap it
with nanomon_context.run(
tags=["my-agent-flow"], # an example of a tag of your choice
metadata={"user-id": "User ID 12345"} # just an example of how you can use it
):
# Run your lang graph (or simply your DSPy Predict or ReAct directly)
final_state = await graph.ainvoke(initial_state)