Spaces:
Configuration error
Configuration error
truevis commited on
Commit ·
93fdefe
1
Parent(s): 7c25d76
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,17 +115,26 @@ def reset_chat():
|
|
| 115 |
st.session_state['first_input_received'] = False
|
| 116 |
st.rerun()
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
def remove_context_tags_and_return_removed_text(text):
|
| 119 |
"""
|
| 120 |
-
Remove <context> tags and the content between them, and return
|
| 121 |
"""
|
| 122 |
-
# Find all occurrences of text within <context> tags
|
| 123 |
-
removed_texts = re.findall(r'<context>(.*?)</context>', text, flags=re.DOTALL)
|
| 124 |
# Remove <context> tags and the content between them
|
| 125 |
clean_text = re.sub(r'<context>.*?</context>', '', text, flags=re.DOTALL)
|
| 126 |
-
|
| 127 |
-
removed_text = "\n".join(removed_texts)
|
| 128 |
-
# return clean_text, removed_text.strip()
|
| 129 |
return clean_text
|
| 130 |
|
| 131 |
def clean_text(text):
|
|
|
|
| 115 |
st.session_state['first_input_received'] = False
|
| 116 |
st.rerun()
|
| 117 |
|
| 118 |
+
# def remove_context_tags_and_return_removed_text(text):
|
| 119 |
+
# """
|
| 120 |
+
# Remove <context> tags and the content between them, and return both the cleaned text and the removed content.
|
| 121 |
+
# """
|
| 122 |
+
# # Find all occurrences of text within <context> tags
|
| 123 |
+
# removed_texts = re.findall(r'<context>(.*?)</context>', text, flags=re.DOTALL)
|
| 124 |
+
# # Remove <context> tags and the content between them
|
| 125 |
+
# clean_text = re.sub(r'<context>.*?</context>', '', text, flags=re.DOTALL)
|
| 126 |
+
# # Join the removed text pieces into a single string, assuming there could be more than one <context> tag
|
| 127 |
+
# removed_text = "\n".join(removed_texts)
|
| 128 |
+
# # return clean_text, removed_text.strip()
|
| 129 |
+
# return clean_text
|
| 130 |
+
|
| 131 |
def remove_context_tags_and_return_removed_text(text):
|
| 132 |
"""
|
| 133 |
+
Remove <context> tags and the content between them, and return the cleaned text.
|
| 134 |
"""
|
|
|
|
|
|
|
| 135 |
# Remove <context> tags and the content between them
|
| 136 |
clean_text = re.sub(r'<context>.*?</context>', '', text, flags=re.DOTALL)
|
| 137 |
+
|
|
|
|
|
|
|
| 138 |
return clean_text
|
| 139 |
|
| 140 |
def clean_text(text):
|