ok
Browse files
app.py
CHANGED
@@ -22,13 +22,10 @@ model_kwargs = {'device': 'cpu'}
|
|
22 |
|
23 |
embeddings = HuggingFaceEmbeddings(model_kwargs=model_kwargs)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
tokenizer = AutoTokenizer.from_pretrained("cmarkea/bloomz-560m-sft-chat")
|
28 |
-
model = AutoModelForCausalLM.from_pretrained("ccmarkea/bloomz-560m-sft-chat", device_map='auto', quantization_config=quantization_config)
|
29 |
|
30 |
-
|
31 |
-
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=150,)
|
32 |
llm = HuggingFacePipeline(pipeline=pipe)
|
33 |
|
34 |
|
@@ -85,14 +82,23 @@ def summarize_pdf (input_pdf_question, custom_prompt=""):
|
|
85 |
#upload_file=gr.File(label="upload file", sources=['upload'],file_count="multiple")),
|
86 |
# input_pdf_name = gr.Dropdown(['testrag.pdf', 'testrag.pdf'], label="file"),
|
87 |
|
88 |
-
|
89 |
fn = summarize_pdf,
|
90 |
inputs = gr.components.Textbox(label="Entrer la question",value="je dois repeindre un mur de 30 m2 avec de la peinture PEINTURE MATE a lille, quel est le prix final ?"),
|
91 |
outputs = gr.components.Textbox(label=" "),
|
92 |
title = "PDF question",
|
93 |
description = "vous pouvez questionner un pdf.",
|
94 |
)
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
|
98 |
if __name__ == "__main__":
|
|
|
22 |
|
23 |
embeddings = HuggingFaceEmbeddings(model_kwargs=model_kwargs)
|
24 |
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
|
26 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2", device_map='auto', quantization_config=quantization_config)
|
|
|
|
|
27 |
|
28 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=150)
|
|
|
29 |
llm = HuggingFacePipeline(pipeline=pipe)
|
30 |
|
31 |
|
|
|
82 |
#upload_file=gr.File(label="upload file", sources=['upload'],file_count="multiple")),
|
83 |
# input_pdf_name = gr.Dropdown(['testrag.pdf', 'testrag.pdf'], label="file"),
|
84 |
|
85 |
+
gradio_app1 = gr.Interface(
|
86 |
fn = summarize_pdf,
|
87 |
inputs = gr.components.Textbox(label="Entrer la question",value="je dois repeindre un mur de 30 m2 avec de la peinture PEINTURE MATE a lille, quel est le prix final ?"),
|
88 |
outputs = gr.components.Textbox(label=" "),
|
89 |
title = "PDF question",
|
90 |
description = "vous pouvez questionner un pdf.",
|
91 |
)
|
92 |
+
|
93 |
+
gradio_app2 = gr.Interface(
|
94 |
+
fn = summarize_pdf,
|
95 |
+
inputs = gr.components.Textbox(label="Entrer la question",value="quel est le prix le moins cher pour une COUCHE ANTI-MOISISSURE"),
|
96 |
+
outputs = gr.components.Textbox(label=" "),
|
97 |
+
title = "PDF question",
|
98 |
+
description = "vous pouvez questionner un pdf.",
|
99 |
+
)
|
100 |
+
|
101 |
+
demo = gr.TabbedInterface([gradio_app1, gradio_app2], ["app1", "app2"])
|
102 |
|
103 |
|
104 |
if __name__ == "__main__":
|