-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_ui.py
More file actions
32 lines (26 loc) ยท 1.14 KB
/
streamlit_ui.py
File metadata and controls
32 lines (26 loc) ยท 1.14 KB
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 streamlit as st
import requests
st.set_page_config(page_title="Lang2Creator Streamlit UI", layout="wide")
st.title("๐๏ธ Lang2Creator AI Assistant")
query = st.chat_input("๋ฌด์์ด ๊ถ๊ธํ์ ๊ฐ์? ์: Creator_001์ ์ธ๋ค์ผ ๋ณด์ฌ์ค")
if query:
with st.chat_message("user"):
st.markdown(query)
try:
payload = {"user": "jinsoo", "text": query}
response = requests.post("http://localhost:8000/ask", json=payload)
result = response.json()
with st.chat_message("assistant"):
if "error" in result:
st.error(result["error"])
elif "thumbnail" in result:
st.image(result["thumbnail"], caption=result.get("title", "์ธ๋ค์ผ"))
st.markdown(f"[๐ ์์ ๋ณด๋ฌ๊ฐ๊ธฐ]({result['url']})")
elif "views" in result:
st.write(f"๐ {result['creator']}์ ์กฐํ์")
df = result["views"]
st.line_chart({v["date"]: v["views"] for v in df})
else:
st.json(result)
except Exception as e:
st.error(f"์์ฒญ ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {e}")