Skip to content

Commit 9563e88

Browse files
refactor(tracing): streamline input extraction in OCI tracer
- Updated the `extract_inputs_from_chat_details` function to convert message roles to lowercase for consistency with OpenAI format. - Removed commented-out code related to system message extraction to enhance code clarity and maintainability.
1 parent 6a8d0e3 commit 9563e88

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/openlayer/lib/integrations/oci_tracer.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
try:
1010
import oci
1111
from oci.generative_ai_inference import GenerativeAiInferenceClient
12-
from oci.generative_ai_inference.models import GenericChatRequest, ChatDetails
13-
1412
HAVE_OCI = True
1513
except ImportError:
1614
HAVE_OCI = False
@@ -380,8 +378,8 @@ def extract_inputs_from_chat_details(chat_details) -> Dict[str, Any]:
380378
if hasattr(chat_request, "messages") and chat_request.messages:
381379
messages = []
382380
for msg in chat_request.messages:
383-
# Extract role
384-
role = getattr(msg, "role", "USER")
381+
# Extract role and convert to OpenAI format (lowercase)
382+
role = getattr(msg, "role", "USER").lower()
385383

386384
# Extract content text
387385
content_text = ""
@@ -402,10 +400,6 @@ def extract_inputs_from_chat_details(chat_details) -> Dict[str, Any]:
402400

403401
inputs["prompt"] = messages
404402

405-
# Extract system message if present
406-
if hasattr(chat_request, "system_message") and chat_request.system_message:
407-
inputs["system"] = chat_request.system_message
408-
409403
# Extract tools if present
410404
if hasattr(chat_request, "tools") and chat_request.tools:
411405
inputs["tools"] = chat_request.tools

0 commit comments

Comments
 (0)