Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,20 @@
|
|
| 1 |
-
import
|
| 2 |
import gradio as gr
|
| 3 |
-
import openai
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
messages=[{"role": "user", "content": prompt}]
|
| 13 |
-
)
|
| 14 |
-
return response.choices[0].message.content
|
| 15 |
-
except Exception as e:
|
| 16 |
-
return f"Erreur : {str(e)}"
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
-
fn=
|
| 20 |
-
inputs=gr.Textbox(placeholder="
|
| 21 |
outputs="text",
|
| 22 |
-
title="
|
| 23 |
-
description="
|
| 24 |
)
|
| 25 |
|
| 26 |
iface.launch()
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
+
# Charge un modèle de summarization (résumé)
|
| 5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 6 |
|
| 7 |
+
def resumetexte(texte):
|
| 8 |
+
# Résume le texte (max 130 tokens de résumé)
|
| 9 |
+
result = summarizer(texte, max_length=130, min_length=30, do_sample=False)
|
| 10 |
+
return result[0]['summary_text']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
iface = gr.Interface(
|
| 13 |
+
fn=resumetexte,
|
| 14 |
+
inputs=gr.Textbox(lines=10, placeholder="Colle ici ton texte à résumer..."),
|
| 15 |
outputs="text",
|
| 16 |
+
title="Résumé automatique",
|
| 17 |
+
description="Colle un texte, et obtient un résumé généré par BART."
|
| 18 |
)
|
| 19 |
|
| 20 |
iface.launch()
|