Spaces:
Running
Running
File size: 3,408 Bytes
a3d26e6 1d4c573 a3d26e6 3a8ddd8 a3d26e6 59ba192 1d4c573 a3d26e6 3a8ddd8 59ba192 24052d0 3a8ddd8 59ba192 8c27c79 3a8ddd8 24052d0 a3d26e6 425940e fc40f0c b10792b 8c27c79 fc40f0c 415e2c4 1d4c573 415e2c4 fc40f0c 1d4c573 fc40f0c 8b93442 3a8ddd8 a3d26e6 720c02e a3d26e6 fc40f0c 24052d0 ea097e4 fc40f0c 415e2c4 ea097e4 415e2c4 a3d26e6 720c02e 59ba192 fc40f0c 59ba192 a3d26e6 1d4c573 fa9f568 a3d26e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
import streamlit as st
import os
import base64
from dotenv import load_dotenv
from rag import Rag
from util import getYamlConfig
from utils.document import generate_pdf
load_dotenv()
GROUP_NAME = os.environ.get("APP_NAME")
LOGO = "assets/logo.png"
userId = None
def init_app():
config = getYamlConfig()
query_params = st.query_params
if "user" in query_params:
global userId
userId = query_params["user"]
if len(st.session_state) == 0:
st.session_state["messages"] = []
st.session_state["assistant"] = Rag()
# st.session_state["data_dict"] = config['variables']
st.session_state["files"] = []
st.session_state["prompt_system"] = config['prompt_system']
st.session_state["chapters"] = config['chapters']
for chapter in st.session_state["chapters"]:
st.session_state[f"chapter_{chapter['num']}"] = {
"title": chapter['name'],
"num": chapter['num'],
"messages": [],
"prompt_system": chapter['prompt_system'],
"prompts": chapter['prompts'],
}
def main():
init_app()
st.set_page_config(page_title=GROUP_NAME)
st.logo(LOGO)
st.title(GROUP_NAME)
# st.write(f"**User ID:** {userId}")
documents = st.Page("pages/documents.py", url_path="documents", title="Vos documents", icon="📂")
form = st.Page("pages/chapter_params.py", url_path="configurations", title="Paramètres", icon="📋")
chapters_pages = [
st.Page(f"pages/chap_{chapter['num']}.py", url_path=chapter['key'], title=chapter['name'], icon="📄")
for chapter in st.session_state["chapters"]
]
pg = st.navigation(
{
"Documents": [
documents,
],
"Configurations": [
form,
],
"Dialogue": chapters_pages,
}
)
if st.sidebar.button("Générer le PDF"):
chapters = []
for chapter in st.session_state["chapters"]:
chapters.append(st.session_state[f"chapter_{chapter['num']}"])
pdf_buffer = generate_pdf(chapters)
st.sidebar.download_button(
label="📥 Télécharger le PDF",
data=pdf_buffer,
file_name="diagnostique_CEGARA.pdf",
mime="application/pdf"
)
st.sidebar.markdown("### Documentation")
st.sidebar.markdown("*Documentation :* [*Lien*]({})".format("https://docs.google.com/presentation/d/1b-cnCKge1qRBS26U5FfMScQPco4gZTn7tN1idhccsso/edit?usp=sharing"))
st.sidebar.markdown("*Evaluation App. IA :*")
st.sidebar.markdown("---")
st.sidebar.image("./assets/bziiit.png", width=100)
st.sidebar.markdown("""
<ul style="padding-left:10px;">
<li style="margin:0;"><em>Contributeur AFNOR SPEC IA FRUGAL</em></li>
<li style="margin:0;"><em>Certifié AFNOR COMPETENCES</em></li>
<li style="margin:0;"><em>Membre HUB FRANCE IA</em></li>
<li style="margin:0;"><em>Membre OSFARM</em></li>
</ul>
""", unsafe_allow_html=True)
st.sidebar.markdown("")
st.sidebar.markdown("<style> p { margin : 0px ; } </style>",unsafe_allow_html=True)
st.sidebar.markdown("2025 : Open source en Licence MIT")
st.sidebar.markdown("[email protected]")
pg.run()
if __name__ == "__main__":
main() |