openlit 1.34.17__tar.gz → 1.34.18__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.17 → openlit-1.34.18}/PKG-INFO +1 -1
- {openlit-1.34.17 → openlit-1.34.18}/pyproject.toml +1 -1
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/cohere/__init__.py +42 -28
- openlit-1.34.18/src/openlit/instrumentation/cohere/async_cohere.py +201 -0
- openlit-1.34.18/src/openlit/instrumentation/cohere/cohere.py +201 -0
- openlit-1.34.18/src/openlit/instrumentation/cohere/utils.py +330 -0
- openlit-1.34.17/src/openlit/instrumentation/cohere/async_cohere.py +0 -610
- openlit-1.34.17/src/openlit/instrumentation/cohere/cohere.py +0 -610
- {openlit-1.34.17 → openlit-1.34.18}/LICENSE +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/README.md +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/__helpers.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/all.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/bias_detection.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/hallucination.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/toxicity.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/evals/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/all.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/prompt_injection.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/restrict_topic.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/sensitive_topic.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/guard/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ag2/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ag2/ag2.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ai21/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ai21/ai21.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ai21/async_ai21.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ai21/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/anthropic/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/assemblyai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/assemblyai/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/astra/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/astra/astra.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/astra/async_astra.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/astra/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/bedrock/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/crewai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/crewai/crewai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/elevenlabs/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/google_ai_studio/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/gpt4all/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/groq/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/julep/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/julep/async_julep.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/julep/julep.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/letta/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/letta/letta.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/litellm/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/litellm/litellm.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/litellm/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mem0/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mem0/mem0.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/mistral/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/multion/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/multion/async_multion.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/multion/multion.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/ollama/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/phidata/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/phidata/phidata.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/premai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/premai/premai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/premai/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/reka/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/reka/async_reka.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/reka/reka.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/reka/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/together/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/together/async_together.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/together/together.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/together/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/transformers/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vllm/utils.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/otel/events.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/src/openlit/otel/tracing.py +0 -0
- {openlit-1.34.17 → openlit-1.34.18}/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.18
|
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.18"
|
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,74 +1,88 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of Cohere Functions"""
|
2
|
+
|
3
3
|
from typing import Collection
|
4
4
|
import importlib.metadata
|
5
5
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
6
6
|
from wrapt import wrap_function_wrapper
|
7
7
|
|
8
|
-
from openlit.instrumentation.cohere.cohere import
|
9
|
-
|
10
|
-
|
8
|
+
from openlit.instrumentation.cohere.cohere import (
|
9
|
+
chat,
|
10
|
+
chat_stream,
|
11
|
+
embed
|
12
|
+
)
|
13
|
+
from openlit.instrumentation.cohere.async_cohere import (
|
14
|
+
async_chat,
|
15
|
+
async_chat_stream,
|
16
|
+
async_embed
|
17
|
+
)
|
11
18
|
|
12
19
|
_instruments = ("cohere >= 5.14.0",)
|
13
20
|
|
14
21
|
class CohereInstrumentor(BaseInstrumentor):
|
15
|
-
"""
|
22
|
+
"""
|
23
|
+
An instrumentor for Cohere client library.
|
24
|
+
"""
|
16
25
|
|
17
26
|
def instrumentation_dependencies(self) -> Collection[str]:
|
18
27
|
return _instruments
|
19
28
|
|
20
29
|
def _instrument(self, **kwargs):
|
21
|
-
application_name = kwargs.get("application_name")
|
22
|
-
environment = kwargs.get("environment")
|
30
|
+
application_name = kwargs.get("application_name", "default")
|
31
|
+
environment = kwargs.get("environment", "default")
|
23
32
|
tracer = kwargs.get("tracer")
|
24
33
|
metrics = kwargs.get("metrics_dict")
|
25
|
-
pricing_info = kwargs.get("pricing_info")
|
26
|
-
capture_message_content = kwargs.get("capture_message_content")
|
34
|
+
pricing_info = kwargs.get("pricing_info", {})
|
35
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
27
36
|
disable_metrics = kwargs.get("disable_metrics")
|
28
37
|
version = importlib.metadata.version("cohere")
|
29
38
|
|
30
|
-
#
|
39
|
+
# sync chat completions
|
31
40
|
wrap_function_wrapper(
|
32
|
-
"cohere.client_v2",
|
33
|
-
"ClientV2.chat",
|
41
|
+
"cohere.client_v2",
|
42
|
+
"ClientV2.chat",
|
34
43
|
chat(version, environment, application_name,
|
35
|
-
|
44
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
36
45
|
)
|
46
|
+
|
47
|
+
# sync chat streaming
|
37
48
|
wrap_function_wrapper(
|
38
|
-
"cohere.client_v2",
|
39
|
-
"ClientV2.chat_stream",
|
49
|
+
"cohere.client_v2",
|
50
|
+
"ClientV2.chat_stream",
|
40
51
|
chat_stream(version, environment, application_name,
|
41
|
-
|
52
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
53
|
)
|
54
|
+
|
55
|
+
# sync embeddings
|
43
56
|
wrap_function_wrapper(
|
44
|
-
"cohere.client_v2",
|
45
|
-
"ClientV2.embed",
|
57
|
+
"cohere.client_v2",
|
58
|
+
"ClientV2.embed",
|
46
59
|
embed(version, environment, application_name,
|
47
60
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
48
61
|
)
|
49
62
|
|
50
|
-
#
|
63
|
+
# async chat completions
|
51
64
|
wrap_function_wrapper(
|
52
|
-
"cohere.client_v2",
|
53
|
-
"AsyncClientV2.chat",
|
65
|
+
"cohere.client_v2",
|
66
|
+
"AsyncClientV2.chat",
|
54
67
|
async_chat(version, environment, application_name,
|
55
|
-
|
68
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
56
69
|
)
|
57
70
|
|
71
|
+
# async chat streaming
|
58
72
|
wrap_function_wrapper(
|
59
|
-
"cohere.client_v2",
|
60
|
-
"AsyncClientV2.chat_stream",
|
73
|
+
"cohere.client_v2",
|
74
|
+
"AsyncClientV2.chat_stream",
|
61
75
|
async_chat_stream(version, environment, application_name,
|
62
|
-
|
76
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
63
77
|
)
|
64
78
|
|
79
|
+
# async embeddings
|
65
80
|
wrap_function_wrapper(
|
66
|
-
"cohere.client_v2",
|
67
|
-
"AsyncClientV2.embed",
|
81
|
+
"cohere.client_v2",
|
82
|
+
"AsyncClientV2.embed",
|
68
83
|
async_embed(version, environment, application_name,
|
69
84
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
70
85
|
)
|
71
86
|
|
72
|
-
@staticmethod
|
73
87
|
def _uninstrument(self, **kwargs):
|
74
88
|
pass
|
@@ -0,0 +1,201 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring Cohere API calls (async version).
|
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.cohere.utils import (
|
12
|
+
process_chunk,
|
13
|
+
process_chat_response,
|
14
|
+
process_streaming_chat_response,
|
15
|
+
process_embedding_response,
|
16
|
+
)
|
17
|
+
from openlit.semcov import SemanticConvention
|
18
|
+
|
19
|
+
def async_chat(version, environment, application_name,
|
20
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
21
|
+
"""
|
22
|
+
Generates a telemetry wrapper for GenAI chat function call
|
23
|
+
"""
|
24
|
+
|
25
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
26
|
+
"""
|
27
|
+
Wraps the GenAI chat function call.
|
28
|
+
"""
|
29
|
+
|
30
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
31
|
+
request_model = kwargs.get("model", "command-r-plus-08-2024")
|
32
|
+
|
33
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
34
|
+
|
35
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
36
|
+
start_time = time.time()
|
37
|
+
response = await wrapped(*args, **kwargs)
|
38
|
+
response = process_chat_response(
|
39
|
+
response=response,
|
40
|
+
request_model=request_model,
|
41
|
+
pricing_info=pricing_info,
|
42
|
+
server_port=server_port,
|
43
|
+
server_address=server_address,
|
44
|
+
environment=environment,
|
45
|
+
application_name=application_name,
|
46
|
+
metrics=metrics,
|
47
|
+
start_time=start_time,
|
48
|
+
span=span,
|
49
|
+
capture_message_content=capture_message_content,
|
50
|
+
disable_metrics=disable_metrics,
|
51
|
+
version=version,
|
52
|
+
**kwargs
|
53
|
+
)
|
54
|
+
|
55
|
+
return response
|
56
|
+
|
57
|
+
return wrapper
|
58
|
+
|
59
|
+
def async_chat_stream(version, environment, application_name,
|
60
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
61
|
+
"""
|
62
|
+
Generates a telemetry wrapper for GenAI chat_stream function call
|
63
|
+
"""
|
64
|
+
|
65
|
+
class TracedAsyncStream:
|
66
|
+
"""
|
67
|
+
Wrapper for async streaming responses to collect telemetry.
|
68
|
+
"""
|
69
|
+
|
70
|
+
def __init__(
|
71
|
+
self,
|
72
|
+
wrapped,
|
73
|
+
span,
|
74
|
+
span_name,
|
75
|
+
kwargs,
|
76
|
+
server_address,
|
77
|
+
server_port,
|
78
|
+
**args,
|
79
|
+
):
|
80
|
+
self.__wrapped__ = wrapped
|
81
|
+
self._span = span
|
82
|
+
self._span_name = span_name
|
83
|
+
self._llmresponse = ""
|
84
|
+
self._response_id = ""
|
85
|
+
self._response_model = ""
|
86
|
+
self._finish_reason = ""
|
87
|
+
self._tools = None
|
88
|
+
self._tool_plan = ""
|
89
|
+
self._input_tokens = 0
|
90
|
+
self._output_tokens = 0
|
91
|
+
|
92
|
+
self._args = args
|
93
|
+
self._kwargs = kwargs
|
94
|
+
self._start_time = time.time()
|
95
|
+
self._end_time = None
|
96
|
+
self._timestamps = []
|
97
|
+
self._ttft = 0
|
98
|
+
self._tbt = 0
|
99
|
+
self._server_address = server_address
|
100
|
+
self._server_port = server_port
|
101
|
+
|
102
|
+
async def __aenter__(self):
|
103
|
+
await self.__wrapped__.__aenter__()
|
104
|
+
return self
|
105
|
+
|
106
|
+
async def __aexit__(self, exc_type, exc_value, traceback):
|
107
|
+
await self.__wrapped__.__aexit__(exc_type, exc_value, traceback)
|
108
|
+
|
109
|
+
def __aiter__(self):
|
110
|
+
return self
|
111
|
+
|
112
|
+
async def __getattr__(self, name):
|
113
|
+
"""Delegate attribute access to the wrapped object."""
|
114
|
+
return getattr(await self.__wrapped__, name)
|
115
|
+
|
116
|
+
async def __anext__(self):
|
117
|
+
try:
|
118
|
+
chunk = await self.__wrapped__.__anext__()
|
119
|
+
process_chunk(self, chunk)
|
120
|
+
return chunk
|
121
|
+
except StopAsyncIteration:
|
122
|
+
try:
|
123
|
+
with tracer.start_as_current_span(self._span_name, kind= SpanKind.CLIENT) as self._span:
|
124
|
+
process_streaming_chat_response(
|
125
|
+
self,
|
126
|
+
pricing_info=pricing_info,
|
127
|
+
environment=environment,
|
128
|
+
application_name=application_name,
|
129
|
+
metrics=metrics,
|
130
|
+
capture_message_content=capture_message_content,
|
131
|
+
disable_metrics=disable_metrics,
|
132
|
+
version=version
|
133
|
+
)
|
134
|
+
|
135
|
+
except Exception as e:
|
136
|
+
handle_exception(self._span, e)
|
137
|
+
|
138
|
+
raise
|
139
|
+
|
140
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
141
|
+
"""
|
142
|
+
Wraps the GenAI chat_stream function call.
|
143
|
+
"""
|
144
|
+
|
145
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
146
|
+
request_model = kwargs.get("model", "command-r-plus-08-2024")
|
147
|
+
|
148
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
149
|
+
|
150
|
+
# Stream endpoint is always streaming
|
151
|
+
awaited_wrapped = await wrapped(*args, **kwargs)
|
152
|
+
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
|
153
|
+
|
154
|
+
return TracedAsyncStream(awaited_wrapped, span, span_name, kwargs, server_address, server_port)
|
155
|
+
|
156
|
+
return wrapper
|
157
|
+
|
158
|
+
def async_embed(version, environment, application_name,
|
159
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
160
|
+
"""
|
161
|
+
Generates a telemetry wrapper for GenAI embedding function call
|
162
|
+
"""
|
163
|
+
|
164
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
165
|
+
"""
|
166
|
+
Wraps the GenAI embedding function call.
|
167
|
+
"""
|
168
|
+
|
169
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
170
|
+
request_model = kwargs.get("model", "embed-english-v3.0")
|
171
|
+
|
172
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
|
173
|
+
|
174
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
175
|
+
start_time = time.time()
|
176
|
+
response = await wrapped(*args, **kwargs)
|
177
|
+
|
178
|
+
try:
|
179
|
+
response = process_embedding_response(
|
180
|
+
response=response,
|
181
|
+
request_model=request_model,
|
182
|
+
pricing_info=pricing_info,
|
183
|
+
server_port=server_port,
|
184
|
+
server_address=server_address,
|
185
|
+
environment=environment,
|
186
|
+
application_name=application_name,
|
187
|
+
metrics=metrics,
|
188
|
+
start_time=start_time,
|
189
|
+
span=span,
|
190
|
+
capture_message_content=capture_message_content,
|
191
|
+
disable_metrics=disable_metrics,
|
192
|
+
version=version,
|
193
|
+
**kwargs
|
194
|
+
)
|
195
|
+
|
196
|
+
except Exception as e:
|
197
|
+
handle_exception(span, e)
|
198
|
+
|
199
|
+
return response
|
200
|
+
|
201
|
+
return wrapper
|
@@ -0,0 +1,201 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring Cohere 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.cohere.utils import (
|
12
|
+
process_chunk,
|
13
|
+
process_chat_response,
|
14
|
+
process_streaming_chat_response,
|
15
|
+
process_embedding_response,
|
16
|
+
)
|
17
|
+
from openlit.semcov import SemanticConvention
|
18
|
+
|
19
|
+
def chat(version, environment, application_name,
|
20
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
21
|
+
"""
|
22
|
+
Generates a telemetry wrapper for GenAI chat function call
|
23
|
+
"""
|
24
|
+
|
25
|
+
def wrapper(wrapped, instance, args, kwargs):
|
26
|
+
"""
|
27
|
+
Wraps the GenAI chat function call.
|
28
|
+
"""
|
29
|
+
|
30
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
31
|
+
request_model = kwargs.get("model", "command-r-plus-08-2024")
|
32
|
+
|
33
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
34
|
+
|
35
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
36
|
+
start_time = time.time()
|
37
|
+
response = wrapped(*args, **kwargs)
|
38
|
+
response = process_chat_response(
|
39
|
+
response=response,
|
40
|
+
request_model=request_model,
|
41
|
+
pricing_info=pricing_info,
|
42
|
+
server_port=server_port,
|
43
|
+
server_address=server_address,
|
44
|
+
environment=environment,
|
45
|
+
application_name=application_name,
|
46
|
+
metrics=metrics,
|
47
|
+
start_time=start_time,
|
48
|
+
span=span,
|
49
|
+
capture_message_content=capture_message_content,
|
50
|
+
disable_metrics=disable_metrics,
|
51
|
+
version=version,
|
52
|
+
**kwargs
|
53
|
+
)
|
54
|
+
|
55
|
+
return response
|
56
|
+
|
57
|
+
return wrapper
|
58
|
+
|
59
|
+
def chat_stream(version, environment, application_name,
|
60
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
61
|
+
"""
|
62
|
+
Generates a telemetry wrapper for GenAI chat_stream function call
|
63
|
+
"""
|
64
|
+
|
65
|
+
class TracedSyncStream:
|
66
|
+
"""
|
67
|
+
Wrapper for streaming responses to collect telemetry.
|
68
|
+
"""
|
69
|
+
|
70
|
+
def __init__(
|
71
|
+
self,
|
72
|
+
wrapped,
|
73
|
+
span,
|
74
|
+
span_name,
|
75
|
+
kwargs,
|
76
|
+
server_address,
|
77
|
+
server_port,
|
78
|
+
**args,
|
79
|
+
):
|
80
|
+
self.__wrapped__ = wrapped
|
81
|
+
self._span = span
|
82
|
+
self._span_name = span_name
|
83
|
+
self._llmresponse = ""
|
84
|
+
self._response_id = ""
|
85
|
+
self._response_model = ""
|
86
|
+
self._finish_reason = ""
|
87
|
+
self._tools = None
|
88
|
+
self._tool_plan = ""
|
89
|
+
self._input_tokens = 0
|
90
|
+
self._output_tokens = 0
|
91
|
+
|
92
|
+
self._args = args
|
93
|
+
self._kwargs = kwargs
|
94
|
+
self._start_time = time.time()
|
95
|
+
self._end_time = None
|
96
|
+
self._timestamps = []
|
97
|
+
self._ttft = 0
|
98
|
+
self._tbt = 0
|
99
|
+
self._server_address = server_address
|
100
|
+
self._server_port = server_port
|
101
|
+
|
102
|
+
def __enter__(self):
|
103
|
+
self.__wrapped__.__enter__()
|
104
|
+
return self
|
105
|
+
|
106
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
107
|
+
self.__wrapped__.__exit__(exc_type, exc_value, traceback)
|
108
|
+
|
109
|
+
def __iter__(self):
|
110
|
+
return self
|
111
|
+
|
112
|
+
def __getattr__(self, name):
|
113
|
+
"""Delegate attribute access to the wrapped object."""
|
114
|
+
return getattr(self.__wrapped__, name)
|
115
|
+
|
116
|
+
def __next__(self):
|
117
|
+
try:
|
118
|
+
chunk = self.__wrapped__.__next__()
|
119
|
+
process_chunk(self, chunk)
|
120
|
+
return chunk
|
121
|
+
except StopIteration:
|
122
|
+
try:
|
123
|
+
with tracer.start_as_current_span(self._span_name, kind= SpanKind.CLIENT) as self._span:
|
124
|
+
process_streaming_chat_response(
|
125
|
+
self,
|
126
|
+
pricing_info=pricing_info,
|
127
|
+
environment=environment,
|
128
|
+
application_name=application_name,
|
129
|
+
metrics=metrics,
|
130
|
+
capture_message_content=capture_message_content,
|
131
|
+
disable_metrics=disable_metrics,
|
132
|
+
version=version
|
133
|
+
)
|
134
|
+
|
135
|
+
except Exception as e:
|
136
|
+
handle_exception(self._span, e)
|
137
|
+
|
138
|
+
raise
|
139
|
+
|
140
|
+
def wrapper(wrapped, instance, args, kwargs):
|
141
|
+
"""
|
142
|
+
Wraps the GenAI chat_stream function call.
|
143
|
+
"""
|
144
|
+
|
145
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
146
|
+
request_model = kwargs.get("model", "command-r-plus-08-2024")
|
147
|
+
|
148
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
149
|
+
|
150
|
+
# Stream endpoint is always streaming
|
151
|
+
awaited_wrapped = wrapped(*args, **kwargs)
|
152
|
+
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
|
153
|
+
|
154
|
+
return TracedSyncStream(awaited_wrapped, span, span_name, kwargs, server_address, server_port)
|
155
|
+
|
156
|
+
return wrapper
|
157
|
+
|
158
|
+
def embed(version, environment, application_name,
|
159
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
160
|
+
"""
|
161
|
+
Generates a telemetry wrapper for GenAI embedding function call
|
162
|
+
"""
|
163
|
+
|
164
|
+
def wrapper(wrapped, instance, args, kwargs):
|
165
|
+
"""
|
166
|
+
Wraps the GenAI embedding function call.
|
167
|
+
"""
|
168
|
+
|
169
|
+
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
|
170
|
+
request_model = kwargs.get("model", "embed-english-v3.0")
|
171
|
+
|
172
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
|
173
|
+
|
174
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
175
|
+
start_time = time.time()
|
176
|
+
response = wrapped(*args, **kwargs)
|
177
|
+
|
178
|
+
try:
|
179
|
+
response = process_embedding_response(
|
180
|
+
response=response,
|
181
|
+
request_model=request_model,
|
182
|
+
pricing_info=pricing_info,
|
183
|
+
server_port=server_port,
|
184
|
+
server_address=server_address,
|
185
|
+
environment=environment,
|
186
|
+
application_name=application_name,
|
187
|
+
metrics=metrics,
|
188
|
+
start_time=start_time,
|
189
|
+
span=span,
|
190
|
+
capture_message_content=capture_message_content,
|
191
|
+
disable_metrics=disable_metrics,
|
192
|
+
version=version,
|
193
|
+
**kwargs
|
194
|
+
)
|
195
|
+
|
196
|
+
except Exception as e:
|
197
|
+
handle_exception(span, e)
|
198
|
+
|
199
|
+
return response
|
200
|
+
|
201
|
+
return wrapper
|