Spaces:
Runtime error
Runtime error
Update graph_rag.py
Browse files- 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,
|
| 68 |
if start_index != -1:
|
| 69 |
-
#
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|