openlit 1.34.16__py3-none-any.whl → 1.34.17__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,80 +1,88 @@
1
- # pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
2
1
  """Initializer of Auto Instrumentation of Mistral 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.mistral.mistral import chat, chat_stream, embeddings
9
- from openlit.instrumentation.mistral.async_mistral import async_chat, async_chat_stream
10
- from openlit.instrumentation.mistral.async_mistral import async_embeddings
8
+ from openlit.instrumentation.mistral.mistral import (
9
+ complete,
10
+ stream,
11
+ embed
12
+ )
13
+ from openlit.instrumentation.mistral.async_mistral import (
14
+ async_complete,
15
+ async_stream,
16
+ async_embed
17
+ )
11
18
 
12
19
  _instruments = ("mistralai >= 1.0.0",)
13
20
 
14
21
  class MistralInstrumentor(BaseInstrumentor):
15
- """An instrumentor for Mistral's client library."""
22
+ """
23
+ An instrumentor for Mistral 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("mistralai")
29
38
 
30
- # sync
39
+ # sync chat completions
31
40
  wrap_function_wrapper(
32
- "mistralai.chat",
33
- "Chat.complete",
34
- chat(version, environment, application_name,
35
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
41
+ "mistralai.chat",
42
+ "Chat.complete",
43
+ complete(version, environment, application_name,
44
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
36
45
  )
37
46
 
38
- # sync
47
+ # sync chat streaming
39
48
  wrap_function_wrapper(
40
- "mistralai.chat",
41
- "Chat.stream",
42
- chat_stream(version, environment, application_name,
43
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
49
+ "mistralai.chat",
50
+ "Chat.stream",
51
+ stream(version, environment, application_name,
52
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
44
53
  )
45
54
 
46
- # sync
55
+ # sync embeddings
47
56
  wrap_function_wrapper(
48
- "mistralai.embeddings",
49
- "Embeddings.create",
50
- embeddings(version, environment, application_name,
51
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
57
+ "mistralai.embeddings",
58
+ "Embeddings.create",
59
+ embed(version, environment, application_name,
60
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
52
61
  )
53
62
 
54
- # Async
63
+ # async chat completions
55
64
  wrap_function_wrapper(
56
- "mistralai.chat",
57
- "Chat.complete_async",
58
- async_chat(version, environment, application_name,
59
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
65
+ "mistralai.chat",
66
+ "Chat.complete_async",
67
+ async_complete(version, environment, application_name,
68
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
60
69
  )
61
70
 
62
- # Async
71
+ # async chat streaming
63
72
  wrap_function_wrapper(
64
- "mistralai.chat",
65
- "Chat.stream_async",
66
- async_chat_stream(version, environment, application_name,
67
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
73
+ "mistralai.chat",
74
+ "Chat.stream_async",
75
+ async_stream(version, environment, application_name,
76
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
68
77
  )
69
78
 
70
- #sync
79
+ # async embeddings
71
80
  wrap_function_wrapper(
72
- "mistralai.embeddings",
73
- "Embeddings.create_async",
74
- async_embeddings(version, environment, application_name,
75
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
81
+ "mistralai.embeddings",
82
+ "Embeddings.create_async",
83
+ async_embed(version, environment, application_name,
84
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
76
85
  )
77
86
 
78
- @staticmethod
79
87
  def _uninstrument(self, **kwargs):
80
88
  pass