Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,6 +162,9 @@ def add_paper_buttons_and_links():
|
|
| 162 |
|
| 163 |
add_paper_buttons_and_links()
|
| 164 |
|
|
|
|
|
|
|
|
|
|
| 165 |
def process_user_input(user_question):
|
| 166 |
response = st.session_state.conversation({'question': user_question})
|
| 167 |
st.session_state.chat_history = response['chat_history']
|
|
@@ -178,19 +181,25 @@ def process_user_input(user_question):
|
|
| 178 |
create_expanders_and_buttons(message.content)
|
| 179 |
|
| 180 |
def create_expanders_and_buttons(content):
|
| 181 |
-
# Split the content into
|
| 182 |
-
|
| 183 |
-
for
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
detail = " ".join(lines[1:]).strip()
|
| 188 |
-
|
| 189 |
with st.expander(header, expanded=False):
|
| 190 |
if st.button(f"Explore {header}"):
|
| 191 |
expanded_outline = "Expand on the feature: " + detail
|
| 192 |
chat_with_model(expanded_outline, header)
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
|
| 196 |
def process_user_input_old(user_question):
|
|
|
|
| 162 |
|
| 163 |
add_paper_buttons_and_links()
|
| 164 |
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# Process user input is a post processor algorithm which runs after document embedding vector DB play of GPT on context of documents..
|
| 168 |
def process_user_input(user_question):
|
| 169 |
response = st.session_state.conversation({'question': user_question})
|
| 170 |
st.session_state.chat_history = response['chat_history']
|
|
|
|
| 181 |
create_expanders_and_buttons(message.content)
|
| 182 |
|
| 183 |
def create_expanders_and_buttons(content):
|
| 184 |
+
# Split the content into paragraphs
|
| 185 |
+
paragraphs = content.split("\n\n")
|
| 186 |
+
for paragraph in paragraphs:
|
| 187 |
+
# Identify the header and detail in the paragraph
|
| 188 |
+
header, detail = extract_feature_and_detail(paragraph)
|
| 189 |
+
if header and detail:
|
|
|
|
|
|
|
| 190 |
with st.expander(header, expanded=False):
|
| 191 |
if st.button(f"Explore {header}"):
|
| 192 |
expanded_outline = "Expand on the feature: " + detail
|
| 193 |
chat_with_model(expanded_outline, header)
|
| 194 |
|
| 195 |
+
def extract_feature_and_detail(paragraph):
|
| 196 |
+
# Use regex to find the header and detail in the paragraph
|
| 197 |
+
match = re.match(r"(.*?):(.*)", paragraph)
|
| 198 |
+
if match:
|
| 199 |
+
header = match.group(1).strip()
|
| 200 |
+
detail = match.group(2).strip()
|
| 201 |
+
return header, detail
|
| 202 |
+
return None, None
|
| 203 |
|
| 204 |
|
| 205 |
def process_user_input_old(user_question):
|