from enum import Enum import streamlit as st st.set_page_config( page_title="ChatGLM3 Demo", page_icon=":robot:", layout='centered', initial_sidebar_state='expanded', ) import demo_chat, demo_ci, demo_tool DEFAULT_SYSTEM_PROMPT = ''' You are ChatGLM3, a large language model trained by Zhipu.AI. Follow the user's instructions carefully. Respond using markdown. '''.strip() class Mode(str, Enum): CHAT, TOOL, CI = '💬 Chat', '🛠️ Tool', '🧑‍💻 Code Interpreter' with st.sidebar: top_p = st.slider( 'top_p', 0.0, 1.0, 0.8, step=0.01 ) temperature = st.slider( 'temperature', 0.0, 1.5, 0.95, step=0.01 ) system_prompt = st.text_area( label="System Prompt (Only for chat mode)", height=300, value=DEFAULT_SYSTEM_PROMPT, ) st.title("ChatGLM3 Demo") prompt_text = st.chat_input( 'Chat with ChatGLM3!', key='chat_input', ) tab = st.radio( 'Mode', [mode.value for mode in Mode], horizontal=True, label_visibility='hidden', ) match tab: case Mode.CHAT: demo_chat.main(top_p, temperature, system_prompt, prompt_text) case Mode.TOOL: demo_tool.main(top_p, temperature, prompt_text) case Mode.CI: demo_ci.main(top_p, temperature, prompt_text) case _: st.error(f'Unexpected tab: {tab}')