openlit 1.24.1__tar.gz → 1.27.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.
Files changed (77) hide show
  1. {openlit-1.24.1 → openlit-1.27.0}/PKG-INFO +75 -18
  2. {openlit-1.24.1 → openlit-1.27.0}/README.md +71 -17
  3. {openlit-1.24.1 → openlit-1.27.0}/pyproject.toml +3 -1
  4. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/__helpers.py +14 -0
  5. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/__init__.py +116 -1
  6. openlit-1.27.0/src/openlit/evals/__init__.py +12 -0
  7. openlit-1.27.0/src/openlit/evals/all.py +169 -0
  8. openlit-1.27.0/src/openlit/evals/bias_detection.py +173 -0
  9. openlit-1.27.0/src/openlit/evals/hallucination.py +170 -0
  10. openlit-1.27.0/src/openlit/evals/toxicity.py +168 -0
  11. openlit-1.27.0/src/openlit/evals/utils.py +272 -0
  12. openlit-1.27.0/src/openlit/guard/__init__.py +12 -0
  13. openlit-1.27.0/src/openlit/guard/all.py +200 -0
  14. openlit-1.27.0/src/openlit/guard/prompt_injection.py +118 -0
  15. openlit-1.27.0/src/openlit/guard/restrict_topic.py +152 -0
  16. openlit-1.27.0/src/openlit/guard/sensitive_topic.py +126 -0
  17. openlit-1.27.0/src/openlit/guard/utils.py +228 -0
  18. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/semcov/__init__.py +16 -0
  19. {openlit-1.24.1 → openlit-1.27.0}/LICENSE +0 -0
  20. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
  21. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
  22. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
  23. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
  24. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
  25. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
  26. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
  27. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
  28. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/chroma/__init__.py +0 -0
  29. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/chroma/chroma.py +0 -0
  30. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/cohere/__init__.py +0 -0
  31. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/cohere/cohere.py +0 -0
  32. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
  33. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
  34. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
  35. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
  36. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
  37. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
  38. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
  39. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
  40. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
  41. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
  42. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/gpu/__init__.py +0 -0
  43. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/groq/__init__.py +0 -0
  44. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/groq/async_groq.py +0 -0
  45. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/groq/groq.py +0 -0
  46. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/haystack/__init__.py +0 -0
  47. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/haystack/haystack.py +0 -0
  48. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/langchain/__init__.py +0 -0
  49. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/langchain/langchain.py +0 -0
  50. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
  51. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
  52. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/milvus/__init__.py +0 -0
  53. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/milvus/milvus.py +0 -0
  54. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/mistral/__init__.py +0 -0
  55. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
  56. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/mistral/mistral.py +0 -0
  57. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/ollama/__init__.py +0 -0
  58. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
  59. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/ollama/ollama.py +0 -0
  60. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/openai/__init__.py +0 -0
  61. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/openai/async_azure_openai.py +0 -0
  62. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/openai/async_openai.py +0 -0
  63. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/openai/azure_openai.py +0 -0
  64. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/openai/openai.py +0 -0
  65. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
  66. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
  67. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
  68. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
  69. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/transformers/__init__.py +0 -0
  70. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/transformers/transformers.py +0 -0
  71. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
  72. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
  73. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
  74. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/vllm/__init__.py +0 -0
  75. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/instrumentation/vllm/vllm.py +0 -0
  76. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/otel/metrics.py +0 -0
  77. {openlit-1.24.1 → openlit-1.27.0}/src/openlit/otel/tracing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openlit
3
- Version: 1.24.1
3
+ Version: 1.27.0
4
4
  Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, 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,gpu
@@ -12,9 +12,12 @@ Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: anthropic (>=0.21.0,<0.22.0)
15
17
  Requires-Dist: boto3 (>=1.34.0,<2.0.0)
16
18
  Requires-Dist: botocore (>=1.34.0,<2.0.0)
17
19
  Requires-Dist: gpustat (>=1.1.1,<2.0.0)
20
+ Requires-Dist: openai (>=1.1.1,<2.0.0)
18
21
  Requires-Dist: opentelemetry-api (>=1.27.0,<2.0.0)
19
22
  Requires-Dist: opentelemetry-exporter-otlp (>=1.27.0,<2.0.0)
