openlit 1.34.4__tar.gz → 1.34.5__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 (140) hide show
  1. {openlit-1.34.4 → openlit-1.34.5}/PKG-INFO +1 -1
  2. {openlit-1.34.4 → openlit-1.34.5}/pyproject.toml +1 -1
  3. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/google_ai_studio/__init__.py +2 -4
  4. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -6
  5. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -6
  6. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/google_ai_studio/utils.py +1 -2
  7. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/together/__init__.py +3 -5
  8. openlit-1.34.5/src/openlit/instrumentation/together/async_together.py +194 -0
  9. openlit-1.34.5/src/openlit/instrumentation/together/together.py +194 -0
  10. openlit-1.34.5/src/openlit/instrumentation/together/utils.py +320 -0
  11. openlit-1.34.4/src/openlit/instrumentation/together/async_together.py +0 -600
  12. openlit-1.34.4/src/openlit/instrumentation/together/together.py +0 -600
  13. {openlit-1.34.4 → openlit-1.34.5}/LICENSE +0 -0
  14. {openlit-1.34.4 → openlit-1.34.5}/README.md +0 -0
  15. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/__helpers.py +0 -0
  16. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/__init__.py +0 -0
  17. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/__init__.py +0 -0
  18. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/all.py +0 -0
  19. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/bias_detection.py +0 -0
  20. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/hallucination.py +0 -0
  21. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/toxicity.py +0 -0
  22. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/evals/utils.py +0 -0
  23. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/__init__.py +0 -0
  24. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/all.py +0 -0
  25. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/prompt_injection.py +0 -0
  26. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/restrict_topic.py +0 -0
  27. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/sensitive_topic.py +0 -0
  28. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/guard/utils.py +0 -0
  29. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ag2/__init__.py +0 -0
  30. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ag2/ag2.py +0 -0
  31. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ai21/__init__.py +0 -0
  32. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ai21/ai21.py +0 -0
  33. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ai21/async_ai21.py +0 -0
  34. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ai21/utils.py +0 -0
  35. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
  36. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
  37. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
  38. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/anthropic/utils.py +0 -0
  39. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/assemblyai/__init__.py +0 -0
  40. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -0
  41. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/astra/__init__.py +0 -0
  42. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/astra/astra.py +0 -0
  43. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/astra/async_astra.py +0 -0
  44. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/astra/utils.py +0 -0
  45. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
  46. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
  47. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
  48. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
  49. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
  50. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
  51. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/bedrock/utils.py +0 -0
  52. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/chroma/__init__.py +0 -0
  53. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/chroma/chroma.py +0 -0
  54. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/cohere/__init__.py +0 -0
  55. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/cohere/async_cohere.py +0 -0
  56. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/cohere/cohere.py +0 -0
  57. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
  58. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
  59. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
  60. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
  61. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
  62. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/crewai/__init__.py +0 -0
  63. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/crewai/crewai.py +0 -0
  64. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
  65. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
  66. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
  67. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
  68. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
  69. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
  70. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
  71. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
  72. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
  73. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
  74. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
  75. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/gpu/__init__.py +0 -0
  76. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/groq/__init__.py +0 -0
  77. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/groq/async_groq.py +0 -0
  78. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/groq/groq.py +0 -0
  79. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/haystack/__init__.py +0 -0
  80. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/haystack/haystack.py +0 -0
  81. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/julep/__init__.py +0 -0
  82. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/julep/async_julep.py +0 -0
  83. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/julep/julep.py +0 -0
  84. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/langchain/__init__.py +0 -0
  85. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
  86. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/langchain/langchain.py +0 -0
  87. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/letta/__init__.py +0 -0
  88. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/letta/letta.py +0 -0
  89. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/litellm/__init__.py +0 -0
  90. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
  91. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/litellm/litellm.py +0 -0
  92. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
  93. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
  94. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/mem0/__init__.py +0 -0
  95. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/mem0/mem0.py +0 -0
  96. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/milvus/__init__.py +0 -0
  97. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/milvus/milvus.py +0 -0
  98. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/mistral/__init__.py +0 -0
  99. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
  100. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/mistral/mistral.py +0 -0
  101. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/multion/__init__.py +0 -0
  102. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/multion/async_multion.py +0 -0
  103. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/multion/multion.py +0 -0
  104. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ollama/__init__.py +0 -0
  105. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
  106. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ollama/ollama.py +0 -0
  107. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/ollama/utils.py +0 -0
  108. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/openai/__init__.py +0 -0
  109. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/openai/async_openai.py +0 -0
  110. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/openai/openai.py +0 -0
  111. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
  112. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
  113. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/phidata/__init__.py +0 -0
  114. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/phidata/phidata.py +0 -0
  115. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
  116. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
  117. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/premai/__init__.py +0 -0
  118. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/premai/premai.py +0 -0
  119. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
  120. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
  121. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
  122. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
  123. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
  124. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
  125. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/reka/__init__.py +0 -0
  126. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/reka/async_reka.py +0 -0
  127. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/reka/reka.py +0 -0
  128. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/transformers/__init__.py +0 -0
  129. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/transformers/transformers.py +0 -0
  130. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/transformers/utils.py +0 -0
  131. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
  132. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
  133. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
  134. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vllm/__init__.py +0 -0
  135. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vllm/utils.py +0 -0
  136. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/instrumentation/vllm/vllm.py +0 -0
  137. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/otel/events.py +0 -0
  138. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/otel/metrics.py +0 -0
  139. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/otel/tracing.py +0 -0
  140. {openlit-1.34.4 → openlit-1.34.5}/src/openlit/semcov/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openlit
