File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 6
6
"trace_anthropic" ,
7
7
"trace_openai" ,
8
8
"trace_openai_assistant_thread_run" ,
9
+ "trace_oci_genai" ,
9
10
"trace_mistral" ,
10
11
"trace_groq" ,
11
12
"trace_async_openai" ,
12
13
"trace_async" ,
13
14
"trace_bedrock" ,
14
- ]
15
+ ]
15
16
16
17
# ---------------------------------- Tracing --------------------------------- #
17
18
from .tracing import tracer
@@ -103,3 +104,23 @@ def trace_bedrock(client):
103
104
if not hasattr (client , "_service_model" ) or client ._service_model .service_name != "bedrock-runtime" :
104
105
raise ValueError ("Invalid client. Please provide a boto3 bedrock-runtime client." )
105
106
return bedrock_tracer .trace_bedrock (client )
107
+
108
+ def trace_oci_genai (client , estimate_tokens : bool = True ):
109
+ """Trace OCI GenAI chat completions.
110
+
111
+ Args:
112
+ client: OCI GenAI client.
113
+ estimate_tokens: Whether to estimate tokens when not available. Defaults to True.
114
+ """
115
+ # pylint: disable=import-outside-toplevel
116
+ try :
117
+ import oci
118
+ except ImportError :
119
+ raise ImportError ("oci is required for OCI GenAI tracing. Install with: pip install oci" )
120
+
121
+ from .integrations import oci_tracer
122
+
123
+ if not isinstance (client , oci .generative_ai_inference .GenerativeAiInferenceClient ):
124
+ raise ValueError ("Invalid client. Please provide an OCI GenAI client." )
125
+
126
+ return oci_tracer .trace_oci_genai (client , estimate_tokens = estimate_tokens )
You can’t perform that action at this time.
0 commit comments