Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ import torch
|
|
13 |
from llama_cpp import Llama
|
14 |
import time
|
15 |
|
16 |
-
# Configuration des modèles
|
17 |
TEXT_MODELS = {
|
18 |
"Utter-Project_EuroLLM-1.7B": "utter-project/EuroLLM-1.7B",
|
19 |
"Mistral Nemo 2407 (GGUF)": "MisterAI/Bartowski_MistralAI_Mistral-Nemo-Instruct-2407-IQ4_XS.gguf",
|
@@ -111,18 +111,24 @@ class PresentationGenerator:
|
|
111 |
)
|
112 |
return response['choices'][0]['text']
|
113 |
else:
|
114 |
-
|
115 |
-
|
|
|
116 |
return_tensors="pt",
|
117 |
-
|
118 |
-
|
|
|
|
|
119 |
outputs = model.generate(
|
120 |
**inputs,
|
121 |
max_new_tokens=max_tokens,
|
122 |
-
temperature=temperature
|
|
|
|
|
123 |
)
|
124 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
125 |
|
|
|
126 |
def parse_presentation_content(self, content):
|
127 |
"""Parse le contenu généré en sections pour les diapositives"""
|
128 |
slides = []
|
@@ -170,6 +176,7 @@ class PresentationGenerator:
|
|
170 |
|
171 |
return prs
|
172 |
|
|
|
173 |
def generate_skeleton(text, text_model_name, temperature, max_tokens):
|
174 |
"""Génère le squelette de la présentation"""
|
175 |
try:
|
@@ -212,7 +219,7 @@ def create_presentation_file(generated_content):
|
|
212 |
print(f"Erreur lors de la création du fichier: {str(e)}")
|
213 |
return None
|
214 |
|
215 |
-
#
|
216 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
217 |
gr.Markdown(
|
218 |
"""
|
@@ -295,5 +302,3 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
|
295 |
if __name__ == "__main__":
|
296 |
demo.launch()
|
297 |
|
298 |
-
|
299 |
-
|
|
|
13 |
from llama_cpp import Llama
|
14 |
import time
|
15 |
|
16 |
+
# [Configuration des modèles et PREPROMPT restent identiques]
|
17 |
TEXT_MODELS = {
|
18 |
"Utter-Project_EuroLLM-1.7B": "utter-project/EuroLLM-1.7B",
|
19 |
"Mistral Nemo 2407 (GGUF)": "MisterAI/Bartowski_MistralAI_Mistral-Nemo-Instruct-2407-IQ4_XS.gguf",
|
|
|
111 |
)
|
112 |
return response['choices'][0]['text']
|
113 |
else:
|
114 |
+
# Modification ici pour gérer les modèles sans chat template
|
115 |
+
inputs = tokenizer(
|
116 |
+
prompt,
|
117 |
return_tensors="pt",
|
118 |
+
truncation=True,
|
119 |
+
max_length=4096
|
120 |
+
).to(model.device)
|
121 |
+
|
122 |
outputs = model.generate(
|
123 |
**inputs,
|
124 |
max_new_tokens=max_tokens,
|
125 |
+
temperature=temperature,
|
126 |
+
do_sample=True,
|
127 |
+
pad_token_id=tokenizer.eos_token_id
|
128 |
)
|
129 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
130 |
|
131 |
+
# [Le reste de la classe PresentationGenerator reste identique]
|
132 |
def parse_presentation_content(self, content):
|
133 |
"""Parse le contenu généré en sections pour les diapositives"""
|
134 |
slides = []
|
|
|
176 |
|
177 |
return prs
|
178 |
|
179 |
+
# [Les fonctions generate_skeleton et create_presentation_file restent identiques]
|
180 |
def generate_skeleton(text, text_model_name, temperature, max_tokens):
|
181 |
"""Génère le squelette de la présentation"""
|
182 |
try:
|
|
|
219 |
print(f"Erreur lors de la création du fichier: {str(e)}")
|
220 |
return None
|
221 |
|
222 |
+
# [L'interface Gradio reste identique]
|
223 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
224 |
gr.Markdown(
|
225 |
"""
|
|
|
302 |
if __name__ == "__main__":
|
303 |
demo.launch()
|
304 |
|
|
|
|