openlit 1.22.3__py3-none-any.whl → 1.23.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.
@@ -484,9 +484,12 @@ def chat(gen_ai_endpoint, version, environment, application_name,
484
484
  input_tokens = response.response_metadata.get("prompt_eval_count", 0)
485
485
  output_tokens = response.response_metadata.get("eval_count", 0)
486
486
 
487
+ prompt = "" if isinstance(args[0], list) else args[0]
488
+ model = getattr(instance, 'model_name', getattr(instance, 'model', 'gpt-4'))
489
+
487
490
  # Calculate cost of the operation
488
491
  cost = get_chat_model_cost(
489
- str(getattr(instance, 'model')),
492
+ model,
490
493
  pricing_info, input_tokens, output_tokens
491
494
  )
492
495
 
@@ -502,15 +505,13 @@ def chat(gen_ai_endpoint, version, environment, application_name,
502
505
  span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
503
506
  application_name)
504
507
  span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
505
- str(getattr(instance, 'model')))
508
+ model)
506
509
  span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
507
- str(getattr(instance, 'temperature')))
510
+ str(getattr(instance, 'temperature', 1)))
508
511
  span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
509
- str(getattr(instance, 'top_k')))
512
+ str(getattr(instance, 'top_k', 1)))
510
513
  span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
511
- str(getattr(instance, 'top_p')))
512
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
513
- [response.response_metadata["done_reason"]])
514
+ str(getattr(instance, 'top_p', 1)))
514
515
  span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
515
516
  False)
516
517
  span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
@@ -525,7 +526,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
525
526
  span.add_event(
526
527
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
527
528
  attributes={
528
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: args[0],
529
+ SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
529
530
  },
530
531
  )
531
532
  span.add_event(
@@ -550,7 +551,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
550
551
  SemanticConvetion.GEN_AI_TYPE:
551
552
  SemanticConvetion.GEN_AI_TYPE_CHAT,
552
553
  SemanticConvetion.GEN_AI_REQUEST_MODEL:
553
- str(getattr(instance, 'model'))
554
+ model
554
555
  }
555
556
 
556
557
  metrics["genai_requests"].add(1, attributes)
@@ -619,8 +620,8 @@ def achat(gen_ai_endpoint, version, environment, application_name,
619
620
  response = await wrapped(*args, **kwargs)
620
621
 
621
622
  try:
622
- input_tokens = response.response_metadata["prompt_eval_count"] or 0
623
- output_tokens = response.response_metadata["eval_count"] or 0
623
+ input_tokens = response.response_metadata.get("prompt_eval_count", 0)
624
+ output_tokens = response.response_metadata.get("eval_count", 0)
624
625
 
625
626
  # Calculate cost of the operation
626
627
  cost = get_chat_model_cost(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openlit
3
- Version: 1.22.3
3
+ Version: 1.23.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
@@ -15,10 +15,10 @@ Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Dist: boto3 (>=1.34.0,<2.0.0)
16
16
  Requires-Dist: botocore (>=1.34.0,<2.0.0)
17
17
  Requires-Dist: gpustat (>=1.1.1,<2.0.0)
18
- Requires-Dist: opentelemetry-api (>=1.24.0,<2.0.0)
19
- Requires-Dist: opentelemetry-exporter-otlp (>=1.24.0,<2.0.0)
20
- Requires-Dist: opentelemetry-instrumentation (>=0.45b0,<0.46)
21
- Requires-Dist: opentelemetry-sdk (>=1.24.0,<2.0.0)
18
+ Requires-Dist: opentelemetry-api (>=1.27.0,<2.0.0)
19
+ Requires-Dist: opentelemetry-exporter-otlp (>=1.27.0,<2.0.0)
20
+ Requires-Dist: opentelemetry-instrumentation (>=0.48b0,<0.49)
21
+ Requires-Dist: opentelemetry-sdk (>=1.27.0,<2.0.0)
22
22
  Requires-Dist: requests (>=2.26.0,<3.0.0)
23
23
  Requires-Dist: schedule (>=1.2.2,<2.0.0)
24
24
  Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
@@ -29,7 +29,7 @@ openlit/instrumentation/groq/groq.py,sha256=m4gFPbYzjUUIgjXZ0Alu2Zy1HcO5takCFA2X
29
29
  openlit/instrumentation/haystack/__init__.py,sha256=QK6XxxZUHX8vMv2Crk7rNBOc64iOOBLhJGL_lPlAZ8s,1758
30
30
  openlit/instrumentation/haystack/haystack.py,sha256=oQIZiDhdp3gnJnhYQ1OouJMc9YT0pQ-_31cmNuopa68,3891
31
31
  openlit/instrumentation/langchain/__init__.py,sha256=0AI2Dnqw81IcJw3jM--gGkv_HRh2GtosOGJjvOpw7Zk,3431
32
- openlit/instrumentation/langchain/langchain.py,sha256=s8vZZxhHfDANeisqIyNvsd5BPcHbc-LNFKDXS5hiEfA,35734
32
+ openlit/instrumentation/langchain/langchain.py,sha256=lWQiPSVMXg6laEhyr7zvmP6j2bkwlH5yPmd4Gc7_0qk,35667
33
33
  openlit/instrumentation/llamaindex/__init__.py,sha256=vPtK65G6b-TwJERowVRUVl7f_nBSlFdwPBtpg8dOGos,1977
34
34
  openlit/instrumentation/llamaindex/llamaindex.py,sha256=uiIigbwhonSbJWA7LpgOVI1R4kxxPODS1K5wyHIQ4hM,4048
35
35
  openlit/instrumentation/milvus/__init__.py,sha256=qi1yfmMrvkDtnrN_6toW8qC9BRL78bq7ayWpObJ8Bq4,2961
@@ -59,7 +59,7 @@ openlit/instrumentation/vllm/vllm.py,sha256=lDzM7F5pgxvh8nKL0dcKB4TD0Mc9wXOWeXOs
59
59
  openlit/otel/metrics.py,sha256=O7NoaDz0bY19mqpE4-0PcKwEe-B-iJFRgOCaanAuZAc,4291
60
60
  openlit/otel/tracing.py,sha256=vL1ifMbARPBpqK--yXYsCM6y5dSu5LFIKqkhZXtYmUc,3712
61
61
  openlit/semcov/__init__.py,sha256=wpAarrnkndbgvP8VSudi8IRInYtD02hkewqjyiC0dMk,7614
62
- openlit-1.22.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
- openlit-1.22.3.dist-info/METADATA,sha256=0F7-sbMG7ctUtCaCNZsxsjUzSZJeqnfgXjzFc7D8Ico,15710
64
- openlit-1.22.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
- openlit-1.22.3.dist-info/RECORD,,
62
+ openlit-1.23.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
+ openlit-1.23.0.dist-info/METADATA,sha256=HY5inp8L68KmgW1pzZ44ozM4AZEw0j7CtQW88cdk71E,15710
64
+ openlit-1.23.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ openlit-1.23.0.dist-info/RECORD,,