|
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" |
|
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: |
|
|
|
pinecone_connector = PineconeConnector() |
|
vs_manager = VectoreStoreManager(pinecone_connector) |
|
|
|
st.session_state["messages"] = [] |
|
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']: |
|
|
|
st.session_state["data_dict"] = [ |
|
{**field, "part": part["name"]} |
|
for part in config["variables"]["parts"] |
|
for field in part["fields"] |
|
] |
|
else: |
|
|
|
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) |
|
|
|
st.write(f"**User ID:** {userId}") |
|
|
|
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() |