Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,14 +17,22 @@ STEPFUN_LOGO_PATH = "/tmp/stepfun_logo.svg"
|
|
| 17 |
|
| 18 |
def download_logo():
|
| 19 |
"""下载 StepFun logo 到本地"""
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
# 启动时下载 logo
|
|
@@ -194,7 +202,7 @@ def main():
|
|
| 194 |
with st.chat_message("user"):
|
| 195 |
st.markdown(msg["content"])
|
| 196 |
elif msg["role"] == "assistant":
|
| 197 |
-
with st.chat_message("assistant", avatar=
|
| 198 |
# 思考内容用 expander
|
| 199 |
if msg.get("thinking"):
|
| 200 |
render_thinking_expander(msg["thinking"], is_streaming=False)
|
|
@@ -230,7 +238,7 @@ def main():
|
|
| 230 |
st.markdown(prompt)
|
| 231 |
|
| 232 |
# 助手回复
|
| 233 |
-
with st.chat_message("assistant", avatar=
|
| 234 |
# 思考内容占位符
|
| 235 |
thinking_placeholder = st.empty()
|
| 236 |
# 回答内容占位符
|
|
|
|
| 17 |
|
| 18 |
def download_logo():
|
| 19 |
"""下载 StepFun logo 到本地"""
|
| 20 |
+
try:
|
| 21 |
+
response = httpx.get(STEPFUN_LOGO_URL, timeout=10.0, follow_redirects=True)
|
| 22 |
+
if response.status_code == 200:
|
| 23 |
+
with open(STEPFUN_LOGO_PATH, "wb") as f:
|
| 24 |
+
f.write(response.content)
|
| 25 |
+
return True
|
| 26 |
+
except Exception:
|
| 27 |
+
pass
|
| 28 |
+
return False
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def get_assistant_avatar():
|
| 32 |
+
"""获取助手头像,优先使用下载的 logo,失败则用 emoji"""
|
| 33 |
+
if os.path.exists(STEPFUN_LOGO_PATH):
|
| 34 |
+
return STEPFUN_LOGO_PATH
|
| 35 |
+
return "🚀"
|
| 36 |
|
| 37 |
|
| 38 |
# 启动时下载 logo
|
|
|
|
| 202 |
with st.chat_message("user"):
|
| 203 |
st.markdown(msg["content"])
|
| 204 |
elif msg["role"] == "assistant":
|
| 205 |
+
with st.chat_message("assistant", avatar=get_assistant_avatar()):
|
| 206 |
# 思考内容用 expander
|
| 207 |
if msg.get("thinking"):
|
| 208 |
render_thinking_expander(msg["thinking"], is_streaming=False)
|
|
|
|
| 238 |
st.markdown(prompt)
|
| 239 |
|
| 240 |
# 助手回复
|
| 241 |
+
with st.chat_message("assistant", avatar=get_assistant_avatar()):
|
| 242 |
# 思考内容占位符
|
| 243 |
thinking_placeholder = st.empty()
|
| 244 |
# 回答内容占位符
|