mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
* Pi's message. * Fix most everything. * Blacked * Add Typing, Docstrings everywhere, organize the code a bit. * Black * fix import * Update message, dedupe. * Increase backoff time. * bump up retries
21 lines
565 B
Python
21 lines
565 B
Python
"""Utilities for the json_fixes package."""
|
|
import re
|
|
|
|
|
|
def extract_char_position(error_message: str) -> int:
|
|
"""Extract the character position from the JSONDecodeError message.
|
|
|
|
Args:
|
|
error_message (str): The error message from the JSONDecodeError
|
|
exception.
|
|
|
|
Returns:
|
|
int: The character position.
|
|
"""
|
|
|
|
char_pattern = re.compile(r"\(char (\d+)\)")
|
|
if match := char_pattern.search(error_message):
|
|
return int(match[1])
|
|
else:
|
|
raise ValueError("Character position not found in the error message.")
|