sanpang commited on
Commit
7fc9442
·
1 Parent(s): d3b24d6

add appp.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import runpy
4
+ st.set_page_config(layout="wide", page_title="My Multi-Page App")
5
+ def set_env_variable(key, value):
6
+ os.environ[key] = value
7
+ def home_page():
8
+ st.header("欢迎来到首页")
9
+ # 设置输入框为隐私状态
10
+ token = st.text_input("请输入浦语token:", type="password", key="token")
11
+ weather_token = st.text_input("请输入和风天气token:", type="password", key="weather_token")
12
+ if st.button("保存并体验agent"):
13
+ if token and weather_token:
14
+ set_env_variable("token", token) # 设置环境变量为 'token'
15
+ set_env_variable("weather_token", weather_token) # 设置环境变量为 'weather_token'
16
+ st.session_state.token_entered = True
17
+ st.rerun()
18
+ else:
19
+ st.error("请输入所有token")
20
+ if 'token_entered' not in st.session_state:
21
+ st.session_state.token_entered = False
22
+ if not st.session_state.token_entered:
23
+ home_page()
24
+ else:
25
+ # 动态加载子页面
26
+ page = st.sidebar.radio("选择页面", ["天气查询助手", "博客写作助手"])
27
+ if page == "天气查询助手":
28
+ runpy.run_path("examples/agent_api_web_demo.py", run_name="__main__")
29
+ elif page == "博客写作助手":
30
+ runpy.run_path("examples/multi_agents_api_web_demo.py", run_name="__main__")