update agent_api_web_demo.py
Browse files- examples/agent_api_web_demo.py +12 -13
examples/agent_api_web_demo.py
CHANGED
|
@@ -2,7 +2,7 @@ import copy
|
|
| 2 |
import os
|
| 3 |
from typing import List
|
| 4 |
import streamlit as st
|
| 5 |
-
from lagent.actions import ArxivSearch
|
| 6 |
from lagent.prompts.parsers import PluginParser
|
| 7 |
from lagent.agents.stream import INTERPRETER_CN, META_CN, PLUGIN_CN, AgentForInternLM, get_plugin_prompt
|
| 8 |
from lagent.llms import GPTAPI
|
|
@@ -17,7 +17,6 @@ class SessionState:
|
|
| 17 |
# 初始化插件列表
|
| 18 |
action_list = [
|
| 19 |
ArxivSearch(),
|
| 20 |
-
WeatherQuery(),
|
| 21 |
]
|
| 22 |
st.session_state['plugin_map'] = {action.name: action for action in action_list}
|
| 23 |
st.session_state['model_map'] = {} # 存储模型实例
|
|
@@ -46,11 +45,11 @@ class StreamlitUI:
|
|
| 46 |
|
| 47 |
def init_streamlit(self):
|
| 48 |
"""初始化 Streamlit 的 UI 设置。"""
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
st.header(':robot_face: :blue[Lagent] Web Demo ', divider='rainbow')
|
| 55 |
|
| 56 |
def setup_sidebar(self):
|
|
@@ -128,16 +127,16 @@ class StreamlitUI:
|
|
| 128 |
|
| 129 |
def main():
|
| 130 |
"""主函数,运行 Streamlit 应用。"""
|
| 131 |
-
if 'ui' not in
|
| 132 |
session_state = SessionState()
|
| 133 |
session_state.init_state()
|
| 134 |
st.session_state['ui'] = StreamlitUI(session_state)
|
| 135 |
else:
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
st.header(':robot_face: :blue[Lagent] Web Demo ', divider='rainbow')
|
| 142 |
|
| 143 |
# 设置侧边栏并获取模型和插件信息
|
|
|
|
| 2 |
import os
|
| 3 |
from typing import List
|
| 4 |
import streamlit as st
|
| 5 |
+
from lagent.actions import ArxivSearch
|
| 6 |
from lagent.prompts.parsers import PluginParser
|
| 7 |
from lagent.agents.stream import INTERPRETER_CN, META_CN, PLUGIN_CN, AgentForInternLM, get_plugin_prompt
|
| 8 |
from lagent.llms import GPTAPI
|
|
|
|
| 17 |
# 初始化插件列表
|
| 18 |
action_list = [
|
| 19 |
ArxivSearch(),
|
|
|
|
| 20 |
]
|
| 21 |
st.session_state['plugin_map'] = {action.name: action for action in action_list}
|
| 22 |
st.session_state['model_map'] = {} # 存储模型实例
|
|
|
|
| 45 |
|
| 46 |
def init_streamlit(self):
|
| 47 |
"""初始化 Streamlit 的 UI 设置。"""
|
| 48 |
+
st.set_page_config(
|
| 49 |
+
layout='wide',
|
| 50 |
+
page_title='lagent-web',
|
| 51 |
+
page_icon='./docs/imgs/lagent_icon.png'
|
| 52 |
+
)
|
| 53 |
st.header(':robot_face: :blue[Lagent] Web Demo ', divider='rainbow')
|
| 54 |
|
| 55 |
def setup_sidebar(self):
|
|
|
|
| 127 |
|
| 128 |
def main():
|
| 129 |
"""主函数,运行 Streamlit 应用。"""
|
| 130 |
+
if 'ui' not in st.session_state:
|
| 131 |
session_state = SessionState()
|
| 132 |
session_state.init_state()
|
| 133 |
st.session_state['ui'] = StreamlitUI(session_state)
|
| 134 |
else:
|
| 135 |
+
st.set_page_config(
|
| 136 |
+
layout='wide',
|
| 137 |
+
page_title='lagent-web',
|
| 138 |
+
page_icon='./docs/imgs/lagent_icon.png'
|
| 139 |
+
)
|
| 140 |
st.header(':robot_face: :blue[Lagent] Web Demo ', divider='rainbow')
|
| 141 |
|
| 142 |
# 设置侧边栏并获取模型和插件信息
|