Spaces:
Sleeping
Sleeping
Commit
·
b04ff52
1
Parent(s):
faaf179
Update
Browse files
app.py
CHANGED
@@ -20,12 +20,11 @@ from llama_index.vector_stores.chroma import ChromaVectorStore
|
|
20 |
|
21 |
load_dotenv()
|
22 |
|
23 |
-
title = "Gaia
|
24 |
description = "Example of an assistant with Gradio, RAG from PDF documents and Mistral AI via its API"
|
25 |
placeholder = (
|
26 |
"Vous pouvez me posez une question sur ce contexte, appuyer sur Entrée pour valider"
|
27 |
)
|
28 |
-
placeholder_url = "Extract text from this url"
|
29 |
llm_model = "open-mixtral-8x22b"
|
30 |
|
31 |
env_api_key = os.environ.get("MISTRAL_API_KEY")
|
@@ -96,24 +95,24 @@ def load_document(input_file):
|
|
96 |
|
97 |
with gr.Blocks() as demo:
|
98 |
gr.Markdown(
|
99 |
-
""" #
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
Mistral
|
104 |
|
105 |
*The files will stay in the database unless there is 48h of inactivty or you re-build the space.*
|
106 |
"""
|
107 |
)
|
108 |
|
109 |
-
gr.Markdown(""" ### 1 /
|
110 |
|
111 |
with gr.Row():
|
112 |
with gr.Column():
|
113 |
input_file = gr.File(
|
114 |
-
label="
|
115 |
file_types=[".pdf"],
|
116 |
-
file_count="
|
117 |
type="filepath",
|
118 |
interactive=True,
|
119 |
)
|
@@ -131,15 +130,15 @@ with gr.Blocks() as demo:
|
|
131 |
)
|
132 |
|
133 |
help_msg = gr.Markdown(
|
134 |
-
value="
|
135 |
)
|
136 |
|
137 |
-
file_btn = gr.Button(value="
|
138 |
btn_msg = gr.Textbox(container=False, visible=False)
|
139 |
|
140 |
with gr.Row():
|
141 |
db_list = gr.Markdown(value=get_documents_in_db)
|
142 |
-
delete_btn = gr.Button(value="
|
143 |
|
144 |
file_btn.click(
|
145 |
load_file,
|
@@ -149,7 +148,7 @@ with gr.Blocks() as demo:
|
|
149 |
)
|
150 |
delete_btn.click(empty_db, outputs=[db_list], show_progress="minimal")
|
151 |
|
152 |
-
gr.Markdown(""" ### 2 /
|
153 |
|
154 |
chatbot = gr.Chatbot()
|
155 |
msg = gr.Textbox(placeholder=placeholder)
|
|
|
20 |
|
21 |
load_dotenv()
|
22 |
|
23 |
+
title = "AgreenDefi Gaia 8x22b PDF Demo"
|
24 |
description = "Example of an assistant with Gradio, RAG from PDF documents and Mistral AI via its API"
|
25 |
placeholder = (
|
26 |
"Vous pouvez me posez une question sur ce contexte, appuyer sur Entrée pour valider"
|
27 |
)
|
|
|
28 |
llm_model = "open-mixtral-8x22b"
|
29 |
|
30 |
env_api_key = os.environ.get("MISTRAL_API_KEY")
|
|
|
95 |
|
96 |
with gr.Blocks() as demo:
|
97 |
gr.Markdown(
|
98 |
+
""" # Bienvenue sur la démo AgreenDefi PDF
|
99 |
|
100 |
+
Ajouter un fichier avant de poser une question sur le tchat.
|
101 |
+
Cette démo vous permet d'interagir entre des fichiers PDF et Mistral AI via son API.
|
102 |
+
Mistral va répondre à vos questions par rapport au document.
|
103 |
|
104 |
*The files will stay in the database unless there is 48h of inactivty or you re-build the space.*
|
105 |
"""
|
106 |
)
|
107 |
|
108 |
+
gr.Markdown(""" ### 1 / Préparer les données """)
|
109 |
|
110 |
with gr.Row():
|
111 |
with gr.Column():
|
112 |
input_file = gr.File(
|
113 |
+
label="Charger des fichiers pdf",
|
114 |
file_types=[".pdf"],
|
115 |
+
file_count="multiple",
|
116 |
type="filepath",
|
117 |
interactive=True,
|
118 |
)
|
|
|
130 |
)
|
131 |
|
132 |
help_msg = gr.Markdown(
|
133 |
+
value="Quan le document est chargé, Appuyer sur Encode pour l'ajouter dans la base de données."
|
134 |
)
|
135 |
|
136 |
+
file_btn = gr.Button(value="Encoder les fichiers ✅", interactive=True)
|
137 |
btn_msg = gr.Textbox(container=False, visible=False)
|
138 |
|
139 |
with gr.Row():
|
140 |
db_list = gr.Markdown(value=get_documents_in_db)
|
141 |
+
delete_btn = gr.Button(value="Vider la base 🗑️", interactive=True, scale=0)
|
142 |
|
143 |
file_btn.click(
|
144 |
load_file,
|
|
|
148 |
)
|
149 |
delete_btn.click(empty_db, outputs=[db_list], show_progress="minimal")
|
150 |
|
151 |
+
gr.Markdown(""" ### 2 / Poser une question selon le contexte """)
|
152 |
|
153 |
chatbot = gr.Chatbot()
|
154 |
msg = gr.Textbox(placeholder=placeholder)
|