Stevross commited on
Commit
83180bf
Β·
1 Parent(s): 42ec7ff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the model and pipeline
5
+ generate_text = pipeline(
6
+ model="Stevross/Astrid-7B-Assistant-CPU",
7
+ task="text-generation",
8
+ device=0 # Use GPU if available, otherwise CPU
9
+ )
10
+
11
+ def generate_response(prompt):
12
+ response = generate_text(prompt, max_length=150)
13
+ return response[0]['generated_text']
14
+
15
+ # Define Gradio interface
16
+ interface = gr.Interface(
17
+ fn=generate_response,
18
+ inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your prompt here..."),
19
+ outputs=gr.outputs.Textbox(),
20
+ live=True,
21
+ title="Astrid-7B-Assistant-CPU Demo",
22
+ description="An interactive demo of the Astrid-7B-Assistant-CPU model from Hugging Face."
23
+ )
24
+
25
+ interface.launch()