openlit 1.34.16__py3-none-any.whl → 1.34.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 chat, chat_stream, embed
9
- from openlit.instrumentation.cohere.async_cohere import async_chat, async_chat_stream, async_embed
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
- """An instrumentor for Cohere's client library."""
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
- # Sync Client
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
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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
- # Async Client
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
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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