spedrox-sac commited on
Commit
5affd8c
·
verified ·
1 Parent(s): 2894b7e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Initialize the text generation pipeline
5
+ pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct", device=-1)
6
+
7
+ # Streamlit app
8
+ st.title("Text Generation with Qwen Model")
9
+
10
+ # Text input from the user
11
+ user_input = st.text_input("Enter your message:", "Who are you?")
12
+
13
+ # Generate text when the button is clicked
14
+ if st.button("Generate"):
15
+ messages = [{"role": "user", "content": user_input}]
16
+ output = pipe(messages, max_new_tokens=50) # Adjust max_new_tokens as needed
17
+ generated_text = output[0]['generated_text']
18
+
19
+ # Display the generated text
20
+ st.write("Generated Response:")
21
+ st.write(generated_text)