fix(captain): aceita DD/MM sem ano e amplia tratamento de requires_input no generate_pix
Problema observado: Daniela chamou generate_pix com arguments vazios apos cliente informar "27/4". Tool retornou missing_fields=[check_in, amount] e LLM caiu no fallback silenciosamente. Correcoes: - DDMMYYYY_REGEX agora aceita "DD/MM" sem ano (assume ano corrente, empurra pro proximo ano se a data ja passou) - parse_date_without_year com fallback explicito - Instruction da scenario Daniela_Reservas (DB, scenario_id=2) atualizada para listar todos os 4 parametros obrigatorios de generate_pix e distinguir requires_input (erro do LLM) de success=false (erro tecnico) Backup da instruction anterior: /tmp/daniela_instruction_backup_20260418.txt Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1c21b8d815
commit
6a5ba17bfc
@ -4,7 +4,7 @@ class Captain::Tools::GeneratePixTool < Captain::Tools::BaseTool
|
|||||||
NAME_WITH_LABEL_REGEX = /nome\s*[:\-]\s*([^\n\r,;]+)/i
|
NAME_WITH_LABEL_REGEX = /nome\s*[:\-]\s*([^\n\r,;]+)/i
|
||||||
EMAIL_REGEX = /\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b/
|
EMAIL_REGEX = /\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b/
|
||||||
SUITE_REGEX = /su[ií]te\s+([^\n\r,.!?]+)/i
|
SUITE_REGEX = /su[ií]te\s+([^\n\r,.!?]+)/i
|
||||||
DDMMYYYY_REGEX = %r{\b(\d{1,2}/\d{1,2}/\d{2,4})\b}
|
DDMMYYYY_REGEX = %r{\b(\d{1,2}/\d{1,2}(?:/\d{2,4})?)\b}
|
||||||
CURRENCY_REGEX = /r\$\s*([\d.,]+)/i
|
CURRENCY_REGEX = /r\$\s*([\d.,]+)/i
|
||||||
TOTAL_AMOUNT_REGEX = /valor\s+total[^\n\r]{0,80}/i
|
TOTAL_AMOUNT_REGEX = /valor\s+total[^\n\r]{0,80}/i
|
||||||
DEPOSIT_AMOUNT_REGEX = /(sinal|entrada)[^\n\r]{0,80}/i
|
DEPOSIT_AMOUNT_REGEX = /(sinal|entrada)[^\n\r]{0,80}/i
|
||||||
@ -611,11 +611,24 @@ class Captain::Tools::GeneratePixTool < Captain::Tools::BaseTool
|
|||||||
begin
|
begin
|
||||||
Date.iso8601(string_value)
|
Date.iso8601(string_value)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
nil
|
parse_date_without_year(string_value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# DD/MM sem ano — assume ano corrente; se a data já passou, empurra para o próximo ano
|
||||||
|
def parse_date_without_year(string_value)
|
||||||
|
match = string_value.match(%r{\A(\d{1,2})/(\d{1,2})\z})
|
||||||
|
return nil unless match
|
||||||
|
|
||||||
|
day = match[1].to_i
|
||||||
|
month = match[2].to_i
|
||||||
|
candidate = Date.new(account_current_date.year, month, day)
|
||||||
|
candidate < account_current_date ? candidate.next_year : candidate
|
||||||
|
rescue ArgumentError
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def normalize_check_in_datetime(value)
|
def normalize_check_in_datetime(value)
|
||||||
return if value.blank?
|
return if value.blank?
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user