Skip to content

Commit

Permalink
fix bug caused by static model_name (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiangning30 authored Feb 21, 2024
1 parent a64aa59 commit 432ffaa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/internlm2_agent_web_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def init_streamlit(self):

def setup_sidebar(self):
"""Setup the sidebar for model and plugin selection."""
model_name = st.sidebar.selectbox('模型选择:', options=['internlm'])
# model_name = st.sidebar.selectbox('模型选择:', options=['internlm'])
model_name = st.sidebar.text_input('模型名称:', value='internlm2-chat-7b')
meta_prompt = st.sidebar.text_area('系统提示词', value=META_CN)
da_prompt = st.sidebar.text_area('数据分析提示词', value=INTERPRETER_CN)
plugin_prompt = st.sidebar.text_area('插件提示词', value=PLUGIN_CN)
Expand Down Expand Up @@ -113,11 +114,11 @@ def setup_sidebar(self):

return model_name, model, plugin_action, uploaded_file, model_ip

def init_model(self, option, ip=None):
"""Initialize the model based on the selected option."""
def init_model(self, model_name, ip=None):
"""Initialize the model based on the input model name."""
model_url = f'http://{ip}'
st.session_state['model_map'][option] = LMDeployClient(
model_name='internlm2-chat-20b',
st.session_state['model_map'][model_name] = LMDeployClient(
model_name=model_name,
url=model_url,
meta_template=META,
max_new_tokens=1024,
Expand All @@ -126,7 +127,7 @@ def init_model(self, option, ip=None):
temperature=0,
repetition_penalty=1.0,
stop_words=['<|im_end|>'])
return st.session_state['model_map'][option]
return st.session_state['model_map'][model_name]

def initialize_chatbot(self, model, plugin_action):
"""Initialize the chatbot with the given model and plugin actions."""
Expand Down

0 comments on commit 432ffaa

Please sign in to comment.