KameronB commited on
Commit
6a211f8
1 Parent(s): 09349f8

The sample code above would raise an error if the model returned improperly formatted responses before. Now it will show the actual response so you can see why re failed to parse it and it will return an object that is {'Software/System': 'Unknown', 'Issue/Request': 'Unknown'} instead of an error.

Browse files
Files changed (1) hide show
  1. README.md +17 -0
README.md CHANGED
@@ -64,7 +64,24 @@ class SITCC_T5_Classifier:
64
  Returns:
65
  dict: A dictionary containing the software/system and issue/request.
66
  """
 
 
 
 
 
 
 
 
67
  matches = re.search(r'Software/System: (.*) Issue/Request: (.*)</s>', response, re.DOTALL)
 
 
 
 
 
 
 
 
 
68
  return {
69
  "Software/System": matches.group(1),
70
  "Issue/Request": matches.group(2)
 
64
  Returns:
65
  dict: A dictionary containing the software/system and issue/request.
66
  """
67
+ # handle null input
68
+ if not response:
69
+ print("Error: Response is empty")
70
+ return {
71
+ "Software/System": "Unknown",
72
+ "Issue/Request": "Unknown"
73
+ }
74
+
75
  matches = re.search(r'Software/System: (.*) Issue/Request: (.*)</s>', response, re.DOTALL)
76
+
77
+ # handle improperly formatted responses
78
+ # TODO: Provide more robust improper format handing
79
+ if not matches or len(matches.groups()) < 2:
80
+ print(f"Error: Response format does not match expected format \"Software/System: (.*) Issue/Request: (.*)</s>\"\nResponse: \"{response}\" ")
81
+ return {
82
+ "Software/System": "Unknown",
83
+ "Issue/Request": "Unknown"
84
+ }
85
  return {
86
  "Software/System": matches.group(1),
87
  "Issue/Request": matches.group(2)