Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ from transformers import pipeline
|
|
| 4 |
from pptx import Presentation
|
| 5 |
from pptx.util import Inches
|
| 6 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextIteratorStreamer
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Préprompt pour donner des instructions au modèle
|
| 9 |
PREPROMPT = """Vous êtes un assistant IA chargé de générer une présentation PowerPoint à partir d'un texte fourni par un utilisateur. Voici les instructions à suivre :
|
|
@@ -15,9 +17,27 @@ PREPROMPT = """Vous êtes un assistant IA chargé de générer une présentation
|
|
| 15 |
Voici le texte à transformer en présentation :"""
|
| 16 |
|
| 17 |
# Chargement du modèle IA depuis Hugging Face
|
| 18 |
-
text_to_presentation = pipeline("text-generation", model="MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained("MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF")
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def generate_presentation(text):
|
| 22 |
# Ajout du préprompt au texte de l'utilisateur
|
| 23 |
full_prompt = PREPROMPT + "\n\n" + text
|
|
|
|
| 4 |
from pptx import Presentation
|
| 5 |
from pptx.util import Inches
|
| 6 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextIteratorStreamer
|
| 7 |
+
from llama_cpp import LLMCppModel
|
| 8 |
+
|
| 9 |
|
| 10 |
# Préprompt pour donner des instructions au modèle
|
| 11 |
PREPROMPT = """Vous êtes un assistant IA chargé de générer une présentation PowerPoint à partir d'un texte fourni par un utilisateur. Voici les instructions à suivre :
|
|
|
|
| 17 |
Voici le texte à transformer en présentation :"""
|
| 18 |
|
| 19 |
# Chargement du modèle IA depuis Hugging Face
|
| 20 |
+
#text_to_presentation = pipeline("text-generation", model="MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF")
|
| 21 |
+
#tokenizer = AutoTokenizer.from_pretrained("MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Chargement du modèle IA depuis Hugging Face
|
| 25 |
+
#from llama_cpp import LLMCppModel
|
| 26 |
+
model_path = "MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF"
|
| 27 |
+
text_to_presentation = LLMCppModel(model_path)
|
| 28 |
+
|
| 29 |
+
# Chargement du tokenizer depuis Hugging Face
|
| 30 |
+
#from transformers import AutoTokenizer
|
| 31 |
tokenizer = AutoTokenizer.from_pretrained("MisterAI/Bartowski_MistralAI_Mistral-Small-24B-Base-2501-GGUF")
|
| 32 |
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
def generate_presentation(text):
|
| 42 |
# Ajout du préprompt au texte de l'utilisateur
|
| 43 |
full_prompt = PREPROMPT + "\n\n" + text
|