refactor: Padronizar a passagem de argumentos para métodos de ferramentas Captain usando um hash flexível.
This commit is contained in:
parent
6d98ff0322
commit
445a7d663a
@ -14,7 +14,8 @@ module Captain
|
|||||||
super(assistant, user: user)
|
super(assistant, user: user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(emoji:)
|
def execute(args = {})
|
||||||
|
emoji = args[:emoji] || args['emoji']
|
||||||
return error_response('Conversation not found') unless @conversation.present?
|
return error_response('Conversation not found') unless @conversation.present?
|
||||||
return error_response('Emoji is required') if emoji.blank?
|
return error_response('Emoji is required') if emoji.blank?
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ class Captain::Tools::AddContactNoteTool < Captain::Tools::BasePublicTool
|
|||||||
description 'Add a note to a contact profile'
|
description 'Add a note to a contact profile'
|
||||||
param :note, type: 'string', desc: 'The note content to add to the contact'
|
param :note, type: 'string', desc: 'The note content to add to the contact'
|
||||||
|
|
||||||
def perform(tool_context, note:)
|
def perform(tool_context, args = {})
|
||||||
|
note = args[:note] || args['note']
|
||||||
contact = find_contact(tool_context.state)
|
contact = find_contact(tool_context.state)
|
||||||
return 'Contact not found' unless contact
|
return 'Contact not found' unless contact
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ class Captain::Tools::AddLabelToConversationTool < Captain::Tools::BasePublicToo
|
|||||||
description 'Add a label to a conversation'
|
description 'Add a label to a conversation'
|
||||||
param :label_name, type: 'string', desc: 'The name of the label to add'
|
param :label_name, type: 'string', desc: 'The name of the label to add'
|
||||||
|
|
||||||
def perform(tool_context, label_name:)
|
def perform(tool_context, args = {})
|
||||||
|
label_name = args[:label_name] || args['label_name']
|
||||||
conversation = find_conversation(tool_context.state)
|
conversation = find_conversation(tool_context.state)
|
||||||
return 'Conversation not found' unless conversation
|
return 'Conversation not found' unless conversation
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ class Captain::Tools::AddPrivateNoteTool < Captain::Tools::BasePublicTool
|
|||||||
description 'Add a private note to a conversation'
|
description 'Add a private note to a conversation'
|
||||||
param :note, type: 'string', desc: 'The private note content'
|
param :note, type: 'string', desc: 'The private note content'
|
||||||
|
|
||||||
def perform(tool_context, note:)
|
def perform(tool_context, args = {})
|
||||||
|
note = args[:note] || args['note']
|
||||||
conversation = find_conversation(tool_context.state)
|
conversation = find_conversation(tool_context.state)
|
||||||
return 'Conversation not found' unless conversation
|
return 'Conversation not found' unless conversation
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ class Captain::Tools::UpdatePriorityTool < Captain::Tools::BasePublicTool
|
|||||||
description 'Update the priority of a conversation'
|
description 'Update the priority of a conversation'
|
||||||
param :priority, type: 'string', desc: 'The priority level: low, medium, high, urgent, or nil to remove priority'
|
param :priority, type: 'string', desc: 'The priority level: low, medium, high, urgent, or nil to remove priority'
|
||||||
|
|
||||||
def perform(tool_context, priority:)
|
def perform(tool_context, args = {})
|
||||||
|
priority = args[:priority] || args['priority']
|
||||||
@conversation = find_conversation(tool_context.state)
|
@conversation = find_conversation(tool_context.state)
|
||||||
return 'Conversation not found' unless @conversation
|
return 'Conversation not found' unless @conversation
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user