Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from utils import generate_titles | |
| import logging | |
| st.header("Exemple de titrage automatique") | |
| st.image("assets/cour-de-cassation.png") | |
| url_input = st.text_input( | |
| label="Entrez l'URL d'une décision sur le site de la cour de cassation", | |
| placeholder="https://www.courdecassation.fr/decision", | |
| ) | |
| n_titles = st.number_input( | |
| label="Choisissez un nombre de titres", min_value=1, max_value=10, value=3 | |
| ) | |
| def check_url_input(url): | |
| url_splits = url.split("/") | |
| # checking the URL | |
| if len(url_splits) != 5: | |
| logging.debug("URL is not long enough") | |
| return False | |
| if url_splits[0] != "https:": | |
| logging.debug("URL does not contain 'https:'") | |
| return False | |
| if url_splits[2] not in ["www.courdecassation.fr", "courdecassation.fr"]: | |
| logging.debug("URL does not refer to 'courdecassation.fr'") | |
| return False | |
| if url_splits[3] != "decision": | |
| logging.debug("URL does not contain 'decision'") | |
| return False | |
| # checking the judilibre id | |
| try: | |
| int(url_splits[4], base=16) | |
| logging.debug("Decision ID is not the right format") | |
| except ValueError: | |
| return False | |
| return True | |
| if check_url_input(url_input): | |
| judilibre_id = url_input.split("/")[-1] | |
| st.text(f"Voici {n_titles} titres pour la décision {url_input}") | |
| for i, title in enumerate(generate_titles(decision="", n_titles=int(n_titles))): | |
| st.text(f"({i+1:02}) {title}") | |
| else: | |
| st.warning("L'URL n'est pas conforme...") | |