Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
import argparse
|
2 |
import os
|
|
|
3 |
import gradio as gr
|
4 |
from loguru import logger
|
5 |
-
from similarities import BertSimilarity
|
|
|
6 |
from chatpdf import ChatPDF
|
7 |
|
8 |
pwd_path = os.path.abspath(os.path.dirname(__file__))
|
@@ -16,6 +18,8 @@ if __name__ == '__main__':
|
|
16 |
parser.add_argument("--rerank_model_name", type=str, default="")
|
17 |
parser.add_argument("--corpus_files", type=str, default="Acuerdo009.pdf")
|
18 |
parser.add_argument("--device", type=str, default=None)
|
|
|
|
|
19 |
parser.add_argument("--chunk_size", type=int, default=220)
|
20 |
parser.add_argument("--chunk_overlap", type=int, default=0)
|
21 |
parser.add_argument("--num_expand_context_chunk", type=int, default=1)
|
@@ -41,6 +45,8 @@ if __name__ == '__main__':
|
|
41 |
)
|
42 |
logger.info(f"chatpdf model: {model}")
|
43 |
|
|
|
|
|
44 |
def predict_stream(message, history):
|
45 |
history_format = []
|
46 |
for human, assistant in history:
|
@@ -57,21 +63,18 @@ if __name__ == '__main__':
|
|
57 |
logger.debug(r)
|
58 |
return r
|
59 |
|
60 |
-
|
61 |
chatbot_stream = gr.Chatbot(
|
62 |
height=600,
|
63 |
avatar_images=(
|
64 |
os.path.join(pwd_path, "assets/user.png"),
|
65 |
os.path.join(pwd_path, "assets/Logo1.png"),
|
66 |
-
),
|
67 |
-
|
68 |
-
)
|
69 |
-
|
70 |
title = " 馃ChatPDF Zonia馃 "
|
71 |
-
|
|
|
72 |
examples = ['Puede hablarme del PNL?', 'Introducci贸n a la PNL']
|
73 |
-
|
74 |
-
# Crear la interfaz sin utilizar la funci贸n que usa yield
|
75 |
chat_interface_stream = gr.ChatInterface(
|
76 |
predict_stream,
|
77 |
textbox=gr.Textbox(lines=4, placeholder="Ask me question", scale=7), # A帽adir submit=True
|
|
|
1 |
import argparse
|
2 |
import os
|
3 |
+
|
4 |
import gradio as gr
|
5 |
from loguru import logger
|
6 |
+
from similarities import BertSimilarity, BM25Similarity
|
7 |
+
|
8 |
from chatpdf import ChatPDF
|
9 |
|
10 |
pwd_path = os.path.abspath(os.path.dirname(__file__))
|
|
|
18 |
parser.add_argument("--rerank_model_name", type=str, default="")
|
19 |
parser.add_argument("--corpus_files", type=str, default="Acuerdo009.pdf")
|
20 |
parser.add_argument("--device", type=str, default=None)
|
21 |
+
#parser.add_argument("--int4", action='store_true', help="use int4 quantization")
|
22 |
+
#parser.add_argument("--int8", action='store_true', help="use int8 quantization")
|
23 |
parser.add_argument("--chunk_size", type=int, default=220)
|
24 |
parser.add_argument("--chunk_overlap", type=int, default=0)
|
25 |
parser.add_argument("--num_expand_context_chunk", type=int, default=1)
|
|
|
45 |
)
|
46 |
logger.info(f"chatpdf model: {model}")
|
47 |
|
48 |
+
logger.info(f"chatpdf model: {model}")
|
49 |
+
|
50 |
def predict_stream(message, history):
|
51 |
history_format = []
|
52 |
for human, assistant in history:
|
|
|
63 |
logger.debug(r)
|
64 |
return r
|
65 |
|
66 |
+
|
67 |
chatbot_stream = gr.Chatbot(
|
68 |
height=600,
|
69 |
avatar_images=(
|
70 |
os.path.join(pwd_path, "assets/user.png"),
|
71 |
os.path.join(pwd_path, "assets/Logo1.png"),
|
72 |
+
), bubble_full_width=False)
|
73 |
+
# Actualizar el t铆tulo y la descripci贸n
|
|
|
|
|
74 |
title = " 馃ChatPDF Zonia馃 "
|
75 |
+
# description = "Enlace en Github: [shibing624/ChatPDF](https://github.com/shibing624/ChatPDF)"
|
76 |
+
css = """.toast-wrap { display: none !importante } """
|
77 |
examples = ['Puede hablarme del PNL?', 'Introducci贸n a la PNL']
|
|
|
|
|
78 |
chat_interface_stream = gr.ChatInterface(
|
79 |
predict_stream,
|
80 |
textbox=gr.Textbox(lines=4, placeholder="Ask me question", scale=7), # A帽adir submit=True
|