Update pergunte_2.py
Browse files556 unmodified lines557558559560561562563564565566567568569570571572573574575576577578556 unmodified linesdef to_dec(v):return None if v is None else Decimal(str(v))if tool_call["tool"] == "calc_progressivo":base = to_dec(args.get("base", 0))brackets = [{"up_to": to_dec(b["up_to"]), "rate": to_dec(b["rate"])} for b in args.get("brackets", [])]result = func(base, brackets)elif tool_call["tool"] == "calc_irpfm_dividendos":total_mes = to_dec(args.get("total_mes", 0))result = func(total_mes)else: # "irrf_mensal_estimado"gross = to_dec(args.get("gross", 0))inss = to_dec(args.get("inss")) if args.get("inss") is not None else Nonedep = int(args.get("dependentes", 0) or 0)usar = bool(args.get("usar_simplificado", True))result = func(gross, inss, dep, usar)# 6) Segunda passada do LLM (com histórico + resultado da ferramenta)final_prompt = ChatPromptTemplate.from_messages([("system", system_text),556 unmodified lines557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591556 unmodified linesdef to_dec(v):return None if v is None else Decimal(str(v))tool_name = tool_call["tool"]if tool_name == "calc_progressivo":base = to_dec(args.get("base", 0))brackets = [{"up_to": to_dec(b["up_to"]), "rate": to_dec(b["rate"])}for b in args.get("brackets", [])]result = func(base, brackets)elif tool_name == "calc_irpfm_dividendos":total_mes = to_dec(args.get("total_mes", 0))result = func(total_mes)elif tool_name == "calc_irpfm":rendimento_anual = to_dec(args.get("rendimento_anual", 0))result = func(rendimento_anual)elif tool_name == "irrf_mensal_estimado":gross = to_dec(args.get("gross", 0))inss = to_dec(args.get("inss")) if args.get("inss") is not None else Nonedep = int(args.get("dependentes", 0) or 0)usar = bool(args.get("usar_simplificado", True))result = func(gross, inss, dep, usar)else:# fallback de segurança: se por algum motivo vier uma ferramenta desconhecidareturn _strip_resultado_if_no_calc(first)# 6) Segunda passada do LLM (com histórico + resultado da ferramenta)final_prompt = ChatPromptTemplate.from_messages([("system", system_text),
pergunte_2.py+17-4