Merge abe628d8ab202a9cbfe5f2b850262362cee266f9 into d7eb05b9361febead29a74e71ddffc2ebeff5302

This commit is contained in:
Patcher 2024-11-14 13:57:16 +08:00 committed by GitHub
commit 1a4e022381
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

46
docs/monitoring.md Normal file
View File

@ -0,0 +1,46 @@
# Monitoring
Use OpenTelemetry to monitor your LLM application in real-time. OpenLIT simplifies the process of gathering insights on interactions, usage metrics, and more, enabling you to optimize the performance and reliability of your Ollama based LLM application.
## How it works?
OpenLIT extends the capabilities of the Ollama Python SDK by adding automated data instrumentation. It automatically wraps around the `chat`, `generate` and `embeddings` functions, generating OpenTelemetry data (traces and metrics) that help you understand how your application performs under various conditions. This telemetry data can be easily integrated with popular observability platforms like Grafana and DataDog, which allows for in-depth analysis and visualization.
## Getting Started
Heres a straightforward guide to help you set up and start monitoring your application:
### 1. Install the OpenLIT SDK
Open your terminal and run:
```shell
pip install openlit
```
### 2. Setup Your Application for Monitoring
In your Python script, configure OpenLIT to work with Ollama:
```python
import ollama
import openlit
openlit.init()
response = ollama.chat(model='llama3', messages=[
{
'role': 'user',
'content': 'Why is the sky blue?',
},
])
print(response['message']['content'])
```
This setup wraps your Ollama model interactions within a monitored session, capturing valuable data about each request and response.
### Visualize
Once you've set up data collection with OpenLIT, you can visualize and analyze this information to better understand your application's performance:
- **Review Your Data:** Connect to OpenLIT's UI to start exploring performance metrics. Visit the OpenLIT [Quickstart Guide](https://docs.openlit.io/latest/quickstart) for step-by-step details.
- **Integrate with Observability Tools:** If you use tools like Grafana or DataDog, you can integrate the data collected by OpenLIT. For instructions on setting up these connections, check the OpenLIT [Connections Guide](https://docs.openlit.io/latest/connections/intro).