Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/langchain/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def handle_user_or_tool_message
end

def set_state_for(response:)
if response.tool_calls.any?
if response.tool_calls&.any?
:in_progress
elsif response.chat_completion
:completed
Expand Down
3 changes: 2 additions & 1 deletion lib/langchain/assistant/llm/adapters/openai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def build_chat_params(
# @param tool_calls [Array] The tool calls
# @param tool_call_id [String] The tool call ID
# @return [Messages::OpenAIMessage] The OpenAI message
def build_message(role:, content: nil, image_url: nil, tool_calls: [], tool_call_id: nil)
def build_message(role:, content: nil, image_url: nil, tool_calls: nil, tool_call_id: nil)
tool_calls ||= []
Messages::OpenAIMessage.new(role: role, content: content, image_url: image_url, tool_calls: tool_calls, tool_call_id: tool_call_id)
end

Expand Down