improved synchro for source process
Browse files
app.py
CHANGED
@@ -13,13 +13,24 @@ A. Component part
|
|
13 |
==================================
|
14 |
"""
|
15 |
|
16 |
-
with gr.Blocks() as
|
17 |
with gr.Row():
|
18 |
|
19 |
with gr.Column():
|
20 |
pass
|
21 |
|
22 |
with gr.Column(scale=10):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
"""
|
24 |
1. input docs components
|
25 |
"""
|
@@ -168,16 +179,15 @@ with gr.Blocks() as docgpt:
|
|
168 |
"""
|
169 |
|
170 |
|
171 |
-
def
|
172 |
"""
|
173 |
Allows to choose the sources for the doc generation
|
174 |
"""
|
175 |
if source_ == "My own sources":
|
176 |
long_id = control.get_long_id(db_collection_)
|
177 |
-
control.get_or_create_collection(long_id)
|
178 |
update_ = {
|
179 |
-
db_col: gr.update(visible=True),
|
180 |
db_collection_var: long_id,
|
|
|
181 |
}
|
182 |
else:
|
183 |
update_ = {
|
@@ -186,6 +196,15 @@ with gr.Blocks() as docgpt:
|
|
186 |
return update_
|
187 |
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
def db_reset_fn(wiki_source_, db_collection_):
|
190 |
"""
|
191 |
resets the source db
|
@@ -226,7 +245,16 @@ with gr.Blocks() as docgpt:
|
|
226 |
return update_
|
227 |
|
228 |
|
229 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
"""
|
231 |
fetch the wikifiles interesting for solving the tasks as defined in the input doc
|
232 |
"""
|
@@ -305,13 +333,18 @@ with gr.Blocks() as docgpt:
|
|
305 |
my_files_db_var: [str] = gr.State([]) # list of titles of the files uploaded in the db (as seen from the UI)
|
306 |
db_collection_var: str = gr.State(-1) # name of the collection of documents sources in the db
|
307 |
|
308 |
-
source_radio
|
|
|
|
|
309 |
db_add_doc_btn.click(db_add_doc_fn, inputs=[], outputs=[db_add_doc_btn, add_col])
|
310 |
add_close_btn.click(add_close_fn, inputs=[], outputs=[db_add_doc_btn, add_col])
|
311 |
|
312 |
-
wiki_fetch_btn
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
315 |
wiki_add_to_db_btn.click(wiki_add_to_db_fn,
|
316 |
inputs=[wiki_list_comp, wiki_source_var, wiki_db_var, db_list_comp, db_collection_var],
|
317 |
outputs=[db_list_comp, wiki_list_comp, wiki_db_var,
|
@@ -371,4 +404,4 @@ with gr.Blocks() as docgpt:
|
|
371 |
==================================
|
372 |
"""
|
373 |
|
374 |
-
|
|
|
13 |
==================================
|
14 |
"""
|
15 |
|
16 |
+
with gr.Blocks() as gptdoc:
|
17 |
with gr.Row():
|
18 |
|
19 |
with gr.Column():
|
20 |
pass
|
21 |
|
22 |
with gr.Column(scale=10):
|
23 |
+
|
24 |
+
gr.Markdown("# GPTdoc")
|
25 |
+
gr.Markdown ("Master your sources when generating your documents")
|
26 |
+
gr.Markdown("### 1. You define the plan of your document ")
|
27 |
+
gr.Markdown("### 2. You select the sources for the text generation: from public unkown sources,"
|
28 |
+
" from wikipedia, or from your own files")
|
29 |
+
gr.Markdown("### 3. You launch the text generation and, when it is ready, "
|
30 |
+
"you can download the generated text")
|
31 |
+
gr.Markdown("\n\n\n")
|
32 |
+
|
33 |
+
|
34 |
"""
|
35 |
1. input docs components
|
36 |
"""
|
|
|
179 |
"""
|
180 |
|
181 |
|
182 |
+
def source1_fn(source_, db_collection_):
|
183 |
"""
|
184 |
Allows to choose the sources for the doc generation
|
185 |
"""
|
186 |
if source_ == "My own sources":
|
187 |
long_id = control.get_long_id(db_collection_)
|
|
|
188 |
update_ = {
|
|
|
189 |
db_collection_var: long_id,
|
190 |
+
db_col: gr.update(visible=True),
|
191 |
}
|
192 |
else:
|
193 |
update_ = {
|
|
|
196 |
return update_
|
197 |
|
198 |
|
199 |
+
def source2_fn(db_collection_):
|
200 |
+
"""
|
201 |
+
Allows to choose the sources for the doc generation
|
202 |
+
"""
|
203 |
+
long_id = control.get_long_id(db_collection_)
|
204 |
+
control.get_or_create_collection(long_id)
|
205 |
+
|
206 |
+
|
207 |
+
|
208 |
def db_reset_fn(wiki_source_, db_collection_):
|
209 |
"""
|
210 |
resets the source db
|
|
|
245 |
return update_
|
246 |
|
247 |
|
248 |
+
def wiki_fetch1_fn():
|
249 |
+
"""
|
250 |
+
fetch the wikifiles interesting for solving the tasks as defined in the input doc
|
251 |
+
"""
|
252 |
+
update_ = {
|
253 |
+
wiki_list_comp: gr.update(visible=True),
|
254 |
+
}
|
255 |
+
return update_
|
256 |
+
|
257 |
+
def wiki_fetch2_fn(wiki_db_files_, input_text_):
|
258 |
"""
|
259 |
fetch the wikifiles interesting for solving the tasks as defined in the input doc
|
260 |
"""
|
|
|
333 |
my_files_db_var: [str] = gr.State([]) # list of titles of the files uploaded in the db (as seen from the UI)
|
334 |
db_collection_var: str = gr.State(-1) # name of the collection of documents sources in the db
|
335 |
|
336 |
+
source_radio\
|
337 |
+
.change(source1_fn, inputs=[source_radio, db_collection_var], outputs=[db_col, db_collection_var])\
|
338 |
+
.then(source2_fn, inputs=[db_collection_var], outputs=[])
|
339 |
db_add_doc_btn.click(db_add_doc_fn, inputs=[], outputs=[db_add_doc_btn, add_col])
|
340 |
add_close_btn.click(add_close_fn, inputs=[], outputs=[db_add_doc_btn, add_col])
|
341 |
|
342 |
+
wiki_fetch_btn\
|
343 |
+
.click(wiki_fetch1_fn, inputs=[], outputs=[wiki_list_comp])\
|
344 |
+
.then(wiki_fetch2_fn,
|
345 |
+
inputs=[wiki_db_var, input_text],
|
346 |
+
outputs=[wiki_list_comp, wiki_source_var, wiki_add_to_db_btn])
|
347 |
+
|
348 |
wiki_add_to_db_btn.click(wiki_add_to_db_fn,
|
349 |
inputs=[wiki_list_comp, wiki_source_var, wiki_db_var, db_list_comp, db_collection_var],
|
350 |
outputs=[db_list_comp, wiki_list_comp, wiki_db_var,
|
|
|
404 |
==================================
|
405 |
"""
|
406 |
|
407 |
+
gptdoc.queue().launch()
|