3
- Version: 1.34.4
3
+ Version: 1.34.5
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
  License: Apache-2.0
6
6
  Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openlit"
3
- version = "1.34.4"
3
+ version = "1.34.5"
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
  license = "Apache-2.0"
@@ -1,4 +1,3 @@
1
- # pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
2
1
  """Initializer of Auto Instrumentation of Google AI Studio Functions"""
3
2
 
4
3
  from typing import Collection
@@ -25,8 +24,8 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
25
24
  return _instruments
26
25
 
27
26
  def _instrument(self, **kwargs):
28
- application_name = kwargs.get("application_name", "default_application")
29
- environment = kwargs.get("environment", "default_environment")
27
+ application_name = kwargs.get("application_name", "default")
28
+ environment = kwargs.get("environment", "default")
30
29
  tracer = kwargs.get("tracer")
31
30
  metrics = kwargs.get("metrics_dict")
32
31
  pricing_info = kwargs.get("pricing_info", {})
@@ -67,5 +66,4 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
67
66
  )
68
67
 
69
68
  def _uninstrument(self, **kwargs):
70
- # Proper uninstrumentation logic to revert patched methods
71
69
  pass
@@ -2,7 +2,6 @@
2
2
  Module for monitoring Google AI Studio API calls.
3
3
  """
4
4
 
5
- import logging
6
5
  import time
7
6
  from opentelemetry.trace import SpanKind
8
7
  from openlit.__helpers import (
@@ -16,9 +15,6 @@ from openlit.instrumentation.google_ai_studio.utils import (
16
15
  )
17
16
  from openlit.semcov import SemanticConvention
18
17
 
19
- # Initialize logger for logging potential issues and operations
20
- logger = logging.getLogger(__name__)
21
-
22
18
  def async_generate(version, environment, application_name,
23
19
  tracer, pricing_info, capture_message_content, metrics, disable_metrics):
24
20
  """
