Spaces:
Sleeping
Sleeping
Update app.py
Browse filesRemoved unused comments. Moved updating of placeholder outside the loop and collect response first before updating placeholder.
app.py
CHANGED
|
@@ -50,16 +50,10 @@ def handle_submit():
|
|
| 50 |
user_input = st.session_state.user_input
|
| 51 |
|
| 52 |
if user_input:
|
| 53 |
-
#if st.session_state.include_context:
|
| 54 |
messages = [
|
| 55 |
{"role": "system", "content": f"Context: {context}"},
|
| 56 |
{"role": "user", "content": user_input}
|
| 57 |
]
|
| 58 |
-
#else:
|
| 59 |
-
# messages = [
|
| 60 |
-
# {"role": "system", "content": f"Context: Adrega is a powerful project management and reporting tool. It can show Gantt diagrams, S-Curves, Tabular reports and various charts in single reports, report bundles or in a customizable dashboard."},
|
| 61 |
-
# {"role": "user", "content": user_input}
|
| 62 |
-
# ]
|
| 63 |
|
| 64 |
response = client.chat.completions.create(
|
| 65 |
model="Qwen/Qwen2.5-72B-Instruct",
|
|
@@ -71,21 +65,17 @@ def handle_submit():
|
|
| 71 |
answer = ""
|
| 72 |
for chunk in response:
|
| 73 |
answer += chunk['choices'][0]['delta']['content']
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
else:
|
| 79 |
st.session_state.conversation(f"<p><strong>Adrega AI:</strong>: Please enter a question.")
|
| 80 |
|
| 81 |
st.text_input('Ask me a question', key='user_input', on_change=handle_submit)
|
| 82 |
-
|
| 83 |
-
#with col1:
|
| 84 |
if st.button("Ask"):
|
| 85 |
handle_submit()
|
| 86 |
|
| 87 |
if 'conversation' not in st.session_state:
|
| 88 |
st.session_state.conversation = ""
|
| 89 |
-
|
| 90 |
-
#with col2:
|
| 91 |
-
# st.session_state.include_context = st.checkbox('Search in Help')
|
|
|
|
| 50 |
user_input = st.session_state.user_input
|
| 51 |
|
| 52 |
if user_input:
|
|
|
|
| 53 |
messages = [
|
| 54 |
{"role": "system", "content": f"Context: {context}"},
|
| 55 |
{"role": "user", "content": user_input}
|
| 56 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
response = client.chat.completions.create(
|
| 59 |
model="Qwen/Qwen2.5-72B-Instruct",
|
|
|
|
| 65 |
answer = ""
|
| 66 |
for chunk in response:
|
| 67 |
answer += chunk['choices'][0]['delta']['content']
|
| 68 |
+
|
| 69 |
+
placeholder.markdown(f'<div class="scrollable-div"><p>{answer}</p></div>', unsafe_allow_html=True)
|
| 70 |
+
st.session_state.conversation = f"<p>{answer}</p>" + st.session_state.conversation
|
| 71 |
|
| 72 |
else:
|
| 73 |
st.session_state.conversation(f"<p><strong>Adrega AI:</strong>: Please enter a question.")
|
| 74 |
|
| 75 |
st.text_input('Ask me a question', key='user_input', on_change=handle_submit)
|
| 76 |
+
|
|
|
|
| 77 |
if st.button("Ask"):
|
| 78 |
handle_submit()
|
| 79 |
|
| 80 |
if 'conversation' not in st.session_state:
|
| 81 |
st.session_state.conversation = ""
|
|
|
|
|
|
|
|
|