20
23
  Requires-Dist: opentelemetry-instrumentation (>=0.48b0,<0.49)
@@ -26,10 +29,11 @@ Project-URL: Repository, https://github.com/openlit/openlit/tree/main/openlit/py
26
29
  Description-Content-Type: text/markdown
27
30
 
28
31
  <div align="center">
29
- <img src="https://github.com/openlit/.github/blob/main/profile/assets/wide-logo-no-bg.png?raw=true" alt="OpenLIT Logo" width="30%"><h1>
30
- OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
32
+ <img src="https://github.com/openlit/.github/blob/main/profile/assets/wide-logo-no-bg.png?raw=true" alt="OpenLIT Logo" width="30%">
33
+ <h3>OpenTelemetry-native</h3>
34
+ <h1>AI Observability, Evaluation and Guardrails Framework</h1>
31
35
 
32
- **[Documentation](https://docs.openlit.io/) | [Quickstart](#-getting-started) | [Python SDK](https://github.com/openlit/openlit/tree/main/sdk/python)**
36
+ **[Documentation](https://docs.openlit.io/) | [Quickstart](#-getting-started-with-llm-observability) | [Roadmap](#️-roadmap) | [Feature Request](https://github.com/openlit/openlit/issues/new?assignees=&labels=%3Araised_hand%3A+Up+for+Grabs%2C+%3Arocket%3A+Feature&projects=&template=feature-request.md&title=%5BFeat%5D%3A) | [Report a Bug](https://github.com/openlit/openlit/issues/new?assignees=&labels=%3Abug%3A+Bug%2C+%3Araised_hand%3A+Up+for+Grabs&projects=&template=bug.md&title=%5BBug%5D%3A)**
33
37
 
34
38
  [![OpenLIT](https://img.shields.io/badge/OpenLIT-orange)](https://github.com/openlit/openlit)
35
39
  [![License](https://img.shields.io/github/license/openlit/openlit?label=License&logo=github&color=f80&logoColor=white)](https://github.com/openlit/openlit/blob/main/LICENSE)
@@ -38,7 +42,6 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
38
42
  [![GitHub Contributors](https://img.shields.io/github/contributors/openlit/openlit)](https://github.com/openlit/openlit/graphs/contributors)
39
43
 
40
44
  [![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack&logoColor=white)](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
41
- [![Discord](https://img.shields.io/badge/Discord-7289DA?logo=discord&logoColor=white)](https://discord.gg/CQnXwNT3)
42
45
  [![X](https://img.shields.io/badge/follow-%40openlit__io-1DA1F2?logo=x&style=social)](https://twitter.com/openlit_io)
43
46
 
44
47
  ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/github-readme-connections-banner.png?raw=true)
@@ -46,11 +49,16 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
46
49
 
47
50
  </div>
48
51
 
49
- 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**.
52
+ OpenLIT SDK is a monitoring framework built on top of **OpenTelemetry** that gives your complete Observability for your AI stack, from LLMs to vector databases and GPUs, with just one line of code with tracing and metrics. It also allows you to send the generated traces and metrics to your existing monitoring tools like Grafana, New Relic, and more.
50
53
 
51
- Whether you're directly using LLM Libraries like OpenAI, Anthropic or building complex RAG Agents using Langchain, OpenLIT seamlessly integrates observability into your applications, ensuring enhanced performance and reliability across diverse scenarios.
54
+ This project proudly follows and maintains the [Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai) with the OpenTelemetry community, consistently updating to align with the latest standards in Observability.
52
55
 
53
- 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).
56
+ ## Features
57
+
58
+ - 🔎 **Auto Instrumentation**: Works with 30+ LLM providers, vector databases, and GPUs with just one line of code.
59
+ - 🔭 **OpenTelemetry-Native Observability SDKs**: Vendor-neutral SDKs that can send traces and metrics to your existing observability tool like Prometheus and Jaeger.
60
+ - 💲 **Cost Tracking for Custom and Fine-Tuned Models**: Pass custom pricing files for accurate budgeting of custom and fine-tuned models.
61
+ - 🚀 **Suppport for OpenLIT Features**: Includes suppprt for prompt management and secrets management features available in OpenLIT.
54
62
 
55
63
  ## Auto Instrumentation Capabilities
56
64
 
@@ -96,9 +104,9 @@ This project adheres to the [Semantic Conventions](https://github.com/open-telem
96
104
  pip install openlit
97
105
  ```
98
106
 
99
- ## 🚀 Getting Started
107
+ ## 🚀 Getting Started with LLM Observability
100
108
 
101
- ### Step 1: Install OpenLIT
109
+ ### Step 1: Install OpenLIT SDK
102
110
 
103
111
  Open your command line or terminal and run:
104
112
 
@@ -107,7 +115,7 @@ pip install openlit
107
115
  ```
108
116
 
109
117
  ### Step 2: Initialize OpenLIT in your Application
110
- Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **two lines of code**:
118
+ Integrate OpenLIT into your AI applications by adding the following lines to your code.
111
119
 
112
120
  ```python
113
121
  import openlit
@@ -115,11 +123,14 @@ import openlit
115
123
  openlit.init()
116
124
  ```
117
125
 
118
- 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.
126
+ Configure the telemetry data destination as follows:
119
127
 
120
- > 💡 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.
128
+ | Purpose | Parameter/Environment Variable | For Sending to OpenLIT |
129
+ |-------------------------------------------|--------------------------------------------------|--------------------------------|
130
+ | Send data to an HTTP OTLP endpoint | `otlp_endpoint` or `OTEL_EXPORTER_OTLP_ENDPOINT` | `"http://127.0.0.1:4318"` |
131
+ | Authenticate telemetry backends | `otlp_headers` or `OTEL_EXPORTER_OTLP_HEADERS` | Not required by default |
121
132
 
122
- 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.
133
+ > 💡 Info: If the `otlp_endpoint` or `OTEL_EXPORTER_OTLP_ENDPOINT` is not provided, the OpenLIT SDK will output traces directly to your console, which is recommended during the development phase.
123
134
 
124
135
  #### Example
125
136
 
@@ -170,19 +181,22 @@ To send telemetry to OpenTelemetry backends requiring authentication, set the `o
170
181
  ---
171
182
 
172
183
  ### Step 3: Visualize and Optimize!
173
- 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 applications performance, behavior, and identify areas of improvement.
184
+ Now that your LLM observability data is being collected and sent to configured OpenTelemetry destination, the next step is to visualize and analyze this data. This will help you understand your LLM application's performance and behavior and identify where it can be improved.
174
185
 
175
- To begin exploring your LLM Application's performance data within the OpenLIT UI, please see the [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
186
+ If you want to use OpenLIT's Observability Dashboard to monitor LLM usage—like cost, tokens, and user interactions—please check out our [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
176
187
 
177
- 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.
188
+ If you're sending metrics and traces to other observability tools, take a look at our [Connections Guide](https://docs.openlit.io/latest/connections/intro) to start using a pre-built dashboard we have created for these tools.
178
189
 
179
190
  ![](https://github.com/openlit/.github/blob/main/profile/assets/openlit-client-1.png?raw=true)
180
191
 
181
192
 
182
- ### Configuration
193
+ ## Configuration
194
+
195
+ ### Observability - `openlit.init()`
183
196
 
184
197
  Below is a detailed overview of the configuration options available, allowing you to adjust OpenLIT's behavior and functionality to align with your specific observability needs:
185
198
 
199
+
186
200
  | Argument | Description | Default Value | Required |
187
201
  |-------------------------|-----------------------------------------------------------------------------------------------|----------------|----------|
188
202
  | `environment` | The deployment environment of the application. | `"default"` | Yes |
@@ -198,6 +212,49 @@ Below is a detailed overview of the configuration options available, allowing yo
198
212
  | `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
199
213
  | `collect_gpu_stats` | Flag to enable or disable GPU metrics collection. | `False` | No |
200
214
 
215
+ ### OpenLIT Prompt Hub - `openlit.get_prompt()`
216
+
217
+ Below are the parameters for use with the SDK for OpenLIT Prompt Hub for prompt management:
218
+
219
+ | Parameter | Description |
220
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------|
221
+ | `url` | Sets the OpenLIT URL. Defaults to the `OPENLIT_URL` environment variable. |
222
+ | `api_key` | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable. |
223
+ | `name` | Sets the name to fetch a unique prompt. Use this or `prompt_id`. |
224
+ | `prompt_id` | Sets the ID to fetch a unique prompt. Use this or `name`. Optional |
225
+ | `version` | Set to `True` to get the prompt with variable substitution.. Optional |
226
+ | `shouldCompile` | Boolean value that compiles the prompt using the provided variables. Optional |
227
+ | `variables` | Sets the variables for prompt compilation. Optional |
228
+ | `meta_properties` | Sets the meta-properties for storing in the prompt's access history metadata. Optional |
229
+
230
+ ### OpenLIT Vault - `openlit.get_secrets()`
231
+
232
+ Below are the parameters for use with the SDK for OpenLIT Vault for secret management:
233
+
234
+ | Parameter | Description |
235
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------|
236
+ | `url` | Sets the Openlit URL. Defaults to the `OPENLIT_URL` environment variable. |
237
+ | `api_key` | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable. |
238
+ | `key` | Sets the key to fetch a specific secret. Optional |
239
+ | `should_set_env` | Boolean value that sets all the secrets as environment variables for the application. Optional |
240
+ | `tags` | Sets the tags for fetching only the secrets that have the mentioned tags assigned. Optional |
241
+
242
+
243
+ ## 🛣️ Roadmap
244
+
245
+ We are dedicated to continuously improving OpenLIT SDKs. Here's a look at what's been accomplished and what's on the horizon:
246
+
247
+ | Feature | Status |
248
+ |----------------------------------------------------------------------------------------------|---------------|
249
+ | [OpenTelmetry auto-instrumentation for LLM Providers like OpenAI, Anthropic]() | ✅ Completed |
250
+ | [OpenTelmetry auto-instrumentation for Vector databases like Pinecone, Chroma]() | ✅ Completed |
251
+ | [OpenTelmetry auto-instrumentation for LLM Frameworks like LangChain, LlamaIndex]() | ✅ Completed |
252
+ | [OpenTelemetry-native auto-instrumentation for NVIDIA GPU Monitoring](https://docs.openlit.io/latest/features/gpu) | ✅ Completed |
253
+ | [Real-Time Guardrails Implementation](https://docs.openlit.io/latest/features/guardrails) | ✅ Completed |
254
+ | [Programmatic Evaluation for LLM Response](https://docs.openlit.io/latest/features/evaluations) | ✅ Completed |
255
+ | [OpenTelmetry auto-instrumentation for Agent Frameworks like CrewAI, DsPy]() | 🔜 Coming Soon |
256
+
257
+
201
258
  ## 🌱 Contributing
202
259
 
203
260
  Whether it's big or small, we love contributions 💚. Check out our [Contribution guide](../../CONTRIBUTING.md) to get started
@@ -1,8 +1,9 @@
1
1
  <div align="center">
2
- <img src="https://github.com/openlit/.github/blob/main/profile/assets/wide-logo-no-bg.png?raw=true" alt="OpenLIT Logo" width="30%"><h1>
3
- OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
2
+ <img src="https://github.com/openlit/.github/blob/main/profile/assets/wide-logo-no-bg.png?raw=true" alt="OpenLIT Logo" width="30%">
3
+ <h3>OpenTelemetry-native</h3>
4
+ <h1>AI Observability, Evaluation and Guardrails Framework</h1>
4
5
 
5
- **[Documentation](https://docs.openlit.io/) | [Quickstart](#-getting-started) | [Python SDK](https://github.com/openlit/openlit/tree/main/sdk/python)**
6
+ **[Documentation](https://docs.openlit.io/) | [Quickstart](#-getting-started-with-llm-observability) | [Roadmap](#️-roadmap) | [Feature Request](https://github.com/openlit/openlit/issues/new?assignees=&labels=%3Araised_hand%3A+Up+for+Grabs%2C+%3Arocket%3A+Feature&projects=&template=feature-request.md&title=%5BFeat%5D%3A) | [Report a Bug](https://github.com/openlit/openlit/issues/new?assignees=&labels=%3Abug%3A+Bug%2C+%3Araised_hand%3A+Up+for+Grabs&projects=&template=bug.md&title=%5BBug%5D%3A)**
6
7
 
7
8
  [![OpenLIT](https://img.shields.io/badge/OpenLIT-orange)](https://github.com/openlit/openlit)
8
9
  [![License](https://img.shields.io/github/license/openlit/openlit?label=License&logo=github&color=f80&logoColor=white)](https://github.com/openlit/openlit/blob/main/LICENSE)
@@ -11,7 +12,6 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
11
12
  [![GitHub Contributors](https://img.shields.io/github/contributors/openlit/openlit)](https://github.com/openlit/openlit/graphs/contributors)
12
13
 
13
14
  [![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack&logoColor=white)](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
14
- [![Discord](https://img.shields.io/badge/Discord-7289DA?logo=discord&logoColor=white)](https://discord.gg/CQnXwNT3)
15
15
  [![X](https://img.shields.io/badge/follow-%40openlit__io-1DA1F2?logo=x&style=social)](https://twitter.com/openlit_io)
16
16
 
17
17
  ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/github-readme-connections-banner.png?raw=true)
@@ -19,11 +19,16 @@ OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications</h1>
19
19
 
20
20
  </div>
21
21
 
22
- 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**.
22
+ OpenLIT SDK is a monitoring framework built on top of **OpenTelemetry** that gives your complete Observability for your AI stack, from LLMs to vector databases and GPUs, with just one line of code with tracing and metrics. It also allows you to send the generated traces and metrics to your existing monitoring tools like Grafana, New Relic, and more.
23
23
 
24
- Whether you're directly using LLM Libraries like OpenAI, Anthropic or building complex RAG Agents using Langchain, OpenLIT seamlessly integrates observability into your applications, ensuring enhanced performance and reliability across diverse scenarios.
24
+ This project proudly follows and maintains the [Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/gen-ai) with the OpenTelemetry community, consistently updating to align with the latest standards in Observability.
25
25
 
26
- 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).
26
+ ## Features
27
+
28
+ - 🔎 **Auto Instrumentation**: Works with 30+ LLM providers, vector databases, and GPUs with just one line of code.
29
+ - 🔭 **OpenTelemetry-Native Observability SDKs**: Vendor-neutral SDKs that can send traces and metrics to your existing observability tool like Prometheus and Jaeger.
30
+ - 💲 **Cost Tracking for Custom and Fine-Tuned Models**: Pass custom pricing files for accurate budgeting of custom and fine-tuned models.
31
+ - 🚀 **Suppport for OpenLIT Features**: Includes suppprt for prompt management and secrets management features available in OpenLIT.
27
32
 
28
33
  ## Auto Instrumentation Capabilities
29
34
 
@@ -69,9 +74,9 @@ This project adheres to the [Semantic Conventions](https://github.com/open-telem
69
74
  pip install openlit
70
75
  ```
71
76
 
72
- ## 🚀 Getting Started
77
+ ## 🚀 Getting Started with LLM Observability
73
78
 
74
- ### Step 1: Install OpenLIT
79
+ ### Step 1: Install OpenLIT SDK
75
80
 
76
81
  Open your command line or terminal and run:
77
82
 
@@ -80,7 +85,7 @@ pip install openlit
80
85
  ```
81
86
 
82
87
  ### Step 2: Initialize OpenLIT in your Application
83
- Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just **two lines of code**:
88
+ Integrate OpenLIT into your AI applications by adding the following lines to your code.
84
89
 
85
90
  ```python
86
91
  import openlit
@@ -88,11 +93,14 @@ import openlit
88
93
  openlit.init()
89
94
  ```
90
95
 
91
- 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.
96
+ Configure the telemetry data destination as follows:
92
97
 
93
- > 💡 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.
98
+ | Purpose | Parameter/Environment Variable | For Sending to OpenLIT |
99
+ |-------------------------------------------|--------------------------------------------------|--------------------------------|
100
+ | Send data to an HTTP OTLP endpoint | `otlp_endpoint` or `OTEL_EXPORTER_OTLP_ENDPOINT` | `"http://127.0.0.1:4318"` |
101
+ | Authenticate telemetry backends | `otlp_headers` or `OTEL_EXPORTER_OTLP_HEADERS` | Not required by default |
94
102
 
95
- 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.
103
+ > 💡 Info: If the `otlp_endpoint` or `OTEL_EXPORTER_OTLP_ENDPOINT` is not provided, the OpenLIT SDK will output traces directly to your console, which is recommended during the development phase.
96
104
 
97
105
  #### Example
98
106
 
@@ -143,19 +151,22 @@ To send telemetry to OpenTelemetry backends requiring authentication, set the `o
143
151
  ---
144
152
 
145
153
  ### Step 3: Visualize and Optimize!
146
- 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 applications performance, behavior, and identify areas of improvement.
154
+ Now that your LLM observability data is being collected and sent to configured OpenTelemetry destination, the next step is to visualize and analyze this data. This will help you understand your LLM application's performance and behavior and identify where it can be improved.
147
155
 
148
- To begin exploring your LLM Application's performance data within the OpenLIT UI, please see the [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
156
+ If you want to use OpenLIT's Observability Dashboard to monitor LLM usage—like cost, tokens, and user interactions—please check out our [Quickstart Guide](https://docs.openlit.io/latest/quickstart).
149
157
 
150
- 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.
158
+ If you're sending metrics and traces to other observability tools, take a look at our [Connections Guide](https://docs.openlit.io/latest/connections/intro) to start using a pre-built dashboard we have created for these tools.
151
159
 
152
160
  ![](https://github.com/openlit/.github/blob/main/profile/assets/openlit-client-1.png?raw=true)
153
161
 
154
162
 
155
- ### Configuration
163
+ ## Configuration
164
+
165
+ ### Observability - `openlit.init()`
156
166
 
157
167
  Below is a detailed overview of the configuration options available, allowing you to adjust OpenLIT's behavior and functionality to align with your specific observability needs:
158
168
 
169
+
159
170
  | Argument | Description | Default Value | Required |
160
171
  |-------------------------|-----------------------------------------------------------------------------------------------|----------------|----------|
161
172
  | `environment` | The deployment environment of the application. | `"default"` | Yes |
@@ -171,6 +182,49 @@ Below is a detailed overview of the configuration options available, allowing yo
171
182
  | `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
172
183
  | `collect_gpu_stats` | Flag to enable or disable GPU metrics collection. | `False` | No |
173
184
 
185
+ ### OpenLIT Prompt Hub - `openlit.get_prompt()`
186
+
187
+ Below are the parameters for use with the SDK for OpenLIT Prompt Hub for prompt management:
188
+
189
+ | Parameter | Description |
190
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------|
191
+ | `url` | Sets the OpenLIT URL. Defaults to the `OPENLIT_URL` environment variable. |
192
+ | `api_key` | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable. |
193
+ | `name` | Sets the name to fetch a unique prompt. Use this or `prompt_id`. |
194
+ | `prompt_id` | Sets the ID to fetch a unique prompt. Use this or `name`. Optional |
195
+ | `version` | Set to `True` to get the prompt with variable substitution.. Optional |
196
+ | `shouldCompile` | Boolean value that compiles the prompt using the provided variables. Optional |
197
+ | `variables` | Sets the variables for prompt compilation. Optional |
198
+ | `meta_properties` | Sets the meta-properties for storing in the prompt's access history metadata. Optional |
199
+
200
+ ### OpenLIT Vault - `openlit.get_secrets()`
201
+
202
+ Below are the parameters for use with the SDK for OpenLIT Vault for secret management:
203
+
204
+ | Parameter | Description |
205
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------|
206
+ | `url` | Sets the Openlit URL. Defaults to the `OPENLIT_URL` environment variable. |
207
+ | `api_key` | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable. |
208
+ | `key` | Sets the key to fetch a specific secret. Optional |
209
+ | `should_set_env` | Boolean value that sets all the secrets as environment variables for the application. Optional |
210
+ | `tags` | Sets the tags for fetching only the secrets that have the mentioned tags assigned. Optional |
211
+
212
+
213
+ ## 🛣️ Roadmap
214
+
215
+ We are dedicated to continuously improving OpenLIT SDKs. Here's a look at what's been accomplished and what's on the horizon:
216
+
217
+ | Feature | Status |
218
+ |----------------------------------------------------------------------------------------------|---------------|
219
+ | [OpenTelmetry auto-instrumentation for LLM Providers like OpenAI, Anthropic]() | ✅ Completed |
220
+ | [OpenTelmetry auto-instrumentation for Vector databases like Pinecone, Chroma]() | ✅ Completed |
221
+ | [OpenTelmetry auto-instrumentation for LLM Frameworks like LangChain, LlamaIndex]() | ✅ Completed |
222
+ | [OpenTelemetry-native auto-instrumentation for NVIDIA GPU Monitoring](https://docs.openlit.io/latest/features/gpu) | ✅ Completed |
223
+ | [Real-Time Guardrails Implementation](https://docs.openlit.io/latest/features/guardrails) | ✅ Completed |
224
+ | [Programmatic Evaluation for LLM Response](https://docs.openlit.io/latest/features/evaluations) | ✅ Completed |
225
+ | [OpenTelmetry auto-instrumentation for Agent Frameworks like CrewAI, DsPy]() | 🔜 Coming Soon |
226
+
227
+
174
228
  ## 🌱 Contributing
175
229
 
176
230
  Whether it's big or small, we love contributions 💚. Check out our [Contribution guide](../../CONTRIBUTING.md) to get started
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openlit"
3
- version = "1.24.1"
3
+ version = "1.27.0"
4
4
  description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, 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"
@@ -20,6 +20,8 @@ opentelemetry-api = "^1.27.0"
20
20
  opentelemetry-sdk = "^1.27.0"
21
21
  opentelemetry-exporter-otlp = "^1.27.0"
22
22
  opentelemetry-instrumentation = "^0.48b0"
23
+ openai = "^1.1.1"
24
+ anthropic = "^0.21.0"
23
25
 
24
26
  [build-system]
25
27
  requires = ["poetry-core>=1.1.0"]
@@ -2,6 +2,7 @@
2
2
  """
3
3
  This module has functions to calculate model costs based on tokens and to fetch pricing information.
4
4
  """
5
+ import os
5
6
  import json
6
7
  import logging
7
8
  from urllib.parse import urlparse
@@ -12,6 +13,19 @@ from opentelemetry.trace import Status, StatusCode
12
13
  # Set up logging
13
14
  logger = logging.getLogger(__name__)
14
15
 
16
+ def get_env_variable(name, arg_value, error_message):
17
+ """
18
+ Retrieve an environment variable if the argument is not provided
19
+ and raise an error if both are not set.
20
+ """
21
+ if arg_value is not None:
22
+ return arg_value
23
+ value = os.getenv(name)
24
+ if not value:
25
+ logging.error(error_message)
26
+ raise RuntimeError(error_message)
27
+ return value
28
+
15
29
  def openai_tokens(text, model):
16
30
  """
17
31
  Calculate the number of tokens a given text would take up for a specified model.
@@ -7,9 +7,11 @@ large language models (LLMs).
7
7
 
8
8
  from typing import Dict
9
9
  import logging
10
+ import os
10
11
  from importlib.util import find_spec
11
12
  from functools import wraps
12
13
  from contextlib import contextmanager
14
+ import requests
13
15
 
14
16
 
15
17
  # Import internal modules for setting up tracing and fetching pricing info.
@@ -18,7 +20,7 @@ from opentelemetry.trace import SpanKind, Status, StatusCode, Span
18
20
  from openlit.semcov import SemanticConvetion
19
21
  from openlit.otel.tracing import setup_tracing
20
22
  from openlit.otel.metrics import setup_meter
21
- from openlit.__helpers import fetch_pricing_info
23
+ from openlit.__helpers import fetch_pricing_info, get_env_variable
22
24
 
23
25
 
24
26
  # Instrumentors for various large language models.
@@ -45,6 +47,8 @@ from openlit.instrumentation.qdrant import QdrantInstrumentor
45
47
  from openlit.instrumentation.milvus import MilvusInstrumentor
46
48
  from openlit.instrumentation.transformers import TransformersInstrumentor
47
49
  from openlit.instrumentation.gpu import NvidiaGPUInstrumentor
50
+ import openlit.guard
51
+ import openlit.evals
48
52
 
49
53
  # Set up logging for error and information messages.
50
54
  logger = logging.getLogger(__name__)
@@ -316,6 +320,117 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
316
320
  except Exception as e:
317
321
  logger.error("Error during openLIT initialization: %s", e)
318
322
 
323
+ def get_prompt(url=None, name=None, api_key=None, prompt_id=None,
324
+ version=None, should_compile=None, variables=None, meta_properties=None):
325
+ """
326
+ Retrieve and returns the prompt from OpenLIT Prompt Hub
327
+ """
328
+
329
+ # Validate and set the base URL
330
+ url = get_env_variable(
331
+ 'OPENLIT_URL',
332
+ url,
333
+ 'Missing OpenLIT URL: Provide as arg or set OPENLIT_URL env var.'
334
+ )
335
+
336
+ # Validate and set the API key
337
+ api_key = get_env_variable(
338
+ 'OPENLIT_API_KEY',
339
+ api_key,
340
+ 'Missing API key: Provide as arg or set OPENLIT_API_KEY env var.'
341
+ )
342
+
343
+ # Construct the API endpoint
344
+ endpoint = url + "/api/prompt/get-compiled"
345
+
346
+ # Prepare the payload
347
+ payload = {
348
+ 'name': name,
349
+ 'promptId': prompt_id,
350
+ 'version': version,
351
+ 'shouldCompile': should_compile,
352
+ 'variables': variables,
353
+ 'metaProperties': meta_properties
354
+ }
355
+
356
+ # Remove None values from payload
357
+ payload = {k: v for k, v in payload.items() if v is not None}
358
+
359
+ # Prepare headers
360
+ headers = {
361
+ 'Authorization': f'Bearer {api_key}',
362
+ 'Content-Type': 'application/json'
363
+ }
364
+
365
+ try:
366
+ # Make the POST request to the API with headers
367
+ response = requests.post(endpoint, json=payload, headers=headers, timeout=120)
368
+
369
+ # Check if the response is successful
370
+ response.raise_for_status()
371
+
372
+ # Return the JSON response
373
+ return response.json()
374
+ except requests.RequestException as error:
375
+ print(f"Error fetching prompt: {error}")
376
+ return None
377
+
378
+ def get_secrets(url=None, api_key=None, key=None, tags=None, should_set_env=None):
379
+ """
380
+ Retrieve & returns the secrets from OpenLIT Vault & sets all to env is should_set_env is True
381
+ """
382
+
383
+ # Validate and set the base URL
384
+ url = get_env_variable(
385
+ 'OPENLIT_URL',
386
+ url,
387
+ 'Missing OpenLIT URL: Provide as arg or set OPENLIT_URL env var.'
388
+ )
389
+
390
+ # Validate and set the API key
391
+ api_key = get_env_variable(
392
+ 'OPENLIT_API_KEY',
393
+ api_key,
394
+ 'Missing API key: Provide as arg or set OPENLIT_API_KEY env var.'
395
+ )
396
+
397
+ # Construct the API endpoint
398
+ endpoint = url + "/api/vault/get-secrets"
399
+
400
+ # Prepare the payload
401
+ payload = {
402
+ 'key': key,
403
+ 'tags': tags,
404
+ }
405
+
406
+ # Remove None values from payload
407
+ payload = {k: v for k, v in payload.items() if v is not None}
408
+
409
+ # Prepare headers
410
+ headers = {
411
+ 'Authorization': f'Bearer {api_key}',
412
+ 'Content-Type': 'application/json'
413
+ }
414
+
415
+ try:
416
+ # Make the POST request to the API with headers
417
+ response = requests.post(endpoint, json=payload, headers=headers, timeout=120)
418
+
419
+ # Check if the response is successful
420
+ response.raise_for_status()
421
+
422
+ # Return the JSON response
423
+ vault_response = response.json()
424
+
425
+ res = vault_response.get('res', [])
426
+
427
+ if should_set_env is True:
428
+ for token, value in res.items():
429
+ os.environ[token] = str(value)
430
+ return vault_response
431
+ except requests.RequestException as error:
432
+ print(f"Error fetching secrets: {error}")
433
+ return None
319
434
 
320
435
  def trace(wrapped):
321
436
  """
@@ -0,0 +1,12 @@
1
+ """
2
+ openlit.evals
3
+
4
+ This module provides a set of classes for analyzing text for various types of
5
+ content-based vulnerabilities,
6
+ such as Hallucination, Bias, and Toxicity detection.
7
+ """
8
+
9
+ from openlit.evals.hallucination import Hallucination
10
+ from openlit.evals.bias_detection import BiasDetector
11
+ from openlit.evals.toxicity import ToxicityDetector
12
+ from openlit.evals.all import All