def parse_estimated_confidence(self, message: AIMessage) -> int:
        """Parse estimated confidence from the message"""

        def find_first_integer(input_string):
            # Define a regular expression pattern to match integers
            pattern = re.compile(r"\d+")

            # Search for the first match in the input string
            match = pattern.search(input_string)

            # Check if a match is found
            if match:
                # Extract and return the matched integer
                return int(match.group())
            else:
                # Return 0 if no integer is found
                logger.info(f"\nCannot find confidence in message: {input_string}\n")
                return 0

        content = message.content.strip()

        return find_first_integer(content)
Parse estimated confidence from the message
autochain/agent/openai_functions_agent/output_parser.py