Spaces:
Runtime error
Runtime error
File size: 1,205 Bytes
f4bf684 7ae3f27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import requests
import streamlit as st
st.title("AI Story Generator")
# Input form for user to enter story details
story = st.text_area("Enter the beginning of your story:")
length = st.slider("Select the desired length of the story:", min_value=50, max_value=500, value=150, step=10)
temperature = st.slider("Select the temperature for the generated text:", min_value=0.1, max_value=2.0, value=0.7, step=0.1)
top_k = st.slider("Select the top-k value for the generated text:", min_value=1, max_value=50, value=1, step=1)
top_p = st.slider("Select the top-p value for the generated text:", min_value=0.1, max_value=1.0, value=0.2, step=0.1)
# Generate story based on user input
if st.button("Generate Story"):
response = requests.post("https://blinkdl-chatrwkv-gradio.hf.space/run/predict", json={
"data": [
story,
length,
top_k,
temperature,
top_p
]
}).json()
# Check if response contains the expected key
if "data" in response:
generated_text = response["data"]
st.write("Generated Story:")
st.write(generated_text)
else:
st.write("Error: Unexpected response from API.")
|