Spaces:
Sleeping
Sleeping
LucasAguetai
commited on
Commit
•
2679d8c
1
Parent(s):
d92c6ee
add error for no context and fix f-string error
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ siteUrl = "https://aloqas-aloqas-qa-fastapi.hf.space"
|
|
7 |
|
8 |
userContext = None
|
9 |
context = None
|
|
|
10 |
|
11 |
with st.sidebar:
|
12 |
st.title("Configuration")
|
@@ -34,7 +35,8 @@ if "messages" not in st.session_state:
|
|
34 |
if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
35 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
36 |
params = {'texte': prompt, "model": model}
|
37 |
-
|
|
|
38 |
if contextSelect == "File" and userContext:
|
39 |
# Préparation de la liste des fichiers pour l'envoi
|
40 |
files = [("file", (file.name, file, file.type)) for file in userContext]
|
@@ -47,16 +49,22 @@ if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
|
47 |
st.session_state.messages.append({"role": "assistant", "content": json.loads(response.text)["answer"]})
|
48 |
|
49 |
else:
|
50 |
-
|
51 |
|
52 |
# st.write("Statut de la requête:", response.status_code)
|
53 |
# st.write("Réponse du serveur:", response.text)
|
54 |
|
55 |
-
|
56 |
-
st.
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
60 |
|
61 |
for msg in st.session_state.messages:
|
62 |
st.chat_message(msg["role"]).write(msg["content"])
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
userContext = None
|
9 |
context = None
|
10 |
+
error = 0
|
11 |
|
12 |
with st.sidebar:
|
13 |
st.title("Configuration")
|
|
|
35 |
if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
36 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
37 |
params = {'texte': prompt, "model": model}
|
38 |
+
print(repr(userContext))
|
39 |
+
if userContext is not '':
|
40 |
if contextSelect == "File" and userContext:
|
41 |
# Préparation de la liste des fichiers pour l'envoi
|
42 |
files = [("file", (file.name, file, file.type)) for file in userContext]
|
|
|
49 |
st.session_state.messages.append({"role": "assistant", "content": json.loads(response.text)["answer"]})
|
50 |
|
51 |
else:
|
52 |
+
error = 1
|
53 |
|
54 |
# st.write("Statut de la requête:", response.status_code)
|
55 |
# st.write("Réponse du serveur:", response.text)
|
56 |
|
57 |
+
if userContext is not '':
|
58 |
+
with st.sidebar:
|
59 |
+
st.title("Statistics on the last answer")
|
60 |
+
st.write(f"Score: {round(json.loads(response.text)['score'], 3)}")
|
61 |
+
st.write(f"Start: {json.loads(response.text)["start"]}")
|
62 |
+
st.write(f"End: {json.loads(response.text)["end"]}")
|
63 |
|
64 |
for msg in st.session_state.messages:
|
65 |
st.chat_message(msg["role"]).write(msg["content"])
|
66 |
+
|
67 |
+
if error == 1:
|
68 |
+
message_rouge = "⚠️ Please provide a context via the menu on your left."
|
69 |
+
st.markdown(f'<div style="color: white; background-color: #ff4444; padding: 10px; border-radius: 5px;">{message_rouge}</div>', unsafe_allow_html=True)
|
70 |
+
error = 0
|