AttributeError: 'NoneType' object has no attribute 'group'

#1
by Daaaku - opened

Im trying to perform the classification of 4 row dataset that i made. When i try to pass it through the function, it get an error.

image.png

image.png

Owner

Thank you!

The cause of this issue is that the model is not returning a correctly formatted response that can be parsed with the regex. I made a change to the script in the model card that checks when the output is improperly formatted, prints the raw output, and returns an {'Software/System': 'Unknown', 'Issue/Request': 'Unknown'} object.

Also, It seems that your input data is for more of a sentiment analysis project, which this model will not handle well. This model is specifically designed to read the tickets and determine what the IT issue or request is. (Software install, broken monitor, software freezing, etc. )
I am working on a different model that is specifically for IT tickets sentiment analysis though, I will paste a link to that here when it is ready.

The new process_response function

  def process_response(self, response:str) -> dict:
    """
    Process the response and extract the software/system and issue/request.

    Args:
    response (str): The response text.

    Returns:
    dict: A dictionary containing the software/system and issue/request.
    """
    # handle null input
    if not response:
      print("Error: Response is empty")
      return {
        "Software/System": "Unknown",
        "Issue/Request": "Unknown"
      }

    matches = re.search(r'Software/System: (.*) Issue/Request: (.*)</s>', response, re.DOTALL)
    
    # handle improperly formatted responses
    # TODO: Provide more robust improper format handing
    if not matches or len(matches.groups()) < 2:
      print(f"Error: Response format does not match expected format \"Software/System: (.*) Issue/Request: (.*)</s>\"\nResponse: \"{response}\" ")
      return {
        "Software/System": "Unknown",
        "Issue/Request": "Unknown"
      }
    return {
      "Software/System": matches.group(1),
      "Issue/Request": matches.group(2)
    }

Sign up or log in to comment