LucasAguetai commited on
Commit
7b7b42e
1 Parent(s): 1d71dd5

upgrade limit error

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -8,6 +8,7 @@ siteUrl = "https://aloqas-aloqas-qa-fastapi.hf.space"
8
  userContext = None
9
  context = None
10
  error = 0
 
11
 
12
  with st.sidebar:
13
  st.title("Configuration")
@@ -35,7 +36,7 @@ if "messages" not in st.session_state:
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
- if userContext != '' and len(userContext) <= 9000:
39
  if contextSelect == "File" and userContext:
40
  # Préparation de la liste des fichiers pour l'envoi
41
  files = [("file", (file.name, file, file.type)) for file in userContext]
@@ -56,7 +57,7 @@ if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
56
  # st.write("Statut de la requête:", response.status_code)
57
  # st.write("Réponse du serveur:", response.text)
58
 
59
- if userContext != '' and len(userContext) <= 9000:
60
  with st.sidebar:
61
  st.title("Statistics on the last answer")
62
  st.write(f"Score: {round(json.loads(response.text)['score'], 3)}")
@@ -71,6 +72,6 @@ if error == 1:
71
  st.markdown(f'<div style="color: white; background-color: #ff4444; padding: 10px; border-radius: 5px;">{message_rouge}</div>', unsafe_allow_html=True)
72
  error = 0
73
  elif error == 2:
74
- message_rouge = "⚠️ Please provide a context less than 9000 caractere."
75
  st.markdown(f'<div style="color: white; background-color: #ff4444; padding: 10px; border-radius: 5px;">{message_rouge}</div>', unsafe_allow_html=True)
76
  error = 0
 
8
  userContext = None
9
  context = None
10
  error = 0
11
+ limit = 9000
12
 
13
  with st.sidebar:
14
  st.title("Configuration")
 
36
  if prompt := st.chat_input(placeholder="Write to ALOQAS..."):
37
  st.session_state.messages.append({"role": "user", "content": prompt})
38
  params = {'texte': prompt, "model": model}
39
+ if userContext != '' and len(userContext) <= limit:
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]
 
57
  # st.write("Statut de la requête:", response.status_code)
58
  # st.write("Réponse du serveur:", response.text)
59
 
60
+ if userContext != '' and len(userContext) <= limit:
61
  with st.sidebar:
62
  st.title("Statistics on the last answer")
63
  st.write(f"Score: {round(json.loads(response.text)['score'], 3)}")
 
72
  st.markdown(f'<div style="color: white; background-color: #ff4444; padding: 10px; border-radius: 5px;">{message_rouge}</div>', unsafe_allow_html=True)
73
  error = 0
74
  elif error == 2:
75
+ message_rouge = f"⚠️ The message you submitted was too long, please reload the conversation and submit something shorter than {limit} caracter."
76
  st.markdown(f'<div style="color: white; background-color: #ff4444; padding: 10px; border-radius: 5px;">{message_rouge}</div>', unsafe_allow_html=True)
77
  error = 0