Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
# Define Streamlit app layout
|
| 8 |
st.title("Personalized Healing Songs Generator")
|
|
@@ -10,9 +11,15 @@ st.title("Personalized Healing Songs Generator")
|
|
| 10 |
prompt = st.text_area("Enter your emotional or therapeutic needs:")
|
| 11 |
|
| 12 |
if st.button("Generate Song"):
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
# Replace with your actual API URL and key
|
| 5 |
+
API_URL = "https://api.example.com/v1/generate" # Example URL
|
| 6 |
+
API_KEY = "gsk_...zzDm"
|
| 7 |
|
| 8 |
# Define Streamlit app layout
|
| 9 |
st.title("Personalized Healing Songs Generator")
|
|
|
|
| 11 |
prompt = st.text_area("Enter your emotional or therapeutic needs:")
|
| 12 |
|
| 13 |
if st.button("Generate Song"):
|
| 14 |
+
if prompt:
|
| 15 |
+
headers = {"Authorization": f"Bearer {API_KEY}"}
|
| 16 |
+
payload = {"prompt": prompt, "max_length": 150}
|
| 17 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 18 |
+
|
| 19 |
+
if response.status_code == 200:
|
| 20 |
+
result = response.json()
|
| 21 |
+
st.write(result['generated_text'].strip())
|
| 22 |
+
else:
|
| 23 |
+
st.error(f"Error: {response.status_code} - {response.text}")
|
| 24 |
+
else:
|
| 25 |
+
st.error("Please enter a prompt.")
|