Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions libs/oci/langchain_oci/chat_models/oci_generative_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ def convert_oci_tool_call_to_langchain(tool_call: Any) -> ToolCall:
# If it's not valid JSON, keep it as a string
pass

if "id" in tool_call.attribute_map and tool_call.id:
id = tool_call.id
else:
id = uuid.uuid4().hex

return ToolCall(
name=tool_call.name,
args=parsed
if "arguments" in tool_call.attribute_map
else tool_call.parameters,
id=tool_call.id if "id" in tool_call.attribute_map else uuid.uuid4().hex[:],
id=id,
)

@staticmethod
Expand Down Expand Up @@ -815,7 +820,12 @@ def messages_to_oci_params(
message.tool_calls or message.additional_kwargs.get("tool_calls")
):
# Process content and tool calls for assistant messages
content = self._process_message_content(message.content)
if message.content:
content = self._process_message_content(message.content)
# Issue 78 fix: Check if original content is empty BEFORE processing
# to prevent NullPointerException in OCI backend
else:
content = [self.oci_chat_message_text_content(text=".")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so there has to be an arbitrary character in the the text?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tried to use an empty space as the content, but empty space does not work.

tool_calls = []
for tool_call in message.tool_calls:
tool_calls.append(
Expand Down