Update app.py
Browse files
app.py
CHANGED
|
@@ -86,10 +86,6 @@ MAX_TOKEN_LIMIT = 400
|
|
| 86 |
|
| 87 |
import random
|
| 88 |
|
| 89 |
-
def generate_dynamic_question(text_chunks):
|
| 90 |
-
# Randomly pick a sentence from the text chunks and frame a question
|
| 91 |
-
random_sentence = random.choice(text_chunks)
|
| 92 |
-
return f"What is the significance of: '{random_sentence}'?"
|
| 93 |
|
| 94 |
def display_example_questions(dynamic_question):
|
| 95 |
if not st.session_state['chat_history']:
|
|
@@ -119,8 +115,6 @@ def main():
|
|
| 119 |
}
|
| 120 |
</style>
|
| 121 |
""", unsafe_allow_html=True)
|
| 122 |
-
|
| 123 |
-
dynamic_question = "No question generated yet." # Initialize the variable here
|
| 124 |
|
| 125 |
if "chat_history" not in st.session_state:
|
| 126 |
st.session_state['chat_history'] = []
|
|
@@ -153,10 +147,6 @@ def main():
|
|
| 153 |
filtered_response = remove_incomplete_sentences(response)
|
| 154 |
filtered_response = remove_redundant_information(filtered_response)
|
| 155 |
|
| 156 |
-
# Dynamic question generation and display example questions
|
| 157 |
-
dynamic_question = generate_dynamic_question(chunks)
|
| 158 |
-
display_example_questions(dynamic_question)
|
| 159 |
-
|
| 160 |
st.session_state['chat_history'].append(("Bot", filtered_response, "new"))
|
| 161 |
|
| 162 |
new_messages = st.session_state['chat_history'][-2:]
|
|
@@ -172,6 +162,15 @@ def main():
|
|
| 172 |
|
| 173 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
# JavaScript for handling question box clicks
|
| 176 |
st.markdown("""
|
| 177 |
<script>
|
|
@@ -187,12 +186,8 @@ def main():
|
|
| 187 |
document.querySelector('input').value = 'Was sind die Vorteile des ambulanten operierens?';
|
| 188 |
document.querySelector('input').dispatchEvent(new Event('change'));
|
| 189 |
};
|
| 190 |
-
document.getElementById('question4').onclick = function() {
|
| 191 |
-
document.querySelector('input').value = 'AI Generated Question: ' + '{0}';
|
| 192 |
-
document.querySelector('input').dispatchEvent(new Event('change'));
|
| 193 |
-
};
|
| 194 |
</script>
|
| 195 |
-
"""
|
| 196 |
|
| 197 |
if __name__ == "__main__":
|
| 198 |
main()
|
|
|
|
| 86 |
|
| 87 |
import random
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
def display_example_questions(dynamic_question):
|
| 91 |
if not st.session_state['chat_history']:
|
|
|
|
| 115 |
}
|
| 116 |
</style>
|
| 117 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 118 |
|
| 119 |
if "chat_history" not in st.session_state:
|
| 120 |
st.session_state['chat_history'] = []
|
|
|
|
| 147 |
filtered_response = remove_incomplete_sentences(response)
|
| 148 |
filtered_response = remove_redundant_information(filtered_response)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
st.session_state['chat_history'].append(("Bot", filtered_response, "new"))
|
| 151 |
|
| 152 |
new_messages = st.session_state['chat_history'][-2:]
|
|
|
|
| 162 |
|
| 163 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
| 164 |
|
| 165 |
+
# Displaying example questions
|
| 166 |
+
if not st.session_state['chat_history']:
|
| 167 |
+
st.markdown("""
|
| 168 |
+
<div class="question-box" id="question1">Was genau ist ein Belegarzt?</div>
|
| 169 |
+
<div class="question-box" id="question2">Wofür wird die Alpha-ID verwendet?</div>
|
| 170 |
+
<br>
|
| 171 |
+
<div class="question-box" id="question3">Was sind die Vorteile des ambulanten operierens?</div>
|
| 172 |
+
""", unsafe_allow_html=True)
|
| 173 |
+
|
| 174 |
# JavaScript for handling question box clicks
|
| 175 |
st.markdown("""
|
| 176 |
<script>
|
|
|
|
| 186 |
document.querySelector('input').value = 'Was sind die Vorteile des ambulanten operierens?';
|
| 187 |
document.querySelector('input').dispatchEvent(new Event('change'));
|
| 188 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
</script>
|
| 190 |
+
""", unsafe_allow_html=True)
|
| 191 |
|
| 192 |
if __name__ == "__main__":
|
| 193 |
main()
|