Skip to content

Commit 1b71062

Browse files
authored
Merge pull request #404 from lmnr-ai/docs-observability
add docs on observability with Laminar
2 parents 8db5e74 + 7e0c796 commit 1b71062

4 files changed

Lines changed: 68 additions & 3 deletions

File tree

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"title": "Integrations",
3-
"pages": ["hud"]
4-
}
3+
"pages": [
4+
"hud",
5+
"observability"
6+
]
7+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Observability
3+
description: Trace CUA execution steps and sessions
4+
---
5+
6+
## Observability
7+
8+
CUA has a native integration with [Laminar](https://laminar.sh/) – open-source platform for tracing, evals, and labeling of autonomous AI agents. Read more about Laminar in the [Laminar docs](https://docs.lmnr.ai/).
9+
10+
## Setup
11+
12+
Register on [Laminar Cloud](https://laminar.sh/) or spin up a [local instance](https://github.com/lmnr-ai/lmnr) and get the key from your project settings. Set the `LMNR_PROJECT_API_KEY` environment variable to your key.
13+
14+
```bash
15+
pip install lmnr[all]
16+
export LMNR_PROJECT_API_KEY=your-key
17+
```
18+
19+
## Usage
20+
21+
Then, initialize Laminar at the entry point of your application, register Laminar LiteLLM callback, and all steps of CUA will be automatically traced.
22+
23+
```python
24+
import os
25+
26+
import litellm
27+
28+
from agent import ComputerAgent
29+
from computer import Computer
30+
from lmnr import Laminar, LaminarLiteLLMCallback # [!code highlight]
31+
32+
Laminar.initialize() # [!code highlight]
33+
litellm.callbacks.append(LaminarLiteLLMCallback()) # [!code highlight]
34+
35+
computer = Computer(
36+
os_type="linux",
37+
provider_type="cloud",
38+
name=os.getenv("CUA_CONTAINER_NAME"),
39+
api_key=os.getenv("CUA_API_KEY"),
40+
)
41+
42+
agent = ComputerAgent(
43+
model="openai/computer-use-preview",
44+
tools=[computer],
45+
)
46+
47+
async def main():
48+
async for step in agent.run("Create a new file called 'test.txt' in the current directory"):
49+
print(step["output"])
50+
51+
if __name__ == "__main__":
52+
asyncio.run(main())
53+
```
54+
55+
## Viewing traces
56+
57+
You can view traces in the Laminar UI by going to the traces tab in your project. When you select a trace,
58+
you will see all the agent execution steps, including computer actions, LLM calls, and screenshots.
59+
60+
For each step, you will see the LLM call, the computer action. The computer actions are highlighted in the timeline in yellow.
61+
62+
<img src="/docs/img/laminar_trace_example.png" alt="Example trace in Laminar showing the litellm.response span and its output." width="800px" />

docs/content/docs/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"---[CodeXml]API Reference---",
1818
"...libraries"
1919
]
20-
}
20+
}
628 KB
Loading

0 commit comments

Comments
 (0)