Spaces:
Sleeping
Sleeping
LucasAguetai
commited on
Commit
·
5b4d076
1
Parent(s):
28ac775
fix chat issue
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import streamlit as st
|
|
|
4 |
|
5 |
siteUrl = "https://aloqas-aloqas-qa-fastapi.hf.space"
|
6 |
|
@@ -29,12 +30,8 @@ if "messages" not in st.session_state:
|
|
29 |
{"role": "assistant", "content": "Hi, I'm ALOQAS. How can I help you?"}
|
30 |
]
|
31 |
|
32 |
-
for msg in st.session_state.messages:
|
33 |
-
st.chat_message(msg["role"]).write(msg["content"])
|
34 |
-
|
35 |
if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
36 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
37 |
-
st.chat_message("user").write(prompt)
|
38 |
params = {'texte': prompt, "model": model}
|
39 |
if userContext is not None:
|
40 |
if contextSelect == "File" and userContext:
|
@@ -43,9 +40,15 @@ if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
|
43 |
response = requests.post(siteUrl + context, params=params, files=files)
|
44 |
else:
|
45 |
params["context"] = userContext
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
else:
|
48 |
response = requests.post(siteUrl + '/withoutFile/', params=params)
|
49 |
|
50 |
-
|
51 |
-
st.write("
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import streamlit as st
|
4 |
+
import json
|
5 |
|
6 |
siteUrl = "https://aloqas-aloqas-qa-fastapi.hf.space"
|
7 |
|
|
|
30 |
{"role": "assistant", "content": "Hi, I'm ALOQAS. How can I help you?"}
|
31 |
]
|
32 |
|
|
|
|
|
|
|
33 |
if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
|
34 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
|
|
35 |
params = {'texte': prompt, "model": model}
|
36 |
if userContext is not None:
|
37 |
if contextSelect == "File" and userContext:
|
|
|
40 |
response = requests.post(siteUrl + context, params=params, files=files)
|
41 |
else:
|
42 |
params["context"] = userContext
|
43 |
+
request_url = f"{siteUrl}/{model.lower()}/?context={userContext}&question={prompt}"
|
44 |
+
response = requests.post(request_url)
|
45 |
+
print(response.text)
|
46 |
+
st.session_state.messages.append({"role": "assistant", "content": json.loads(response.text)["answer"]})
|
47 |
+
|
48 |
else:
|
49 |
response = requests.post(siteUrl + '/withoutFile/', params=params)
|
50 |
|
51 |
+
for msg in st.session_state.messages:
|
52 |
+
st.chat_message(msg["role"]).write(msg["content"])
|
53 |
+
# st.write("Statut de la requête:", response.status_code)
|
54 |
+
# st.write("Réponse du serveur:", response.text)
|