Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from gradio_client import Client
|
| 3 |
+
|
| 4 |
+
# Create Hunyuan-Large client
|
| 5 |
+
client = Client("tencent/Hunyuan-Large")
|
| 6 |
+
|
| 7 |
+
# Set Streamlit page title
|
| 8 |
+
st.title("Tencent Hunyuan-Large API Demo")
|
| 9 |
+
|
| 10 |
+
# Set input box
|
| 11 |
+
message = st.text_input("Please enter a message:", "")
|
| 12 |
+
|
| 13 |
+
# Set button
|
| 14 |
+
if st.button("Get Response"):
|
| 15 |
+
if message:
|
| 16 |
+
# Call the Hunyuan-Large API
|
| 17 |
+
result = client.predict(message=message, api_name="/chat")
|
| 18 |
+
|
| 19 |
+
# Display the returned result
|
| 20 |
+
st.subheader("Model Response:")
|
| 21 |
+
st.write(result)
|
| 22 |
+
else:
|
| 23 |
+
st.error("Please enter the message first!")
|