Vivek12345323 commited on
Commit
501414a
·
verified ·
1 Parent(s): 94524d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the Hugging Face model
5
+ pipe = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.2")
6
+
7
+ # Define what the app does
8
+ def rewrite(text):
9
+ prompt = f"Fix grammar and improve clarity for this text:\n\n{text}"
10
+ output = pipe(prompt, max_new_tokens=300, do_sample=True)[0]['generated_text']
11
+ return output
12
+
13
+ # Create the interface
14
+ gr.Interface(
15
+ fn=rewrite,
16
+ inputs=gr.Textbox(lines=10, placeholder="Paste your essay here..."),
17
+ outputs=gr.Textbox(lines=10, label="Improved Essay"),
18
+ title="AI Essay Rewriter",
19
+ description="Paste an essay or paragraph and get an improved version using Mistral-7B."
20
+ ).launch()