openlit 1.34.3__tar.gz → 1.34.4__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.34.3 → openlit-1.34.4}/PKG-INFO +1 -1
- {openlit-1.34.3 → openlit-1.34.4}/pyproject.toml +1 -1
- openlit-1.34.4/src/openlit/instrumentation/ai21/__init__.py +66 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ai21/ai21.py +58 -51
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ai21/async_ai21.py +58 -51
- openlit-1.34.4/src/openlit/instrumentation/ai21/utils.py +300 -0
- openlit-1.34.3/src/openlit/instrumentation/ai21/__init__.py +0 -67
- openlit-1.34.3/src/openlit/instrumentation/ai21/utils.py +0 -409
- {openlit-1.34.3 → openlit-1.34.4}/LICENSE +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/README.md +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/__helpers.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/all.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/bias_detection.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/hallucination.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/toxicity.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/evals/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/all.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/prompt_injection.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/restrict_topic.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/sensitive_topic.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/guard/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ag2/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ag2/ag2.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/anthropic/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/assemblyai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/astra/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/astra/astra.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/astra/async_astra.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/astra/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/bedrock/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/cohere/async_cohere.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/crewai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/crewai/crewai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/google_ai_studio/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/julep/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/julep/async_julep.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/julep/julep.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/letta/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/letta/letta.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/litellm/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/litellm/litellm.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/mem0/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/mem0/mem0.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/multion/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/multion/async_multion.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/multion/multion.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/ollama/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/phidata/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/phidata/phidata.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/premai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/premai/premai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/reka/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/reka/async_reka.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/reka/reka.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/together/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/together/async_together.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/together/together.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/transformers/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vllm/utils.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/otel/events.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/src/openlit/otel/tracing.py +0 -0
- {openlit-1.34.3 → openlit-1.34.4}/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.
|
3
|
+
Version: 1.34.4
|
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.
|
3
|
+
version = "1.34.4"
|
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"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
|
+
"""Initializer of Auto Instrumentation of AI21 Functions"""
|
3
|
+
|
4
|
+
from typing import Collection
|
5
|
+
import importlib.metadata
|
6
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
7
|
+
from wrapt import wrap_function_wrapper
|
8
|
+
|
9
|
+
from openlit.instrumentation.ai21.ai21 import (
|
10
|
+
chat, chat_rag
|
11
|
+
)
|
12
|
+
from openlit.instrumentation.ai21.async_ai21 import (
|
13
|
+
async_chat, async_chat_rag
|
14
|
+
)
|
15
|
+
|
16
|
+
_instruments = ("ai21 >= 3.0.0",)
|
17
|
+
|
18
|
+
class AI21Instrumentor(BaseInstrumentor):
|
19
|
+
"""
|
20
|
+
An instrumentor for AI21 client library.
|
21
|
+
"""
|
22
|
+
|
23
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
24
|
+
return _instruments
|
25
|
+
|
26
|
+
def _instrument(self, **kwargs):
|
27
|
+
application_name = kwargs.get("application_name", "default")
|
28
|
+
environment = kwargs.get("environment", "default")
|
29
|
+
tracer = kwargs.get("tracer")
|
30
|
+
metrics = kwargs.get("metrics_dict")
|
31
|
+
pricing_info = kwargs.get("pricing_info", {})
|
32
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
33
|
+
disable_metrics = kwargs.get("disable_metrics")
|
34
|
+
version = importlib.metadata.version("ai21")
|
35
|
+
|
36
|
+
#sync
|
37
|
+
wrap_function_wrapper(
|
38
|
+
"ai21.clients.studio.resources.chat.chat_completions",
|
39
|
+
"ChatCompletions.create",
|
40
|
+
chat(version, environment, application_name,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
|
+
)
|
43
|
+
wrap_function_wrapper(
|
44
|
+
"ai21.clients.studio.resources.studio_conversational_rag",
|
45
|
+
"StudioConversationalRag.create",
|
46
|
+
chat_rag(version, environment, application_name,
|
47
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
48
|
+
)
|
49
|
+
|
50
|
+
#Async
|
51
|
+
wrap_function_wrapper(
|
52
|
+
"ai21.clients.studio.resources.chat.async_chat_completions",
|
53
|
+
"AsyncChatCompletions.create",
|
54
|
+
async_chat(version, environment, application_name,
|
55
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
56
|
+
)
|
57
|
+
wrap_function_wrapper(
|
58
|
+
"ai21.clients.studio.resources.studio_conversational_rag",
|
59
|
+
"AsyncStudioConversationalRag.create",
|
60
|
+
async_chat_rag(version, environment, application_name,
|
61
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
62
|
+
)
|
63
|
+
|
64
|
+
def _uninstrument(self, **kwargs):
|
65
|
+
# Proper uninstrumentation logic to revert patched methods
|
66
|
+
pass
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvention
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def chat(version, environment, application_name,
|
25
|
-
tracer,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for GenAI function call
|
28
28
|
"""
|
@@ -46,9 +46,9 @@ def chat(version, environment, application_name,
|
|
46
46
|
self._span = span
|
47
47
|
self._span_name = span_name
|
48
48
|
# Placeholder for aggregating streaming response
|
49
|
-
self._llmresponse =
|
50
|
-
self._response_id =
|
51
|
-
self._finish_reason =
|
49
|
+
self._llmresponse = ""
|
50
|
+
self._response_id = ""
|
51
|
+
self._finish_reason = ""
|
52
52
|
self._input_tokens = 0
|
53
53
|
self._output_tokens = 0
|
54
54
|
self._choices = []
|
@@ -92,14 +92,13 @@ def chat(version, environment, application_name,
|
|
92
92
|
environment=environment,
|
93
93
|
application_name=application_name,
|
94
94
|
metrics=metrics,
|
95
|
-
event_provider=event_provider,
|
96
95
|
capture_message_content=capture_message_content,
|
97
96
|
disable_metrics=disable_metrics,
|
98
97
|
version=version
|
99
98
|
)
|
100
99
|
except Exception as e:
|
101
100
|
handle_exception(self._span, e)
|
102
|
-
logger.error(
|
101
|
+
logger.error("Error in trace creation: %s", e)
|
103
102
|
raise
|
104
103
|
|
105
104
|
def wrapper(wrapped, instance, args, kwargs):
|
@@ -108,12 +107,12 @@ def chat(version, environment, application_name,
|
|
108
107
|
"""
|
109
108
|
|
110
109
|
# Check if streaming is enabled for the API call
|
111
|
-
streaming = kwargs.get(
|
110
|
+
streaming = kwargs.get("stream", False)
|
112
111
|
|
113
|
-
server_address, server_port = set_server_address_and_port(instance,
|
114
|
-
request_model = kwargs.get(
|
112
|
+
server_address, server_port = set_server_address_and_port(instance, "api.ai21.com", 443)
|
113
|
+
request_model = kwargs.get("model", "jamba-1.5-mini")
|
115
114
|
|
116
|
-
span_name = f
|
115
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
117
116
|
|
118
117
|
# pylint: disable=no-else-return
|
119
118
|
if streaming:
|
@@ -127,30 +126,34 @@ def chat(version, environment, application_name,
|
|
127
126
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
128
127
|
start_time = time.time()
|
129
128
|
response = wrapped(*args, **kwargs)
|
130
|
-
response = process_chat_response(
|
131
|
-
response=response,
|
132
|
-
request_model=request_model,
|
133
|
-
pricing_info=pricing_info,
|
134
|
-
server_port=server_port,
|
135
|
-
server_address=server_address,
|
136
|
-
environment=environment,
|
137
|
-
application_name=application_name,
|
138
|
-
metrics=metrics,
|
139
|
-
event_provider=event_provider,
|
140
|
-
start_time=start_time,
|
141
|
-
span=span,
|
142
|
-
capture_message_content=capture_message_content,
|
143
|
-
disable_metrics=disable_metrics,
|
144
|
-
version=version,
|
145
|
-
**kwargs
|
146
|
-
)
|
147
129
|
|
148
|
-
|
130
|
+
try:
|
131
|
+
response = process_chat_response(
|
132
|
+
response=response,
|
133
|
+
request_model=request_model,
|
134
|
+
pricing_info=pricing_info,
|
135
|
+
server_port=server_port,
|
136
|
+
server_address=server_address,
|
137
|
+
environment=environment,
|
138
|
+
application_name=application_name,
|
139
|
+
metrics=metrics,
|
140
|
+
start_time=start_time,
|
141
|
+
span=span,
|
142
|
+
capture_message_content=capture_message_content,
|
143
|
+
disable_metrics=disable_metrics,
|
144
|
+
version=version,
|
145
|
+
**kwargs
|
146
|
+
)
|
147
|
+
|
148
|
+
except Exception as e:
|
149
|
+
handle_exception(span, e)
|
150
|
+
|
151
|
+
return response
|
149
152
|
|
150
153
|
return wrapper
|
151
154
|
|
152
155
|
def chat_rag(version, environment, application_name,
|
153
|
-
tracer,
|
156
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
154
157
|
"""
|
155
158
|
Generates a telemetry wrapper for GenAI function call
|
156
159
|
"""
|
@@ -160,32 +163,36 @@ def chat_rag(version, environment, application_name,
|
|
160
163
|
Wraps the GenAI function call.
|
161
164
|
"""
|
162
165
|
|
163
|
-
server_address, server_port = set_server_address_and_port(instance,
|
164
|
-
request_model = kwargs.get(
|
166
|
+
server_address, server_port = set_server_address_and_port(instance, "api.ai21.com", 443)
|
167
|
+
request_model = kwargs.get("model", "jamba-1.5-mini")
|
165
168
|
|
166
|
-
span_name = f
|
169
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
167
170
|
|
168
171
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
169
172
|
start_time = time.time()
|
170
173
|
response = wrapped(*args, **kwargs)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
174
|
+
|
175
|
+
try:
|
176
|
+
response = process_chat_rag_response(
|
177
|
+
response=response,
|
178
|
+
request_model=request_model,
|
179
|
+
pricing_info=pricing_info,
|
180
|
+
server_port=server_port,
|
181
|
+
server_address=server_address,
|
182
|
+
environment=environment,
|
183
|
+
application_name=application_name,
|
184
|
+
metrics=metrics,
|
185
|
+
start_time=start_time,
|
186
|
+
span=span,
|
187
|
+
capture_message_content=capture_message_content,
|
188
|
+
disable_metrics=disable_metrics,
|
189
|
+
version=version,
|
190
|
+
**kwargs
|
191
|
+
)
|
192
|
+
|
193
|
+
except Exception as e:
|
194
|
+
handle_exception(span, e)
|
195
|
+
|
196
|
+
return response
|
190
197
|
|
191
198
|
return wrapper
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvention
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def async_chat(version, environment, application_name,
|
25
|
-
tracer,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for GenAI function call
|
28
28
|
"""
|
@@ -46,9 +46,9 @@ def async_chat(version, environment, application_name,
|
|
46
46
|
self._span = span
|
47
47
|
self._span_name = span_name
|
48
48
|
# Placeholder for aggregating streaming response
|
49
|
-
self._llmresponse =
|
50
|
-
self._response_id =
|
51
|
-
self._finish_reason =
|
49
|
+
self._llmresponse = ""
|
50
|
+
self._response_id = ""
|
51
|
+
self._finish_reason = ""
|
52
52
|
self._input_tokens = 0
|
53
53
|
self._output_tokens = 0
|
54
54
|
self._choices = []
|
@@ -92,14 +92,13 @@ def async_chat(version, environment, application_name,
|
|
92
92
|
environment=environment,
|
93
93
|
application_name=application_name,
|
94
94
|
metrics=metrics,
|
95
|
-
event_provider=event_provider,
|
96
95
|
capture_message_content=capture_message_content,
|
97
96
|
disable_metrics=disable_metrics,
|
98
97
|
version=version
|
99
98
|
)
|
100
99
|
except Exception as e:
|
101
100
|
handle_exception(self._span, e)
|
102
|
-
|
101
|
+
|
103
102
|
raise
|
104
103
|
|
105
104
|
async def wrapper(wrapped, instance, args, kwargs):
|
@@ -108,12 +107,12 @@ def async_chat(version, environment, application_name,
|
|
108
107
|
"""
|
109
108
|
|
110
109
|
# Check if streaming is enabled for the API call
|
111
|
-
streaming = kwargs.get(
|
110
|
+
streaming = kwargs.get("stream", False)
|
112
111
|
|
113
|
-
server_address, server_port = set_server_address_and_port(instance,
|
114
|
-
request_model = kwargs.get(
|
112
|
+
server_address, server_port = set_server_address_and_port(instance, "api.ai21.com", 443)
|
113
|
+
request_model = kwargs.get("model", "jamba-1.5-mini")
|
115
114
|
|
116
|
-
span_name = f
|
115
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
117
116
|
|
118
117
|
# pylint: disable=no-else-return
|
119
118
|
if streaming:
|
@@ -127,30 +126,34 @@ def async_chat(version, environment, application_name,
|
|
127
126
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
128
127
|
start_time = time.time()
|
129
128
|
response = await wrapped(*args, **kwargs)
|
130
|
-
response = process_chat_response(
|
131
|
-
response=response,
|
132
|
-
request_model=request_model,
|
133
|
-
pricing_info=pricing_info,
|
134
|
-
server_port=server_port,
|
135
|
-
server_address=server_address,
|
136
|
-
environment=environment,
|
137
|
-
application_name=application_name,
|
138
|
-
metrics=metrics,
|
139
|
-
event_provider=event_provider,
|
140
|
-
start_time=start_time,
|
141
|
-
span=span,
|
142
|
-
capture_message_content=capture_message_content,
|
143
|
-
disable_metrics=disable_metrics,
|
144
|
-
version=version,
|
145
|
-
**kwargs
|
146
|
-
)
|
147
129
|
|
148
|
-
|
130
|
+
try:
|
131
|
+
response = process_chat_response(
|
132
|
+
response=response,
|
133
|
+
request_model=request_model,
|
134
|
+
pricing_info=pricing_info,
|
135
|
+
server_port=server_port,
|
136
|
+
server_address=server_address,
|
137
|
+
environment=environment,
|
138
|
+
application_name=application_name,
|
139
|
+
metrics=metrics,
|
140
|
+
start_time=start_time,
|
141
|
+
span=span,
|
142
|
+
capture_message_content=capture_message_content,
|
143
|
+
disable_metrics=disable_metrics,
|
144
|
+
version=version,
|
145
|
+
**kwargs
|
146
|
+
)
|
147
|
+
|
148
|
+
except Exception as e:
|
149
|
+
handle_exception(span, e)
|
150
|
+
|
151
|
+
return response
|
149
152
|
|
150
153
|
return wrapper
|
151
154
|
|
152
155
|
def async_chat_rag(version, environment, application_name,
|
153
|
-
tracer,
|
156
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
154
157
|
"""
|
155
158
|
Generates a telemetry wrapper for GenAI function call
|
156
159
|
"""
|
@@ -160,32 +163,36 @@ def async_chat_rag(version, environment, application_name,
|
|
160
163
|
Wraps the GenAI function call.
|
161
164
|
"""
|
162
165
|
|
163
|
-
server_address, server_port = set_server_address_and_port(instance,
|
164
|
-
request_model = kwargs.get(
|
166
|
+
server_address, server_port = set_server_address_and_port(instance, "api.ai21.com", 443)
|
167
|
+
request_model = kwargs.get("model", "jamba-1.5-mini")
|
165
168
|
|
166
|
-
span_name = f
|
169
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
167
170
|
|
168
171
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
169
172
|
start_time = time.time()
|
170
173
|
response = await wrapped(*args, **kwargs)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
174
|
+
|
175
|
+
try:
|
176
|
+
response = process_chat_rag_response(
|
177
|
+
response=response,
|
178
|
+
request_model=request_model,
|
179
|
+
pricing_info=pricing_info,
|
180
|
+
server_port=server_port,
|
181
|
+
server_address=server_address,
|
182
|
+
environment=environment,
|
183
|
+
application_name=application_name,
|
184
|
+
metrics=metrics,
|
185
|
+
start_time=start_time,
|
186
|
+
span=span,
|
187
|
+
capture_message_content=capture_message_content,
|
188
|
+
disable_metrics=disable_metrics,
|
189
|
+
version=version,
|
190
|
+
**kwargs
|
191
|
+
)
|
192
|
+
|
193
|
+
except Exception as e:
|
194
|
+
handle_exception(span, e)
|
195
|
+
|
196
|
+
return response
|
190
197
|
|
191
198
|
return wrapper
|