Spaces:
Sleeping
Sleeping
File size: 852 Bytes
c0a983b |
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 |
import requests
import streamlit as st
# from streamlitui import StreamlitUI
# stui = StreamlitUI(api_url="http://localhost:8000") # FastAPI backend URL
st.title("FastAPI ChatBot")
if "messages" not in st.session_state:
st.session_state.messages = []
for message in st.session_state.messages:
with st.chat_message(message["role"]):
content = message["content"]
if isinstance(content, bytes):
st.audio(content)
else:
st.markdown(content)
if prompt := st.chat_input("Write your prompt in this input field"):
response = requests.get(
f"https://ahmed-eisa-genai-service.hf.space/generate/audio", params={"prompt": prompt}
)
response.raise_for_status()
with st.chat_message("assistant"):
st.text("Here is your generated audio")
st.audio(response.content) |