openlit 1.7.0__tar.gz → 1.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openlit-1.7.0 → openlit-1.9.0}/PKG-INFO +74 -57
- {openlit-1.7.0 → openlit-1.9.0}/README.md +73 -56
- {openlit-1.7.0 → openlit-1.9.0}/pyproject.toml +1 -1
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/__helpers.py +30 -5
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/__init__.py +7 -4
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/cohere/cohere.py +4 -3
- {openlit-1.7.0 → openlit-1.9.0}/LICENSE +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/openai/async_azure_openai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/openai/azure_openai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/otel/tracing.py +0 -0
- {openlit-1.7.0 → openlit-1.9.0}/src/openlit/semcov/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.9.0
|
4
4
|
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects
|
5
5
|
Home-page: https://github.com/openlit/openlit/tree/main/openlit/python
|
6
6
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT
|
@@ -38,6 +38,9 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
|
|
38
38
|
[](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
|
39
39
|
[](https://twitter.com/openlit_io)
|
40
40
|
|
41
|
+

|
42
|
+
|
43
|
+
|
41
44
|
</div>
|
42
45
|
|
43
46
|
OpenLIT Python SDK is an **OpenTelemetry-native** Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects. Designed with simplicity and efficiency, OpenLIT offers the ability to embed observability into your GenAI-driven projects effortlessly using just **a single line of code**.
|
@@ -46,31 +49,20 @@ Whether you're directly using LLM Libraries like OpenAI, Anthropic or building c
|
|
46
49
|
|
47
50
|
This project adheres to the [Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai) proposed by the OpenTelemetry community. You can check out the current definitions [here](src/openlit/semcov/__init__.py).
|
48
51
|
|
49
|
-
##
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
### Vector DBs
|
64
|
-
- [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb)
|
65
|
-
- [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone)
|
66
|
-
- [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant)
|
67
|
-
- [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus)
|
68
|
-
|
69
|
-
### Frameworks
|
70
|
-
- [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain)
|
71
|
-
- [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm)
|
72
|
-
- [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index)
|
73
|
-
- [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack)
|
52
|
+
## Auto Instrumentation Capabilities
|
53
|
+
|
54
|
+
| LLMs | Vector DBs | Frameworks |
|
55
|
+
|----------------------------------------------------------|----------------------------------------------|----------------------------------------------|
|
56
|
+
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai) | [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb) | [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain) |
|
57
|
+
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) |
|
58
|
+
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) |
|
59
|
+
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) |
|
60
|
+
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | |
|
61
|
+
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | |
|
62
|
+
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | |
|
63
|
+
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | |
|
64
|
+
| [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | |
|
65
|
+
| [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | |
|
74
66
|
|
75
67
|
## Supported Destinations
|
76
68
|
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
|
@@ -92,14 +84,16 @@ pip install openlit
|
|
92
84
|
|
93
85
|
## 🚀 Getting Started
|
94
86
|
|
95
|
-
|
87
|
+
### Step 1: Install OpenLIT
|
88
|
+
|
89
|
+
Open your command line or terminal and run:
|
96
90
|
|
97
91
|
```bash
|
98
92
|
pip install openlit
|
99
93
|
```
|
100
94
|
|
101
|
-
### Step 2:
|
102
|
-
Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **
|
95
|
+
### Step 2: Initialize OpenLIT in your Application
|
96
|
+
Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **two lines of code**:
|
103
97
|
|
104
98
|
```python
|
105
99
|
import openlit
|
@@ -107,46 +101,68 @@ import openlit
|
|
107
101
|
openlit.init()
|
108
102
|
```
|
109
103
|
|
110
|
-
|
104
|
+
To forward telemetry data to an HTTP OTLP endpoint, such as the OpenTelemetry Collector, set the `otlp_endpoint` parameter with the desired endpoint. Alternatively, you can configure the endpoint by setting the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable as recommended in the OpenTelemetry documentation.
|
105
|
+
|
106
|
+
> 💡 Info: If you dont provide `otlp_endpoint` function argument or set the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable, OpenLIT directs the trace directly to your console, which can be useful during development.
|
111
107
|
|
112
108
|
To send telemetry to OpenTelemetry backends requiring authentication, set the `otlp_headers` parameter with its desired value. Alternatively, you can configure the endpoint by setting the `OTEL_EXPORTER_OTLP_HEADERS` environment variable as recommended in the OpenTelemetry documentation.
|
113
109
|
|
114
110
|
#### Example
|
115
111
|
|
116
|
-
|
112
|
+
---
|
117
113
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
)
|
123
|
-
```
|
114
|
+
<details>
|
115
|
+
<summary>Initialize using Function Arguments</summary>
|
116
|
+
|
117
|
+
---
|
124
118
|
|
125
|
-
|
119
|
+
Add the following two lines to your application code:
|
120
|
+
|
121
|
+
```python
|
122
|
+
import openlit
|
123
|
+
|
124
|
+
openlit.init(
|
125
|
+
otlp_endpoint="YOUR_OTEL_ENDPOINT",
|
126
|
+
otlp_headers ="YOUR_OTEL_ENDPOINT_AUTH"
|
127
|
+
)
|
128
|
+
```
|
126
129
|
|
127
|
-
|
128
|
-
openlit.init()
|
129
|
-
```
|
130
|
+
</details>
|
130
131
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
---
|
133
|
+
|
134
|
+
<details>
|
135
|
+
|
136
|
+
<summary>Initialize using Environment Variables</summary>
|
137
|
+
|
138
|
+
---
|
139
|
+
|
140
|
+
Add the following two lines to your application code:
|
141
|
+
|
142
|
+
```python
|
143
|
+
import openlit
|
144
|
+
|
145
|
+
openlit.init()
|
146
|
+
```
|
147
|
+
|
148
|
+
Then, configure the your OTLP endpoint using environment variable:
|
149
|
+
|
150
|
+
```env
|
151
|
+
export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"
|
152
|
+
export OTEL_EXPORTER_OTLP_HEADERS = "YOUR_OTEL_ENDPOINT_AUTH"
|
153
|
+
```
|
154
|
+
</details>
|
155
|
+
|
156
|
+
---
|
135
157
|
|
136
158
|
### Step 3: Visualize and Optimize!
|
137
|
-
With the LLM Observability data now being collected and sent to
|
159
|
+
With the LLM Observability data now being collected and sent to OpenLIT, the next step is to visualize and analyze this data to get insights into your LLM application’s performance, behavior, and identify areas of improvement.
|
138
160
|
|
139
|
-
|
140
|
-
- At the top, ensure the correct Tempo data source is selected from the dropdown menu.
|
141
|
-
- Use the **Query** field to specify any particular traces you are interested in, or leave it empty to browse through all the available traces.
|
142
|
-
- You can adjust the time range to focus on specific periods of interest.
|
143
|
-
- Hit **Run Query** to fetch your trace data. You'll see a visual representation of your traces along with detailed information on particular spans when clicked.
|
161
|
+
To begin exploring your LLM Application's performance data within the OpenLIT UI, please see the [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
|
144
162
|
|
145
|
-
|
163
|
+
If you want to integrate and send metrics and traces to your existing observability tools, refer to our [Connections Guide](https://docs.openlit.io/latest/connections/intro) for detailed instructions.
|
146
164
|
|
147
|
-
|
148
|
-
- **Set Alerts:** Grafana also allows you to set up alerts based on specific thresholds. This feature can be invaluable in proactively managing your application's health by notifying you of potential issues before they impact users.
|
149
|
-
- **Iterate and Optimize:** Use the insights gained from your observability data to make informed decisions on optimizing your LLM application. This might involve refining model parameters, adjusting scaling strategies, or identifying and resolving bottlenecks.
|
165
|
+

|
150
166
|
|
151
167
|
|
152
168
|
### Configuration
|
@@ -163,8 +179,9 @@ Below is a detailed overview of the configuration options available, allowing yo
|
|
163
179
|
| `otlp_headers` | Defines headers for the OTLP exporter, useful for backends requiring authentication. | `None` | No |
|
164
180
|
| `disable_batch` | A flag to disable batch span processing, favoring immediate dispatch. | `False` | No |
|
165
181
|
| `trace_content` | Enables tracing of content for deeper insights. | `True` | No |
|
166
|
-
| `disabled_instrumentors`| List of instrumentors to disable.
|
182
|
+
| `disabled_instrumentors`| List of instrumentors to disable. | `None` | No |
|
167
183
|
| `disable_metrics` | If set, disables the collection of metrics. | `False` | No |
|
184
|
+
| `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
|
168
185
|
|
169
186
|
## 🌱 Contributing
|
170
187
|
|
@@ -183,5 +200,5 @@ Connect with the OpenLIT community and maintainers for support, discussions, and
|
|
183
200
|
- 🌟 If you like it, Leave a star on our [GitHub](https://github.com/openlit/openlit/)
|
184
201
|
- 🌍 Join our [Slack](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ) Community for live interactions and questions.
|
185
202
|
- 🐞 Report bugs on our [GitHub Issues](https://github.com/openlit/openlit/issues) to help us improve OpenLIT.
|
186
|
-
- 𝕏 Follow us on [X](https://
|
203
|
+
- 𝕏 Follow us on [X](https://x.com/openlit_io) for the latest updates and news.
|
187
204
|
|
@@ -13,6 +13,9 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
|
|
13
13
|
[](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
|
14
14
|
[](https://twitter.com/openlit_io)
|
15
15
|
|
16
|
+

|
17
|
+
|
18
|
+
|
16
19
|
</div>
|
17
20
|
|
18
21
|
OpenLIT Python SDK is an **OpenTelemetry-native** Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects. Designed with simplicity and efficiency, OpenLIT offers the ability to embed observability into your GenAI-driven projects effortlessly using just **a single line of code**.
|
@@ -21,31 +24,20 @@ Whether you're directly using LLM Libraries like OpenAI, Anthropic or building c
|
|
21
24
|
|
22
25
|
This project adheres to the [Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai) proposed by the OpenTelemetry community. You can check out the current definitions [here](src/openlit/semcov/__init__.py).
|
23
26
|
|
24
|
-
##
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
### Vector DBs
|
39
|
-
- [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb)
|
40
|
-
- [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone)
|
41
|
-
- [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant)
|
42
|
-
- [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus)
|
43
|
-
|
44
|
-
### Frameworks
|
45
|
-
- [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain)
|
46
|
-
- [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm)
|
47
|
-
- [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index)
|
48
|
-
- [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack)
|
27
|
+
## Auto Instrumentation Capabilities
|
28
|
+
|
29
|
+
| LLMs | Vector DBs | Frameworks |
|
30
|
+
|----------------------------------------------------------|----------------------------------------------|----------------------------------------------|
|
31
|
+
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai) | [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb) | [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain) |
|
32
|
+
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) |
|
33
|
+
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) |
|
34
|
+
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) |
|
35
|
+
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | |
|
36
|
+
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | |
|
37
|
+
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | |
|
38
|
+
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | |
|
39
|
+
| [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | |
|
40
|
+
| [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | |
|
49
41
|
|
50
42
|
## Supported Destinations
|
51
43
|
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
|
@@ -67,14 +59,16 @@ pip install openlit
|
|
67
59
|
|
68
60
|
## 🚀 Getting Started
|
69
61
|
|
70
|
-
|
62
|
+
### Step 1: Install OpenLIT
|
63
|
+
|
64
|
+
Open your command line or terminal and run:
|
71
65
|
|
72
66
|
```bash
|
73
67
|
pip install openlit
|
74
68
|
```
|
75
69
|
|
76
|
-
### Step 2:
|
77
|
-
Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **
|
70
|
+
### Step 2: Initialize OpenLIT in your Application
|
71
|
+
Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **two lines of code**:
|
78
72
|
|
79
73
|
```python
|
80
74
|
import openlit
|
@@ -82,46 +76,68 @@ import openlit
|
|
82
76
|
openlit.init()
|
83
77
|
```
|
84
78
|
|
85
|
-
|
79
|
+
To forward telemetry data to an HTTP OTLP endpoint, such as the OpenTelemetry Collector, set the `otlp_endpoint` parameter with the desired endpoint. Alternatively, you can configure the endpoint by setting the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable as recommended in the OpenTelemetry documentation.
|
80
|
+
|
81
|
+
> 💡 Info: If you dont provide `otlp_endpoint` function argument or set the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable, OpenLIT directs the trace directly to your console, which can be useful during development.
|
86
82
|
|
87
83
|
To send telemetry to OpenTelemetry backends requiring authentication, set the `otlp_headers` parameter with its desired value. Alternatively, you can configure the endpoint by setting the `OTEL_EXPORTER_OTLP_HEADERS` environment variable as recommended in the OpenTelemetry documentation.
|
88
84
|
|
89
85
|
#### Example
|
90
86
|
|
91
|
-
|
87
|
+
---
|
92
88
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
)
|
98
|
-
```
|
89
|
+
<details>
|
90
|
+
<summary>Initialize using Function Arguments</summary>
|
91
|
+
|
92
|
+
---
|
99
93
|
|
100
|
-
|
94
|
+
Add the following two lines to your application code:
|
95
|
+
|
96
|
+
```python
|
97
|
+
import openlit
|
98
|
+
|
99
|
+
openlit.init(
|
100
|
+
otlp_endpoint="YOUR_OTEL_ENDPOINT",
|
101
|
+
otlp_headers ="YOUR_OTEL_ENDPOINT_AUTH"
|
102
|
+
)
|
103
|
+
```
|
101
104
|
|
102
|
-
|
103
|
-
openlit.init()
|
104
|
-
```
|
105
|
+
</details>
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
---
|
108
|
+
|
109
|
+
<details>
|
110
|
+
|
111
|
+
<summary>Initialize using Environment Variables</summary>
|
112
|
+
|
113
|
+
---
|
114
|
+
|
115
|
+
Add the following two lines to your application code:
|
116
|
+
|
117
|
+
```python
|
118
|
+
import openlit
|
119
|
+
|
120
|
+
openlit.init()
|
121
|
+
```
|
122
|
+
|
123
|
+
Then, configure the your OTLP endpoint using environment variable:
|
124
|
+
|
125
|
+
```env
|
126
|
+
export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"
|
127
|
+
export OTEL_EXPORTER_OTLP_HEADERS = "YOUR_OTEL_ENDPOINT_AUTH"
|
128
|
+
```
|
129
|
+
</details>
|
130
|
+
|
131
|
+
---
|
110
132
|
|
111
133
|
### Step 3: Visualize and Optimize!
|
112
|
-
With the LLM Observability data now being collected and sent to
|
134
|
+
With the LLM Observability data now being collected and sent to OpenLIT, the next step is to visualize and analyze this data to get insights into your LLM application’s performance, behavior, and identify areas of improvement.
|
113
135
|
|
114
|
-
|
115
|
-
- At the top, ensure the correct Tempo data source is selected from the dropdown menu.
|
116
|
-
- Use the **Query** field to specify any particular traces you are interested in, or leave it empty to browse through all the available traces.
|
117
|
-
- You can adjust the time range to focus on specific periods of interest.
|
118
|
-
- Hit **Run Query** to fetch your trace data. You'll see a visual representation of your traces along with detailed information on particular spans when clicked.
|
136
|
+
To begin exploring your LLM Application's performance data within the OpenLIT UI, please see the [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
|
119
137
|
|
120
|
-
|
138
|
+
If you want to integrate and send metrics and traces to your existing observability tools, refer to our [Connections Guide](https://docs.openlit.io/latest/connections/intro) for detailed instructions.
|
121
139
|
|
122
|
-
|
123
|
-
- **Set Alerts:** Grafana also allows you to set up alerts based on specific thresholds. This feature can be invaluable in proactively managing your application's health by notifying you of potential issues before they impact users.
|
124
|
-
- **Iterate and Optimize:** Use the insights gained from your observability data to make informed decisions on optimizing your LLM application. This might involve refining model parameters, adjusting scaling strategies, or identifying and resolving bottlenecks.
|
140
|
+

|
125
141
|
|
126
142
|
|
127
143
|
### Configuration
|
@@ -138,8 +154,9 @@ Below is a detailed overview of the configuration options available, allowing yo
|
|
138
154
|
| `otlp_headers` | Defines headers for the OTLP exporter, useful for backends requiring authentication. | `None` | No |
|
139
155
|
| `disable_batch` | A flag to disable batch span processing, favoring immediate dispatch. | `False` | No |
|
140
156
|
| `trace_content` | Enables tracing of content for deeper insights. | `True` | No |
|
141
|
-
| `disabled_instrumentors`| List of instrumentors to disable.
|
157
|
+
| `disabled_instrumentors`| List of instrumentors to disable. | `None` | No |
|
142
158
|
| `disable_metrics` | If set, disables the collection of metrics. | `False` | No |
|
159
|
+
| `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
|
143
160
|
|
144
161
|
## 🌱 Contributing
|
145
162
|
|
@@ -158,4 +175,4 @@ Connect with the OpenLIT community and maintainers for support, discussions, and
|
|
158
175
|
- 🌟 If you like it, Leave a star on our [GitHub](https://github.com/openlit/openlit/)
|
159
176
|
- 🌍 Join our [Slack](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ) Community for live interactions and questions.
|
160
177
|
- 🐞 Report bugs on our [GitHub Issues](https://github.com/openlit/openlit/issues) to help us improve OpenLIT.
|
161
|
-
- 𝕏 Follow us on [X](https://
|
178
|
+
- 𝕏 Follow us on [X](https://x.com/openlit_io) for the latest updates and news.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openlit"
|
3
|
-
version = "1.
|
3
|
+
version = "1.9.0"
|
4
4
|
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects"
|
5
5
|
authors = ["OpenLIT"]
|
6
6
|
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
|
@@ -2,8 +2,9 @@
|
|
2
2
|
"""
|
3
3
|
This module has functions to calculate model costs based on tokens and to fetch pricing information.
|
4
4
|
"""
|
5
|
-
|
5
|
+
import json
|
6
6
|
import logging
|
7
|
+
from urllib.parse import urlparse
|
7
8
|
import requests
|
8
9
|
import tiktoken
|
9
10
|
from opentelemetry.trace import Status, StatusCode
|
@@ -122,11 +123,35 @@ def get_audio_model_cost(model, pricing_info, prompt):
|
|
122
123
|
cost = 0
|
123
124
|
return cost
|
124
125
|
|
125
|
-
def fetch_pricing_info():
|
126
|
-
"""
|
127
|
-
|
126
|
+
def fetch_pricing_info(pricing_json=None):
|
127
|
+
"""
|
128
|
+
Fetches pricing information from a specified URL or File Path.
|
129
|
+
|
130
|
+
Args:
|
131
|
+
pricing_json(str): path or url to the pricing json file
|
132
|
+
|
133
|
+
Returns:
|
134
|
+
dict: The pricing json
|
135
|
+
"""
|
136
|
+
if pricing_json:
|
137
|
+
is_url = urlparse(pricing_json).scheme != ""
|
138
|
+
if is_url:
|
139
|
+
pricing_url = pricing_json
|
140
|
+
else:
|
141
|
+
try:
|
142
|
+
with open(pricing_json, mode='r', encoding='utf-8') as f:
|
143
|
+
return json.load(f)
|
144
|
+
except FileNotFoundError:
|
145
|
+
logger.error("Pricing information file not found: %s", pricing_json)
|
146
|
+
except json.JSONDecodeError:
|
147
|
+
logger.error("Error decoding JSON from file: %s", pricing_json)
|
148
|
+
except Exception as file_err:
|
149
|
+
logger.error("Unexpected error occurred while reading file: %s", file_err)
|
150
|
+
return {}
|
151
|
+
else:
|
152
|
+
pricing_url = "https://raw.githubusercontent.com/openlit/openlit/main/assets/pricing.json"
|
128
153
|
try:
|
129
|
-
|
154
|
+
# Set a timeout of 10 seconds for both the connection and the read
|
130
155
|
response = requests.get(pricing_url, timeout=20)
|
131
156
|
response.raise_for_status()
|
132
157
|
return response.json()
|
@@ -75,7 +75,8 @@ class OpenlitConfig:
|
|
75
75
|
|
76
76
|
@classmethod
|
77
77
|
def update_config(cls, environment, application_name, tracer, otlp_endpoint,
|
78
|
-
otlp_headers, disable_batch, trace_content, metrics_dict,
|
78
|
+
otlp_headers, disable_batch, trace_content, metrics_dict,
|
79
|
+
disable_metrics, pricing_json):
|
79
80
|
"""
|
80
81
|
Updates the configuration based on provided parameters.
|
81
82
|
|
@@ -88,10 +89,11 @@ class OpenlitConfig:
|
|
88
89
|
otlp_headers (Dict[str, str]): OTLP headers.
|
89
90
|
disable_batch (bool): Disable batch span processing flag.
|
90
91
|
trace_content (bool): Enable or disable content tracing.
|
92
|
+
pricing_json(str): path or url to the pricing json file
|
91
93
|
"""
|
92
94
|
cls.environment = environment
|
93
95
|
cls.application_name = application_name
|
94
|
-
cls.pricing_info = fetch_pricing_info()
|
96
|
+
cls.pricing_info = fetch_pricing_info(pricing_json)
|
95
97
|
cls.tracer = tracer
|
96
98
|
cls.metrics_dict = metrics_dict
|
97
99
|
cls.otlp_endpoint = otlp_endpoint
|
@@ -126,7 +128,7 @@ def instrument_if_available(instrumentor_name, instrumentor_instance, config,
|
|
126
128
|
|
127
129
|
def init(environment="default", application_name="default", tracer=None, otlp_endpoint=None,
|
128
130
|
otlp_headers=None, disable_batch=False, trace_content=True, disabled_instrumentors=None,
|
129
|
-
meter=None, disable_metrics=False):
|
131
|
+
meter=None, disable_metrics=False, pricing_json=None):
|
130
132
|
"""
|
131
133
|
Initializes the openLIT configuration and setups tracing.
|
132
134
|
|
@@ -144,6 +146,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
144
146
|
trace_content (bool): Flag to trace content (Optional).
|
145
147
|
disabled_instrumentors (List[str]): Optional. List of instrumentor names to disable.
|
146
148
|
disable_metrics (bool): Flag to disable metrics (Optional)
|
149
|
+
pricing_json(str): File path or url to the pricing json (Optional)
|
147
150
|
"""
|
148
151
|
disabled_instrumentors = disabled_instrumentors if disabled_instrumentors else []
|
149
152
|
# Check for invalid instrumentor names
|
@@ -199,7 +202,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
199
202
|
# Update global configuration with the provided settings.
|
200
203
|
config.update_config(environment, application_name, tracer, otlp_endpoint,
|
201
204
|
otlp_headers, disable_batch, trace_content,
|
202
|
-
metrics_dict, disable_metrics)
|
205
|
+
metrics_dict, disable_metrics, pricing_json)
|
203
206
|
|
204
207
|
# Map instrumentor names to their instances
|
205
208
|
instrumentor_instances = {
|
@@ -203,9 +203,9 @@ def chat(gen_ai_endpoint, version, environment, application_name, tracer,
|
|
203
203
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
|
204
204
|
False)
|
205
205
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
|
206
|
-
response.
|
206
|
+
response.generation_id)
|
207
207
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
208
|
-
response.
|
208
|
+
response.finish_reason)
|
209
209
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
|
210
210
|
response.meta.billed_units.input_tokens)
|
211
211
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COMPLETION_TOKENS,
|
@@ -306,10 +306,11 @@ def chat_stream(gen_ai_endpoint, version, environment, application_name,
|
|
306
306
|
# Collect message IDs and aggregated response from events
|
307
307
|
if event.event_type == "stream-end":
|
308
308
|
llmresponse = event.response.text
|
309
|
-
response_id = event.response.response_id
|
310
309
|
prompt_tokens = event.response.meta.billed_units.input_tokens
|
311
310
|
completion_tokens = event.response.meta.billed_units.output_tokens
|
312
311
|
finish_reason = event.finish_reason
|
312
|
+
if event.event_type == "stream-start":
|
313
|
+
response_id = event.generation_id
|
313
314
|
yield event
|
314
315
|
|
315
316
|
# Handling exception ensure observability without disrupting operation
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|