AbdulMoid commited on
Commit
de5845d
·
verified ·
1 Parent(s): 864b6b0

Update graph_rag.py

Browse files
Files changed (1) hide show
  1. graph_rag.py +12 -3
graph_rag.py CHANGED
@@ -64,10 +64,19 @@ def clean_response(response):
64
  search_str = "SUCCESS: Global Search Response:"
65
  start_index = response.find(search_str)
66
 
67
- # If the search string is found, return the substring starting from after this string
68
  if start_index != -1:
69
- # Add the length of search_str to start_index to begin after the search string
70
- return response[start_index + len(search_str):].strip()
 
 
 
 
 
 
 
 
 
71
  else:
72
  # If the search string is not found, return the original response
73
  return response
 
64
  search_str = "SUCCESS: Global Search Response:"
65
  start_index = response.find(search_str)
66
 
67
+ # If the search string is found, process the response from that point onward
68
  if start_index != -1:
69
+ # Extract the relevant part of the response
70
+ cleaned_response = response[start_index + len(search_str):].strip()
71
+
72
+ # Remove "[Data: Reports (XXX)]" references
73
+ pattern = r'\[Data: Reports \(\d+\)\]'
74
+ cleaned_response = re.sub(pattern, '', cleaned_response)
75
+
76
+ # Remove extra spaces that might result from the substitution
77
+ cleaned_response = re.sub(r'\s+', ' ', cleaned_response).strip()
78
+
79
+ return cleaned_response
80
  else:
81
  # If the search string is not found, return the original response
82
  return response