62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
import os
|
|
|
|
import dotenv
|
|
import requests
|
|
import streamlit as st
|
|
|
|
dotenv.load_dotenv()
|
|
|
|
# Set the backend API base URL
|
|
BACKEND_URL = os.environ.get("BACKEND_URL")
|
|
|
|
# Database variables
|
|
available_sources = requests.get(
|
|
f"{BACKEND_URL}/import/available_sources"
|
|
).json()
|
|
|
|
# Application tabs
|
|
tabs = st.tabs(["Conversion", "Analysis", "Data", "Settings", "Dashboard"])
|
|
|
|
# Application core
|
|
with tabs[0]:
|
|
st.header("Conversion de source")
|
|
with st.form("conversion_form"):
|
|
input_file = st.file_uploader("Télécharge un fichier à convertir")
|
|
input_text = st.text_area("Saisis du texte à convertir")
|
|
source_type = st.selectbox(
|
|
label="Sélectionne la source",
|
|
options=[
|
|
source.get("name")
|
|
for source in available_sources.get("sources")
|
|
],
|
|
format_func=lambda x: {
|
|
source.get("name"): source.get("display_name")
|
|
for source in available_sources.get("sources")
|
|
}.get(x),
|
|
)
|
|
if input_text:
|
|
source_data = input_text
|
|
elif input_file:
|
|
source_data = input_file
|
|
else:
|
|
st.error("Tu dois fournir un fichier ou du texte")
|
|
submitted = st.form_submit_button("Convertir")
|
|
if submitted:
|
|
response = requests.post(
|
|
f"{BACKEND_URL}/convert",
|
|
json={"source_type": source_type, "source_data": source_data},
|
|
)
|
|
st.success("Conversion Result:")
|
|
st.write(response.json())
|
|
|
|
with tabs[1]:
|
|
st.header("Importer des données")
|
|
|
|
with tabs[2]:
|
|
st.header("Analyser des données")
|
|
|
|
with tabs[3]:
|
|
st.header("Exporter des données")
|
|
|
|
with tabs[4]:
|
|
st.header("Générer une publication")
|