@@ -61,7 +57,6 @@ def async_generate(version, environment, application_name,
61
57
 
62
58
  except Exception as e:
63
59
  handle_exception(span, e)
64
- logger.error("Error in trace creation: %s", e)
65
60
 
66
61
  # Return original response
67
62
  return response
@@ -144,7 +139,6 @@ def async_generate_stream(version, environment, application_name,
144
139
 
145
140
  except Exception as e:
146
141
  handle_exception(self._span, e)
147
- logger.error("Error in trace creation: %s", e)
148
142
  raise
149
143
 
150
144
  async def wrapper(wrapped, instance, args, kwargs):
@@ -2,7 +2,6 @@
2
2
  Module for monitoring Google AI Studio API calls.
3
3
  """
4
4
 
5
- import logging
6
5
  import time
7
6
  from opentelemetry.trace import SpanKind
8
7
  from openlit.__helpers import (
@@ -16,9 +15,6 @@ from openlit.instrumentation.google_ai_studio.utils import (
16
15
  )
17
16
  from openlit.semcov import SemanticConvention
18
17
 
19
- # Initialize logger for logging potential issues and operations
20
- logger = logging.getLogger(__name__)
21
-
22
18
  def generate(version, environment, application_name,
23
19
  tracer, pricing_info, capture_message_content, metrics, disable_metrics):
24
20
  """
@@ -61,7 +57,6 @@ def generate(version, environment, application_name,
61
57
 
62
58
  except Exception as e:
63
59
  handle_exception(span, e)
64
- logger.error("Error in trace creation: %s", e)
65
60
 
66
61
  # Return original response
67
62
  return response
@@ -144,7 +139,6 @@ def generate_stream(version, environment, application_name,
144
139
 
145
140
  except Exception as e:
146
141
  handle_exception(self._span, e)
147
- logger.error("Error in trace creation: %s", e)
148
142
  raise
149
143
 
150
144
  def wrapper(wrapped, instance, args, kwargs):
@@ -15,8 +15,7 @@ from openlit.semcov import SemanticConvention
15
15
 
16
16
  def format_content(messages):
17
17
  """
18
- Process a list of messages to extract content, categorize them by role,
19
- and concatenate all 'content' fields into a single string with role: content format.
18
+ Process a list of messages to extract content.
20
19
  """
21
20
 
22
21
  formatted_messages = []
@@ -1,4 +1,3 @@
1
- # pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
2
1
  """Initializer of Auto Instrumentation of Together AI Functions"""
3
2
 
4
3
  from typing import Collection
@@ -17,15 +16,15 @@ _instruments = ("together >= 1.3.5",)
17
16
 
18
17
  class TogetherInstrumentor(BaseInstrumentor):
19
18
  """
20
- An instrumentor for Together's client library.
19
+ An instrumentor for Together client library.
21
20
  """
22
21
 
23
22
  def instrumentation_dependencies(self) -> Collection[str]:
24
23
  return _instruments
25
24
 
26
25
  def _instrument(self, **kwargs):
27
- application_name = kwargs.get("application_name", "default_application")
28
- environment = kwargs.get("environment", "default_environment")
26
+ application_name = kwargs.get("application_name", "default")
27
+ environment = kwargs.get("environment", "default")
29
28
  tracer = kwargs.get("tracer")
30
29
  metrics = kwargs.get("metrics_dict")
31
30
  pricing_info = kwargs.get("pricing_info", {})
@@ -66,5 +65,4 @@ class TogetherInstrumentor(BaseInstrumentor):
66
65
  )
67
66
 
68
67
  def _uninstrument(self, **kwargs):
69
- # Proper uninstrumentation logic to revert patched methods
70
68
  pass
@@ -0,0 +1,194 @@
1
+ """
2
+ Module for monitoring Together API calls.
3
+ """
4
+
5
+ import time
6
+ from opentelemetry.trace import SpanKind
7
+ from openlit.__helpers import (
8
+ handle_exception,
9
+ set_server_address_and_port
10
+ )
11
+ from openlit.instrumentation.together.utils import (
12
+ process_chat_response,
13
+ process_chunk,
14
+ process_streaming_chat_response,
15
+ process_image_response
16
+ )
17
+ from openlit.semcov import SemanticConvention
18
+
19
+ def async_completion(version, environment, application_name,
20
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
21
+ """
22
+ Generates a telemetry wrapper for GenAI function call
23
+ """
24
+
25
+ class TracedAsyncStream:
26
+ """
27
+ Wrapper for streaming responses to collect telemetry.
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ wrapped,
33
+ span,
34
+ span_name,
35
+ kwargs,
36
+ server_address,
37
+ server_port,
38
+ **args,
39
+ ):
40
+ self.__wrapped__ = wrapped
41
+ self._span = span
42
+ self._span_name = span_name
43
+ self._llmresponse = ""
44
+ self._response_id = ""
45
+ self._response_model = ""
46
+ self._input_tokens = 0
47
+ self._output_tokens = 0
48
+ self._finish_reason = ""
49
+ self._tools = None
50
+ self._args = args
51
+ self._kwargs = kwargs
52
+ self._start_time = time.time()
53
+ self._end_time = None
54
+ self._timestamps = []
55
+ self._ttft = 0
56
+ self._tbt = 0
57
+ self._server_address = server_address
58
+ self._server_port = server_port
59
+
60
+ async def __aenter__(self):
61
+ await self.__wrapped__.__aenter__()
62
+ return self
63
+
64
+ async def __aexit__(self, exc_type, exc_value, traceback):
65
+ await self.__wrapped__.__aexit__(exc_type, exc_value, traceback)
66
+
67
+ def __aiter__(self):
68
+ return self
69
+
70
+ async def __getattr__(self, name):
71
+ """Delegate attribute access to the wrapped object."""
72
+ return getattr(await self.__wrapped__, name)
73
+
74
+ async def __anext__(self):
75
+ try:
76
+ chunk = await self.__wrapped__.__anext__()
77
+ process_chunk(self, chunk)
78
+ return chunk
79
+ except StopIteration:
80
+ try:
81
+ with tracer.start_as_current_span(self._span_name, kind= SpanKind.CLIENT) as self._span:
82
+ process_streaming_chat_response(
83
+ self,
84
+ pricing_info=pricing_info,
85
+ environment=environment,
86
+ application_name=application_name,
87
+ metrics=metrics,
88
+ capture_message_content=capture_message_content,
89
+ disable_metrics=disable_metrics,
90
+ version=version
91
+ )
92
+
93
+ except Exception as e:
94
+ handle_exception(self._span, e)
95
+
96
+ raise
97
+
98
+ async def wrapper(wrapped, instance, args, kwargs):
99
+ """
100
+ Wraps the GenAI function call.
101
+ """
102
+
103
+ # Check if streaming is enabled for the API call
104
+ streaming = kwargs.get("stream", False)
105
+
106
+ server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
107
+ request_model = kwargs.get("model", "gpt-4o")
108
+
109
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
110
+
111
+ if streaming:
112
+ # Special handling for streaming response to accommodate the nature of data flow
113
+ awaited_wrapped = await wrapped(*args, **kwargs)
114
+ span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
115
+ return TracedAsyncStream(awaited_wrapped, span, span_name, kwargs, server_address, server_port)
116
+
117
+ # Handling for non-streaming responses
118
+ else:
119
+ with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
120
+ start_time = time.time()
121
+ response = await wrapped(*args, **kwargs)
122
+
123
+ try:
124
+ response = process_chat_response(
125
+ response=response,
126
+ request_model=request_model,
127
+ pricing_info=pricing_info,
128
+ server_port=server_port,
129
+ server_address=server_address,
130
+ environment=environment,
131
+ application_name=application_name,
132
+ metrics=metrics,
133
+ start_time=start_time,
134
+ span=span,
135
+ capture_message_content=capture_message_content,
136
+ disable_metrics=disable_metrics,
137
+ version=version,
138
+ **kwargs
139
+ )
140
+
141
+ except Exception as e:
142
+ handle_exception(span, e)
143
+
144
+ return response
145
+
146
+ return wrapper
147
+
148
+ def async_image_generate(version, environment, application_name,
149
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
150
+ """
151
+ Generates a telemetry wrapper for GenAI function call
152
+ """
153
+
154
+ async def wrapper(wrapped, instance, args, kwargs):
155
+ """
156
+ Wraps the GenAI function call.
157
+ """
158
+
159
+ server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
160
+ request_model = kwargs.get("model", "dall-e-2")
161
+
162
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
163
+
164
+ with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
165
+ start_time = time.time()
166
+ response = await wrapped(*args, **kwargs)
167
+ end_time = time.time()
168
+
169
+ try:
170
+ response = process_image_response(
171
+ response=response,
172
+ request_model=request_model,
173
+ pricing_info=pricing_info,
174
+ server_address=server_address,
175
+ server_port=server_port,
176
+ environment=environment,
177
+ application_name=application_name,
178
+ metrics=metrics,
179
+ start_time=start_time,
180
+ end_time=end_time,
181
+ span=span,
182
+ capture_message_content=capture_message_content,
183
+ disable_metrics=disable_metrics,
184
+ version=version,
185
+ **kwargs
186
+ )
187
+
188
+ return response
189
+
190
+ except Exception as e:
191
+ handle_exception(span, e)
192
+ return response
193
+
194
+ return wrapper
@@ -0,0 +1,194 @@
1
+ """
2
+ Module for monitoring Together API calls.
3
+ """
4
+
5
+ import time
6
+ from opentelemetry.trace import SpanKind
7
+ from openlit.__helpers import (
8
+ handle_exception,
9
+ set_server_address_and_port
10
+ )
11
+ from openlit.instrumentation.together.utils import (
12
+ process_chat_response,
13
+ process_chunk,
14
+ process_streaming_chat_response,
15
+ process_image_response
16
+ )
17
+ from openlit.semcov import SemanticConvention
18
+
19
+ def completion(version, environment, application_name,
20
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
21
+ """
22
+ Generates a telemetry wrapper for GenAI function call
23
+ """
24
+
25
+ class TracedSyncStream:
26
+ """
27
+ Wrapper for streaming responses to collect telemetry.
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ wrapped,
33
+ span,
34
+ span_name,
35
+ kwargs,
36
+ server_address,
37
+ server_port,
38
+ **args,
39
+ ):
40
+ self.__wrapped__ = wrapped
41
+ self._span = span
42
+ self._span_name = span_name
43
+ self._llmresponse = ""
44
+ self._response_id = ""
45
+ self._response_model = ""
46
+ self._input_tokens = 0
47
+ self._output_tokens = 0
48
+ self._finish_reason = ""
49
+ self._tools = None
50
+ self._args = args
51
+ self._kwargs = kwargs
52
+ self._start_time = time.time()
53
+ self._end_time = None
54
+ self._timestamps = []
55
+ self._ttft = 0
56
+ self._tbt = 0
57
+ self._server_address = server_address
58
+ self._server_port = server_port
59
+
60
+ def __enter__(self):
61
+ self.__wrapped__.__enter__()
62
+ return self
63
+
64
+ def __exit__(self, exc_type, exc_value, traceback):
65
+ self.__wrapped__.__exit__(exc_type, exc_value, traceback)
66
+
67
+ def __iter__(self):
68
+ return self
69
+
70
+ def __getattr__(self, name):
71
+ """Delegate attribute access to the wrapped object."""
72
+ return getattr(self.__wrapped__, name)
73
+
74
+ def __next__(self):
75
+ try:
76
+ chunk = self.__wrapped__.__next__()
77
+ process_chunk(self, chunk)
78
+ return chunk
79
+ except StopIteration:
80
+ try:
81
+ with tracer.start_as_current_span(self._span_name, kind= SpanKind.CLIENT) as self._span:
82
+ process_streaming_chat_response(
83
+ self,
84
+ pricing_info=pricing_info,
85
+ environment=environment,
86
+ application_name=application_name,
87
+ metrics=metrics,
88
+ capture_message_content=capture_message_content,
89
+ disable_metrics=disable_metrics,
90
+ version=version
91
+ )
92
+
93
+ except Exception as e:
94
+ handle_exception(self._span, e)
95
+
96
+ raise
97
+
98
+ def wrapper(wrapped, instance, args, kwargs):
99
+ """
100
+ Wraps the GenAI function call.
101
+ """
102
+
103
+ # Check if streaming is enabled for the API call
104
+ streaming = kwargs.get("stream", False)
105
+
106
+ server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
107
+ request_model = kwargs.get("model", "gpt-4o")
108
+
109
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
110
+
111
+ if streaming:
112
+ # Special handling for streaming response to accommodate the nature of data flow
113
+ awaited_wrapped = wrapped(*args, **kwargs)
114
+ span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
115
+ return TracedSyncStream(awaited_wrapped, span, span_name, kwargs, server_address, server_port)
116
+
117
+ # Handling for non-streaming responses
118
+ else:
119
+ with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
120
+ start_time = time.time()
121
+ response = wrapped(*args, **kwargs)
122
+
123
+ try:
124
+ response = process_chat_response(
125
+ response=response,
126
+ request_model=request_model,
127
+ pricing_info=pricing_info,
128
+ server_port=server_port,
129
+ server_address=server_address,
130
+ environment=environment,
131
+ application_name=application_name,
132
+ metrics=metrics,
133
+ start_time=start_time,
134
+ span=span,
135
+ capture_message_content=capture_message_content,
136
+ disable_metrics=disable_metrics,
137
+ version=version,
138
+ **kwargs
139
+ )
140
+
141
+ except Exception as e:
142
+ handle_exception(span, e)
143
+
144
+ return response
145
+
146
+ return wrapper
147
+
148
+ def image_generate(version, environment, application_name,
149
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
150
+ """
151
+ Generates a telemetry wrapper for GenAI function call
152
+ """
153
+
154
+ def wrapper(wrapped, instance, args, kwargs):
155
+ """
156
+ Wraps the GenAI function call.
157
+ """
158
+
159
+ server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
160
+ request_model = kwargs.get("model", "dall-e-2")
161
+
162
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
163
+
164
+ with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
165
+ start_time = time.time()
166
+ response = wrapped(*args, **kwargs)
167
+ end_time = time.time()
168
+
169
+ try:
170
+ response = process_image_response(
171
+ response=response,
172
+ request_model=request_model,
173
+ pricing_info=pricing_info,
174
+ server_address=server_address,
175
+ server_port=server_port,
176
+ environment=environment,
177
+ application_name=application_name,
178
+ metrics=metrics,
179
+ start_time=start_time,
180
+ end_time=end_time,
181
+ span=span,
182
+ capture_message_content=capture_message_content,
183
+ disable_metrics=disable_metrics,
184
+ version=version,
185
+ **kwargs
186
+ )
187
+
188
+ return response
189
+
190
+ except Exception as e:
191
+ handle_exception(span, e)
192
+ return response
193
+
194
+ return wrapper