Alizhan commited on
Commit
bd29bf9
·
1 Parent(s): ca9cfd6
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,4 +1,26 @@
1
  import streamlit as st
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ # Initialize the pipeline
5
+ st.title("Hugging Face Text Generation")
6
+ st.subheader("Model: ai-forever/mGPT-1.3B-kazakh")
7
+
8
+ # Create the pipeline
9
+ @st.cache_resource
10
+ def load_pipeline():
11
+ return pipeline("text-generation", model="ai-forever/mGPT-1.3B-kazakh")
12
+
13
+ pipe = load_pipeline()
14
+
15
+ # User input
16
+ prompt = st.text_area("Enter your prompt:", value="", height=100)
17
+
18
+ # Text generation
19
+ if st.button("Generate Text"):
20
+ if prompt.strip():
21
+ with st.spinner("Generating text..."):
22
+ result = pipe(prompt, max_length=100, num_return_sequences=1)
23
+ st.subheader("Generated Text:")
24
+ st.write(result[0]["generated_text"])
25
+ else:
26
+ st.error("Please enter a prompt to generate text.")