openlit 1.24.1__py3-none-any.whl → 1.25.0__py3-none-any.whl
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/__init__.py
CHANGED
@@ -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.
|
@@ -316,6 +318,73 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
316
318
|
except Exception as e:
|
317
319
|
logger.error("Error during openLIT initialization: %s", e)
|
318
320
|
|
321
|
+
def get_prompt(url=None, name=None, api_key=None, prompt_id=None,
|
322
|
+
version=None, should_compile=None, variables=None, meta_properties=None):
|
323
|
+
"""
|
324
|
+
Retrieve and returns the prompt from OpenLIT Prompt Hub
|
325
|
+
"""
|
326
|
+
|
327
|
+
def get_env_variable(name, arg_value, error_message):
|
328
|
+
"""
|
329
|
+
Retrieve an environment variable if the argument is not provided
|
330
|
+
and raise an error if both are not set.
|
331
|
+
"""
|
332
|
+
if arg_value is not None:
|
333
|
+
return arg_value
|
334
|
+
value = os.getenv(name)
|
335
|
+
if not value:
|
336
|
+
logging.error(error_message)
|
337
|
+
raise RuntimeError(error_message)
|
338
|
+
return value
|
339
|
+
|
340
|
+
# Validate and set the base URL
|
341
|
+
url = get_env_variable(
|
342
|
+
'OPENLIT_URL',
|
343
|
+
url,
|
344
|
+
'Missing OpenLIT URL: Provide as arg or set OPENLIT_URL env var.'
|
345
|
+
)
|
346
|
+
|
347
|
+
# Validate and set the API key
|
348
|
+
api_key = get_env_variable(
|
349
|
+
'OPENLIT_API_KEY',
|
350
|
+
api_key,
|
351
|
+
'Missing API key: Provide as arg or set OPENLIT_API_KEY env var.'
|
352
|
+
)
|
353
|
+
|
354
|
+
# Construct the API endpoint
|
355
|
+
endpoint = url + "/api/prompt/get-compiled"
|
356
|
+
|
357
|
+
# Prepare the payload
|
358
|
+
payload = {
|
359
|
+
'name': name,
|
360
|
+
'promptId': prompt_id,
|
361
|
+
'version': version,
|
362
|
+
'shouldCompile': should_compile,
|
363
|
+
'variables': variables,
|
364
|
+
'metaProperties': meta_properties
|
365
|
+
}
|
366
|
+
|
367
|
+
# Remove None values from payload
|
368
|
+
payload = {k: v for k, v in payload.items() if v is not None}
|
369
|
+
|
370
|
+
# Prepare headers
|
371
|
+
headers = {
|
372
|
+
'Authorization': f'Bearer {api_key}',
|
373
|
+
'Content-Type': 'application/json'
|
374
|
+
}
|
375
|
+
|
376
|
+
try:
|
377
|
+
# Make the POST request to the API with headers
|
378
|
+
response = requests.post(endpoint, json=payload, headers=headers, timeout=120)
|
379
|
+
|
380
|
+
# Check if the response is successful
|
381
|
+
response.raise_for_status()
|
382
|
+
|
383
|
+
# Return the JSON response
|
384
|
+
return response.json()
|
385
|
+
except requests.RequestException as error:
|
386
|
+
print(f"Error fetching prompt: {error}")
|
387
|
+
return None
|
319
388
|
|
320
389
|
def trace(wrapped):
|
321
390
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.25.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,6 +12,7 @@ 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
|
15
16
|
Requires-Dist: boto3 (>=1.34.0,<2.0.0)
|
16
17
|
Requires-Dist: botocore (>=1.34.0,<2.0.0)
|
17
18
|
Requires-Dist: gpustat (>=1.1.1,<2.0.0)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
openlit/__helpers.py,sha256=lrn4PBs9owDudiCY2NBoVbAi7AU_HtUpyOj0oqPBsPY,5545
|
2
|
-
openlit/__init__.py,sha256=
|
2
|
+
openlit/__init__.py,sha256=1odqNlSQmcvrkf9IMPGuM8w0wCj3NneF_0lqq2VxS0s,18083
|
3
3
|
openlit/instrumentation/anthropic/__init__.py,sha256=oaU53BOPyfUKbEzYvLr1DPymDluurSnwo4Hernf2XdU,1955
|
4
4
|
openlit/instrumentation/anthropic/anthropic.py,sha256=y7CEGhKOGHWt8G_5Phr4qPJTfPGRJIAr9Yk6nM3CcvM,16775
|
5
5
|
openlit/instrumentation/anthropic/async_anthropic.py,sha256=Zz1KRKIG9wGn0quOoLvjORC-49IvHQpJ6GBdB-4PfCQ,16816
|
@@ -59,7 +59,7 @@ openlit/instrumentation/vllm/vllm.py,sha256=lDzM7F5pgxvh8nKL0dcKB4TD0Mc9wXOWeXOs
|
|
59
59
|
openlit/otel/metrics.py,sha256=-PntPlH4xOBXgnDqgJp3iA7rh1TWxM7PudGnb0GxVDA,4298
|
60
60
|
openlit/otel/tracing.py,sha256=2kSj7n7uXSkRegcGFDC8IbnDOxqWTA8dGODs__Yn_yA,3719
|
61
61
|
openlit/semcov/__init__.py,sha256=wpAarrnkndbgvP8VSudi8IRInYtD02hkewqjyiC0dMk,7614
|
62
|
-
openlit-1.
|
63
|
-
openlit-1.
|
64
|
-
openlit-1.
|
65
|
-
openlit-1.
|
62
|
+
openlit-1.25.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
63
|
+
openlit-1.25.0.dist-info/METADATA,sha256=Ak-Pi2g2GMv7O0UV2O7BLnw3IdPlzOzVITQBN_vDOf0,15761
|
64
|
+
openlit-1.25.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
65
|
+
openlit-1.25.0.dist-info/RECORD,,
|
File without changes
|