...chars > 0 else text_full

            user_prompt = USER_TEMPLATE.replace("{extract_text}", text)

            raw = ""
            repaired_raw = ""
            t0 = time.time()

            # retry plan
            attempt = 0
            curr_max_chars = args.max_chars if args.max_chars and args.max_chars > 0 else 0
            curr_num_predict = int(args.num_predict)

            last_err = ""

  ...