Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from gpt4all import GPT4All
|
3 |
+
|
4 |
+
st.title("Write a story")
|
5 |
+
|
6 |
+
model = GPT4All("mistral-7b-instruct-v0.1.Q4_0.gguf")
|
7 |
+
|
8 |
+
prompt = st.text_area("Enter a prompt:", "Write a story about a guy with a mask")
|
9 |
+
|
10 |
+
if st.button("Generate Text"):
|
11 |
+
output = model.generate(prompt)
|
12 |
+
sentences = output.split(".")[:-1]
|
13 |
+
formatted_output = ".\n".join(sentence.strip() for sentence in sentences if sentence.strip())
|
14 |
+
st.write("Generated Story:")
|
15 |
+
st.text(formatted_output + ".")
|
16 |
+
st.session_state['story'] = formatted_output
|