openlit 1.34.7__tar.gz → 1.34.10__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.7 → openlit-1.34.10}/PKG-INFO +1 -1
- {openlit-1.34.7 → openlit-1.34.10}/pyproject.toml +1 -1
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/__helpers.py +46 -0
- openlit-1.34.10/src/openlit/instrumentation/assemblyai/__init__.py +39 -0
- openlit-1.34.10/src/openlit/instrumentation/assemblyai/assemblyai.py +59 -0
- openlit-1.34.10/src/openlit/instrumentation/assemblyai/utils.py +142 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/elevenlabs/__init__.py +5 -27
- openlit-1.34.10/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +55 -0
- openlit-1.34.10/src/openlit/instrumentation/elevenlabs/elevenlabs.py +55 -0
- openlit-1.34.10/src/openlit/instrumentation/elevenlabs/utils.py +133 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/gpt4all/__init__.py +3 -6
- openlit-1.34.10/src/openlit/instrumentation/gpt4all/gpt4all.py +189 -0
- openlit-1.34.10/src/openlit/instrumentation/gpt4all/utils.py +281 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ollama/__init__.py +5 -6
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ollama/async_ollama.py +65 -62
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ollama/ollama.py +65 -62
- openlit-1.34.10/src/openlit/instrumentation/ollama/utils.py +277 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/premai/__init__.py +2 -2
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/premai/utils.py +4 -3
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/reka/utils.py +3 -3
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/together/utils.py +3 -3
- openlit-1.34.7/src/openlit/instrumentation/assemblyai/__init__.py +0 -43
- openlit-1.34.7/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -150
- openlit-1.34.7/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -145
- openlit-1.34.7/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -145
- openlit-1.34.7/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -497
- openlit-1.34.7/src/openlit/instrumentation/ollama/utils.py +0 -336
- {openlit-1.34.7 → openlit-1.34.10}/LICENSE +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/README.md +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/all.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/bias_detection.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/hallucination.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/toxicity.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/evals/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/all.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/prompt_injection.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/restrict_topic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/sensitive_topic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/guard/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ag2/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ag2/ag2.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ai21/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ai21/ai21.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ai21/async_ai21.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/ai21/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/anthropic/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/astra/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/astra/astra.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/astra/async_astra.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/astra/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/bedrock/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/cohere/async_cohere.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/crewai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/crewai/crewai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/google_ai_studio/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/julep/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/julep/async_julep.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/julep/julep.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/letta/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/letta/letta.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/litellm/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/litellm/litellm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/mem0/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/mem0/mem0.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/multion/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/multion/async_multion.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/multion/multion.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/phidata/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/phidata/phidata.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/premai/premai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/reka/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/reka/async_reka.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/reka/reka.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/together/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/together/async_together.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/together/together.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/transformers/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vllm/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/otel/events.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/src/openlit/otel/tracing.py +0 -0
- {openlit-1.34.7 → openlit-1.34.10}/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.10
|
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.10"
|
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"
|
@@ -333,3 +333,49 @@ def format_and_concatenate(messages):
|
|
333
333
|
for message_data in formatted_messages.values()
|
334
334
|
if message_data['content']
|
335
335
|
)
|
336
|
+
|
337
|
+
def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_address, server_port,
|
338
|
+
request_model, response_model, environment, application_name, is_stream, tbt, ttft, version):
|
339
|
+
"""
|
340
|
+
Set common span attributes for both chat and RAG operations.
|
341
|
+
"""
|
342
|
+
|
343
|
+
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
344
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, gen_ai_operation)
|
345
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, gen_ai_system)
|
346
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
347
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
348
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
349
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
|
350
|
+
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
351
|
+
scope._span.set_attribute(SERVICE_NAME, application_name)
|
352
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
353
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
|
354
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
|
355
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
356
|
+
|
357
|
+
def record_completion_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
358
|
+
request_model, response_model, environment, application_name, start_time, end_time, cost,
|
359
|
+
input_tokens, output_tokens, tbt, ttft):
|
360
|
+
"""
|
361
|
+
Record completion metrics for the operation.
|
362
|
+
"""
|
363
|
+
|
364
|
+
attributes = create_metrics_attributes(
|
365
|
+
operation=gen_ai_operation,
|
366
|
+
system=gen_ai_system,
|
367
|
+
server_address=server_address,
|
368
|
+
server_port=server_port,
|
369
|
+
request_model=request_model,
|
370
|
+
response_model=response_model,
|
371
|
+
service_name=application_name,
|
372
|
+
deployment_environment=environment,
|
373
|
+
)
|
374
|
+
metrics["genai_client_usage_tokens"].record(input_tokens + output_tokens, attributes)
|
375
|
+
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
376
|
+
metrics["genai_server_tbt"].record(tbt, attributes)
|
377
|
+
metrics["genai_server_ttft"].record(ttft, attributes)
|
378
|
+
metrics["genai_requests"].add(1, attributes)
|
379
|
+
metrics["genai_completion_tokens"].add(output_tokens, attributes)
|
380
|
+
metrics["genai_prompt_tokens"].add(input_tokens, attributes)
|
381
|
+
metrics["genai_cost"].record(cost, attributes)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"""Initializer of Auto Instrumentation of AssemblyAI Functions"""
|
2
|
+
|
3
|
+
from typing import Collection
|
4
|
+
import importlib.metadata
|
5
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
6
|
+
from wrapt import wrap_function_wrapper
|
7
|
+
|
8
|
+
from openlit.instrumentation.assemblyai.assemblyai import transcribe
|
9
|
+
|
10
|
+
_instruments = ("assemblyai >= 0.35.1",)
|
11
|
+
|
12
|
+
class AssemblyAIInstrumentor(BaseInstrumentor):
|
13
|
+
"""
|
14
|
+
An instrumentor for AssemblyAI client library.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
18
|
+
return _instruments
|
19
|
+
|
20
|
+
def _instrument(self, **kwargs):
|
21
|
+
application_name = kwargs.get("application_name", "default")
|
22
|
+
environment = kwargs.get("environment", "default")
|
23
|
+
tracer = kwargs.get("tracer")
|
24
|
+
metrics = kwargs.get("metrics_dict")
|
25
|
+
pricing_info = kwargs.get("pricing_info", {})
|
26
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
27
|
+
disable_metrics = kwargs.get("disable_metrics")
|
28
|
+
version = importlib.metadata.version("assemblyai")
|
29
|
+
|
30
|
+
# sync transcribe
|
31
|
+
wrap_function_wrapper(
|
32
|
+
"assemblyai.transcriber",
|
33
|
+
"Transcriber.transcribe",
|
34
|
+
transcribe(version, environment, application_name,
|
35
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
36
|
+
)
|
37
|
+
|
38
|
+
def _uninstrument(self, **kwargs):
|
39
|
+
pass
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring AssemblyAI API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import logging
|
6
|
+
import time
|
7
|
+
from opentelemetry.trace import SpanKind
|
8
|
+
from openlit.__helpers import handle_exception, set_server_address_and_port
|
9
|
+
from openlit.instrumentation.assemblyai.utils import process_audio_response
|
10
|
+
from openlit.semcov import SemanticConvention
|
11
|
+
|
12
|
+
# Initialize logger for logging potential issues and operations
|
13
|
+
logger = logging.getLogger(__name__)
|
14
|
+
|
15
|
+
def transcribe(version, environment, application_name,
|
16
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
17
|
+
"""
|
18
|
+
Generates a telemetry wrapper for AssemblyAI transcribe function call
|
19
|
+
"""
|
20
|
+
|
21
|
+
def wrapper(wrapped, instance, args, kwargs):
|
22
|
+
"""
|
23
|
+
Wraps the AssemblyAI transcribe function call.
|
24
|
+
"""
|
25
|
+
|
26
|
+
server_address, server_port = set_server_address_and_port(instance, "api.assemblyai.com", 443)
|
27
|
+
request_model = kwargs.get("speech_model", "best")
|
28
|
+
|
29
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
|
30
|
+
|
31
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
32
|
+
start_time = time.time()
|
33
|
+
|
34
|
+
try:
|
35
|
+
response = wrapped(*args, **kwargs)
|
36
|
+
|
37
|
+
response = process_audio_response(
|
38
|
+
response=response,
|
39
|
+
gen_ai_endpoint="assemblyai.transcribe",
|
40
|
+
pricing_info=pricing_info,
|
41
|
+
server_port=server_port,
|
42
|
+
server_address=server_address,
|
43
|
+
environment=environment,
|
44
|
+
application_name=application_name,
|
45
|
+
metrics=metrics,
|
46
|
+
start_time=start_time,
|
47
|
+
span=span,
|
48
|
+
capture_message_content=capture_message_content,
|
49
|
+
disable_metrics=disable_metrics,
|
50
|
+
version=version,
|
51
|
+
**kwargs
|
52
|
+
)
|
53
|
+
|
54
|
+
except Exception as e:
|
55
|
+
handle_exception(span, e)
|
56
|
+
|
57
|
+
return response
|
58
|
+
|
59
|
+
return wrapper
|
@@ -0,0 +1,142 @@
|
|
1
|
+
"""
|
2
|
+
AssemblyAI OpenTelemetry instrumentation utility functions
|
3
|
+
"""
|
4
|
+
import time
|
5
|
+
|
6
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
7
|
+
from opentelemetry.trace import Status, StatusCode
|
8
|
+
|
9
|
+
from openlit.__helpers import (
|
10
|
+
get_audio_model_cost,
|
11
|
+
create_metrics_attributes,
|
12
|
+
)
|
13
|
+
from openlit.semcov import SemanticConvention
|
14
|
+
|
15
|
+
def format_audio_url(audio_url):
|
16
|
+
"""
|
17
|
+
Process audio URL input to extract content.
|
18
|
+
"""
|
19
|
+
return str(audio_url) if audio_url else ""
|
20
|
+
|
21
|
+
def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_address, server_port,
|
22
|
+
request_model, response_model, environment, application_name, is_stream, tbt, ttft, version):
|
23
|
+
"""
|
24
|
+
Set common span attributes for both chat and RAG operations.
|
25
|
+
"""
|
26
|
+
|
27
|
+
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
28
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, gen_ai_operation)
|
29
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, gen_ai_system)
|
30
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
31
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
32
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
33
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
|
34
|
+
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
35
|
+
scope._span.set_attribute(SERVICE_NAME, application_name)
|
36
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
37
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
|
38
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
|
39
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
40
|
+
|
41
|
+
def record_audio_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
42
|
+
request_model, response_model, environment, application_name, start_time, end_time, cost):
|
43
|
+
"""
|
44
|
+
Record audio metrics for the operation.
|
45
|
+
"""
|
46
|
+
|
47
|
+
attributes = create_metrics_attributes(
|
48
|
+
operation=gen_ai_operation,
|
49
|
+
system=gen_ai_system,
|
50
|
+
server_address=server_address,
|
51
|
+
server_port=server_port,
|
52
|
+
request_model=request_model,
|
53
|
+
response_model=response_model,
|
54
|
+
service_name=application_name,
|
55
|
+
deployment_environment=environment,
|
56
|
+
)
|
57
|
+
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
58
|
+
metrics["genai_requests"].add(1, attributes)
|
59
|
+
metrics["genai_cost"].record(cost, attributes)
|
60
|
+
|
61
|
+
def common_audio_logic(scope, gen_ai_endpoint, pricing_info, environment, application_name,
|
62
|
+
metrics, capture_message_content, disable_metrics, version):
|
63
|
+
"""
|
64
|
+
Process audio transcription request and generate Telemetry
|
65
|
+
"""
|
66
|
+
|
67
|
+
prompt = scope._response.audio_url
|
68
|
+
request_model = scope._kwargs.get("speech_model", "best")
|
69
|
+
is_stream = False
|
70
|
+
|
71
|
+
# Calculate cost based on audio duration
|
72
|
+
cost = get_audio_model_cost(request_model, pricing_info, prompt, scope._response.audio_duration)
|
73
|
+
|
74
|
+
# Common Span Attributes
|
75
|
+
common_span_attributes(scope,
|
76
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO, SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI,
|
77
|
+
scope._server_address, scope._server_port, request_model, request_model,
|
78
|
+
environment, application_name, is_stream, scope._tbt, scope._ttft, version)
|
79
|
+
|
80
|
+
# Span Attributes for Response parameters
|
81
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, "text")
|
82
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID, scope._response.id)
|
83
|
+
|
84
|
+
# Span Attributes for Cost
|
85
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
|
86
|
+
|
87
|
+
# Audio-specific span attributes
|
88
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_DURATION, scope._response.audio_duration)
|
89
|
+
|
90
|
+
# Span Attributes for Content
|
91
|
+
if capture_message_content:
|
92
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_PROMPT, prompt)
|
93
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION, scope._response.text)
|
94
|
+
|
95
|
+
# To be removed once the change to span_attributes (from span events) is complete
|
96
|
+
scope._span.add_event(
|
97
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
98
|
+
attributes={
|
99
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
100
|
+
},
|
101
|
+
)
|
102
|
+
scope._span.add_event(
|
103
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
104
|
+
attributes={
|
105
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._response.text,
|
106
|
+
},
|
107
|
+
)
|
108
|
+
|
109
|
+
scope._span.set_status(Status(StatusCode.OK))
|
110
|
+
|
111
|
+
# Metrics
|
112
|
+
if not disable_metrics:
|
113
|
+
record_audio_metrics(metrics, SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
|
114
|
+
SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI, scope._server_address, scope._server_port,
|
115
|
+
request_model, request_model, environment, application_name, scope._start_time,
|
116
|
+
scope._end_time, cost)
|
117
|
+
|
118
|
+
def process_audio_response(response, gen_ai_endpoint, pricing_info, server_port, server_address,
|
119
|
+
environment, application_name, metrics, start_time, span, capture_message_content=False,
|
120
|
+
disable_metrics=False, version="1.0.0", **kwargs):
|
121
|
+
"""
|
122
|
+
Process audio transcription request and generate Telemetry
|
123
|
+
"""
|
124
|
+
|
125
|
+
scope = type("GenericScope", (), {})()
|
126
|
+
|
127
|
+
scope._start_time = start_time
|
128
|
+
scope._end_time = time.time()
|
129
|
+
scope._span = span
|
130
|
+
scope._server_address, scope._server_port = server_address, server_port
|
131
|
+
scope._kwargs = kwargs
|
132
|
+
scope._response = response
|
133
|
+
|
134
|
+
# Initialize streaming and timing values for AssemblyAI transcription
|
135
|
+
scope._response_model = kwargs.get("speech_model", "best")
|
136
|
+
scope._tbt = 0.0
|
137
|
+
scope._ttft = scope._end_time - scope._start_time
|
138
|
+
|
139
|
+
common_audio_logic(scope, gen_ai_endpoint, pricing_info, environment, application_name,
|
140
|
+
metrics, capture_message_content, disable_metrics, version)
|
141
|
+
|
142
|
+
return response
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of ElevenLabs Functions"""
|
3
2
|
|
4
3
|
from typing import Collection
|
@@ -6,18 +5,14 @@ import importlib.metadata
|
|
6
5
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
7
6
|
from wrapt import wrap_function_wrapper
|
8
7
|
|
9
|
-
from openlit.instrumentation.elevenlabs.elevenlabs import
|
10
|
-
|
11
|
-
)
|
12
|
-
from openlit.instrumentation.elevenlabs.async_elevenlabs import (
|
13
|
-
async_generate
|
14
|
-
)
|
8
|
+
from openlit.instrumentation.elevenlabs.elevenlabs import generate
|
9
|
+
from openlit.instrumentation.elevenlabs.async_elevenlabs import async_generate
|
15
10
|
|
16
11
|
_instruments = ("elevenlabs >= 1.4.0",)
|
17
12
|
|
18
13
|
class ElevenLabsInstrumentor(BaseInstrumentor):
|
19
14
|
"""
|
20
|
-
An instrumentor for ElevenLabs
|
15
|
+
An instrumentor for ElevenLabs client library.
|
21
16
|
"""
|
22
17
|
|
23
18
|
def instrumentation_dependencies(self) -> Collection[str]:
|
@@ -33,14 +28,6 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
33
28
|
disable_metrics = kwargs.get("disable_metrics")
|
34
29
|
version = importlib.metadata.version("elevenlabs")
|
35
30
|
|
36
|
-
# sync generate
|
37
|
-
wrap_function_wrapper(
|
38
|
-
"elevenlabs.client",
|
39
|
-
"ElevenLabs.generate",
|
40
|
-
generate("elevenlabs.generate", version, environment, application_name,
|
41
|
-
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
|
-
)
|
43
|
-
|
44
31
|
# sync text_to_speech.convert
|
45
32
|
wrap_function_wrapper(
|
46
33
|
"elevenlabs.text_to_speech.client",
|
@@ -49,22 +36,13 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
49
36
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
50
37
|
)
|
51
38
|
|
52
|
-
# async
|
53
|
-
wrap_function_wrapper(
|
54
|
-
"elevenlabs.client",
|
55
|
-
"AsyncElevenLabs.generate",
|
56
|
-
async_generate("elevenlabs.generate", version, environment, application_name,
|
57
|
-
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
58
|
-
)
|
59
|
-
|
60
|
-
# sync text_to_speech.convert
|
39
|
+
# async text_to_speech.convert
|
61
40
|
wrap_function_wrapper(
|
62
41
|
"elevenlabs.text_to_speech.client",
|
63
42
|
"AsyncTextToSpeechClient.convert",
|
64
|
-
|
43
|
+
async_generate("elevenlabs.text_to_speech", version, environment, application_name,
|
65
44
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
66
45
|
)
|
67
46
|
|
68
47
|
def _uninstrument(self, **kwargs):
|
69
|
-
# Proper uninstrumentation logic to revert patched methods
|
70
48
|
pass
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring ElevenLabs API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import time
|
6
|
+
from opentelemetry.trace import SpanKind
|
7
|
+
from openlit.__helpers import handle_exception
|
8
|
+
from openlit.instrumentation.elevenlabs.utils import process_audio_response
|
9
|
+
from openlit.semcov import SemanticConvention
|
10
|
+
|
11
|
+
def async_generate(gen_ai_endpoint, version, environment, application_name,
|
12
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
13
|
+
"""
|
14
|
+
Generates a telemetry wrapper for GenAI function call
|
15
|
+
"""
|
16
|
+
|
17
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
18
|
+
"""
|
19
|
+
Wraps the GenAI function call.
|
20
|
+
"""
|
21
|
+
|
22
|
+
server_address, server_port = "api.elevenlabs.io", 443
|
23
|
+
request_model = kwargs.get("model", kwargs.get("model_id", "eleven_multilingual_v2"))
|
24
|
+
|
25
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
|
26
|
+
|
27
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
28
|
+
start_time = time.time()
|
29
|
+
response = wrapped(*args, **kwargs)
|
30
|
+
|
31
|
+
try:
|
32
|
+
response = process_audio_response(
|
33
|
+
response=response,
|
34
|
+
gen_ai_endpoint=gen_ai_endpoint,
|
35
|
+
pricing_info=pricing_info,
|
36
|
+
server_port=server_port,
|
37
|
+
server_address=server_address,
|
38
|
+
environment=environment,
|
39
|
+
application_name=application_name,
|
40
|
+
metrics=metrics,
|
41
|
+
start_time=start_time,
|
42
|
+
span=span,
|
43
|
+
args=args,
|
44
|
+
kwargs=kwargs,
|
45
|
+
capture_message_content=capture_message_content,
|
46
|
+
disable_metrics=disable_metrics,
|
47
|
+
version=version
|
48
|
+
)
|
49
|
+
|
50
|
+
except Exception as e:
|
51
|
+
handle_exception(span, e)
|
52
|
+
|
53
|
+
return response
|
54
|
+
|
55
|
+
return wrapper
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring ElevenLabs API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import time
|
6
|
+
from opentelemetry.trace import SpanKind
|
7
|
+
from openlit.__helpers import handle_exception
|
8
|
+
from openlit.instrumentation.elevenlabs.utils import process_audio_response
|
9
|
+
from openlit.semcov import SemanticConvention
|
10
|
+
|
11
|
+
def generate(gen_ai_endpoint, version, environment, application_name,
|
12
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
13
|
+
"""
|
14
|
+
Generates a telemetry wrapper for GenAI function call
|
15
|
+
"""
|
16
|
+
|
17
|
+
def wrapper(wrapped, instance, args, kwargs):
|
18
|
+
"""
|
19
|
+
Wraps the GenAI function call.
|
20
|
+
"""
|
21
|
+
|
22
|
+
server_address, server_port = "api.elevenlabs.io", 443
|
23
|
+
request_model = kwargs.get("model", kwargs.get("model_id", "eleven_multilingual_v2"))
|
24
|
+
|
25
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
|
26
|
+
|
27
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
28
|
+
start_time = time.time()
|
29
|
+
response = wrapped(*args, **kwargs)
|
30
|
+
|
31
|
+
try:
|
32
|
+
response = process_audio_response(
|
33
|
+
response=response,
|
34
|
+
gen_ai_endpoint=gen_ai_endpoint,
|
35
|
+
pricing_info=pricing_info,
|
36
|
+
server_port=server_port,
|
37
|
+
server_address=server_address,
|
38
|
+
environment=environment,
|
39
|
+
application_name=application_name,
|
40
|
+
metrics=metrics,
|
41
|
+
start_time=start_time,
|
42
|
+
span=span,
|
43
|
+
args=args,
|
44
|
+
kwargs=kwargs,
|
45
|
+
capture_message_content=capture_message_content,
|
46
|
+
disable_metrics=disable_metrics,
|
47
|
+
version=version
|
48
|
+
)
|
49
|
+
|
50
|
+
except Exception as e:
|
51
|
+
handle_exception(span, e)
|
52
|
+
|
53
|
+
return response
|
54
|
+
|
55
|
+
return wrapper
|
@@ -0,0 +1,133 @@
|
|
1
|
+
"""
|
2
|
+
ElevenLabs OpenTelemetry instrumentation utility functions
|
3
|
+
"""
|
4
|
+
import time
|
5
|
+
|
6
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
7
|
+
from opentelemetry.trace import Status, StatusCode
|
8
|
+
|
9
|
+
from openlit.__helpers import (
|
10
|
+
get_audio_model_cost,
|
11
|
+
create_metrics_attributes,
|
12
|
+
)
|
13
|
+
from openlit.semcov import SemanticConvention
|
14
|
+
|
15
|
+
def format_content(text):
|
16
|
+
"""
|
17
|
+
Process text input to extract content.
|
18
|
+
"""
|
19
|
+
return str(text) if text else ""
|
20
|
+
|
21
|
+
def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_address, server_port,
|
22
|
+
request_model, response_model, environment, application_name, is_stream, tbt, ttft, version):
|
23
|
+
"""
|
24
|
+
Set common span attributes for both chat and RAG operations.
|
25
|
+
"""
|
26
|
+
|
27
|
+
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
28
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, gen_ai_operation)
|
29
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, gen_ai_system)
|
30
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
31
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
32
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
33
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
|
34
|
+
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
35
|
+
scope._span.set_attribute(SERVICE_NAME, application_name)
|
36
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
37
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
|
38
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
|
39
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
40
|
+
|
41
|
+
def record_audio_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
42
|
+
request_model, response_model, environment, application_name, start_time, end_time, cost):
|
43
|
+
"""
|
44
|
+
Record audio generation metrics for the operation.
|
45
|
+
"""
|
46
|
+
|
47
|
+
attributes = create_metrics_attributes(
|
48
|
+
operation=gen_ai_operation,
|
49
|
+
system=gen_ai_system,
|
50
|
+
server_address=server_address,
|
51
|
+
server_port=server_port,
|
52
|
+
request_model=request_model,
|
53
|
+
response_model=response_model,
|
54
|
+
service_name=application_name,
|
55
|
+
deployment_environment=environment,
|
56
|
+
)
|
57
|
+
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
58
|
+
metrics["genai_requests"].add(1, attributes)
|
59
|
+
metrics["genai_cost"].record(cost, attributes)
|
60
|
+
|
61
|
+
def common_audio_logic(scope, gen_ai_endpoint, pricing_info, environment, application_name,
|
62
|
+
metrics, capture_message_content, disable_metrics, version):
|
63
|
+
"""
|
64
|
+
Process audio generation request and generate Telemetry
|
65
|
+
"""
|
66
|
+
|
67
|
+
text = format_content(scope._kwargs.get("text", ""))
|
68
|
+
request_model = scope._kwargs.get("model", scope._kwargs.get("model_id", "eleven_multilingual_v2"))
|
69
|
+
is_stream = False # ElevenLabs audio generation is not streaming
|
70
|
+
|
71
|
+
cost = get_audio_model_cost(request_model, pricing_info, text)
|
72
|
+
|
73
|
+
# Common Span Attributes
|
74
|
+
common_span_attributes(scope,
|
75
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO, SemanticConvention.GEN_AI_SYSTEM_ELEVENLABS,
|
76
|
+
scope._server_address, scope._server_port, request_model, request_model,
|
77
|
+
environment, application_name, is_stream, scope._tbt, scope._ttft, version)
|
78
|
+
|
79
|
+
# Span Attributes for Cost and Tokens
|
80
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
|
81
|
+
|
82
|
+
# Span Attributes for Response parameters
|
83
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, scope._kwargs.get("output_format", "mp3_44100_128"))
|
84
|
+
|
85
|
+
# Audio-specific span attributes
|
86
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE, scope._kwargs.get("voice_id", ""))
|
87
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SETTINGS, str(scope._kwargs.get("voice_settings", "")))
|
88
|
+
|
89
|
+
# Span Attributes for Content
|
90
|
+
if capture_message_content:
|
91
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_PROMPT, text)
|
92
|
+
|
93
|
+
# To be removed once the change to span_attributes (from span events) is complete
|
94
|
+
scope._span.add_event(
|
95
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
96
|
+
attributes={
|
97
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: text,
|
98
|
+
},
|
99
|
+
)
|
100
|
+
|
101
|
+
scope._span.set_status(Status(StatusCode.OK))
|
102
|
+
|
103
|
+
# Metrics
|
104
|
+
if not disable_metrics:
|
105
|
+
record_audio_metrics(metrics, SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO, SemanticConvention.GEN_AI_SYSTEM_ELEVENLABS,
|
106
|
+
scope._server_address, scope._server_port, request_model, request_model, environment,
|
107
|
+
application_name, scope._start_time, scope._end_time, cost)
|
108
|
+
|
109
|
+
def process_audio_response(response, gen_ai_endpoint, pricing_info, server_port, server_address,
|
110
|
+
environment, application_name, metrics, start_time, span, args, kwargs, capture_message_content=False,
|
111
|
+
disable_metrics=False, version="1.0.0"):
|
112
|
+
"""
|
113
|
+
Process audio generation request and generate Telemetry
|
114
|
+
"""
|
115
|
+
|
116
|
+
scope = type("GenericScope", (), {})()
|
117
|
+
|
118
|
+
scope._start_time = start_time
|
119
|
+
scope._end_time = time.time()
|
120
|
+
scope._span = span
|
121
|
+
scope._server_address, scope._server_port = server_address, server_port
|
122
|
+
scope._kwargs = kwargs
|
123
|
+
scope._args = args
|
124
|
+
|
125
|
+
# Initialize streaming and timing values for ElevenLabs audio generation
|
126
|
+
scope._response_model = kwargs.get("model", kwargs.get("model_id", "eleven_multilingual_v2"))
|
127
|
+
scope._tbt = 0.0
|
128
|
+
scope._ttft = scope._end_time - scope._start_time
|
129
|
+
|
130
|
+
common_audio_logic(scope, gen_ai_endpoint, pricing_info, environment, application_name,
|
131
|
+
metrics, capture_message_content, disable_metrics, version)
|
132
|
+
|
133
|
+
return response
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of GPT4All Functions"""
|
3
2
|
|
4
3
|
from typing import Collection
|
@@ -14,15 +13,15 @@ _instruments = ("gpt4all >= 2.6.0",)
|
|
14
13
|
|
15
14
|
class GPT4AllInstrumentor(BaseInstrumentor):
|
16
15
|
"""
|
17
|
-
An instrumentor for GPT4All
|
16
|
+
An instrumentor for GPT4All client library.
|
18
17
|
"""
|
19
18
|
|
20
19
|
def instrumentation_dependencies(self) -> Collection[str]:
|
21
20
|
return _instruments
|
22
21
|
|
23
22
|
def _instrument(self, **kwargs):
|
24
|
-
application_name = kwargs.get("application_name", "
|
25
|
-
environment = kwargs.get("environment", "
|
23
|
+
application_name = kwargs.get("application_name", "default")
|
24
|
+
environment = kwargs.get("environment", "default")
|
26
25
|
tracer = kwargs.get("tracer")
|
27
26
|
metrics = kwargs.get("metrics_dict")
|
28
27
|
pricing_info = kwargs.get("pricing_info", {})
|
@@ -46,7 +45,5 @@ class GPT4AllInstrumentor(BaseInstrumentor):
|
|
46
45
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
46
|
)
|
48
47
|
|
49
|
-
|
50
48
|
def _uninstrument(self, **kwargs):
|
51
|
-
# Proper uninstrumentation logic to revert patched methods
|
52
49
|
pass
|