Spaces:
Sleeping
Sleeping
File size: 2,323 Bytes
a3d26e6 3a8ddd8 a3d26e6 59ba192 a3d26e6 3a8ddd8 214b1f8 3a8ddd8 59ba192 8c27c79 3a8ddd8 a3d26e6 3536eb7 a3d26e6 ea96b1d a3d26e6 8c27c79 3a8ddd8 8b93442 3a8ddd8 a3d26e6 720c02e a3d26e6 720c02e a3d26e6 720c02e 59ba192 e49d193 59ba192 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 |
import streamlit as st
import os
from dotenv import load_dotenv
from rag import Rag
from vectore_store.PineconeConnector import PineconeConnector
from vectore_store.VectoreStoreManager import VectoreStoreManager
from util import getYamlConfig
load_dotenv()
GROUP_NAME = os.environ.get("APP_NAME")
LOGO = "assets/logo.png"
def init_app():
config = getYamlConfig()
if len(st.session_state) == 0:
# Define Vectore store strategy
pinecone_connector = PineconeConnector()
vs_manager = VectoreStoreManager(pinecone_connector)
st.session_state["retrived_documents"] = []
st.session_state["messages"] = []
st.session_state["remove_undefined_value"] = True
st.session_state["assistant"] = Rag(vectore_store=vs_manager)
st.session_state["data_dict"] = config['variables']
st.session_state["prompt_system"] = config['prompt_system']
if 'parts' in config['variables']:
# Flatten structure by adding part name to each field
st.session_state["data_dict"] = [
{**field, "part": part["name"]}
for part in config["variables"]["parts"]
for field in part["fields"]
]
else:
# Initialize session state with single list of variables
st.session_state["data_dict"] = [{**field} for field in config["variables"]]
def main():
init_app()
st.set_page_config(page_title=GROUP_NAME)
st.logo(LOGO)
st.title(GROUP_NAME)
saved_documents = st.Page("pages/persistent_documents.py", title="Communs", icon="🗃️")
documents = st.Page("pages/documents.py", title="Vos documents", icon="📂")
prompt_system = st.Page("pages/prompt_system.py", title="Prompt système", icon="🖊️", default=True)
form = st.Page("pages/form.py", title="Paramètres", icon="📋")
chatbot = st.Page("pages/chatbot.py", title="Chatbot", icon="🤖")
pg = st.navigation(
{
"Documents": [
saved_documents,
documents,
],
"Configurations": [
prompt_system,
form,
],
"Dialogue": [
chatbot
],
}
)
pg.run()
if __name__ == "__main__":
main() |