Fix bug of LMDeployClient (#140)

* Fix bug of LMDeployClient

* fix bug of web_demo
This commit is contained in:
liujiangning30
2024-02-01 17:58:10 +08:00
committed by GitHub
parent e20a768066
commit 42c6d265e1
2 changed files with 8 additions and 6 deletions

View File

@@ -117,7 +117,7 @@ class StreamlitUI:
"""Initialize the model based on the selected option."""
model_url = f'http://{ip}'
st.session_state['model_map'][option] = LMDeployClient(
path='internlm2-chat-20b',
model_name='internlm2-chat-20b',
url=model_url,
meta_template=META,
top_p=0.8,
@@ -294,8 +294,7 @@ def main():
st.session_state['ui'].render_action_results(
agent_return.actions[-1])
elif (agent_return.state == AgentStatusCode.STREAM_ING
or agent_return.state == AgentStatusCode.CODING
or agent_return.state == AgentStatusCode.END):
or agent_return.state == AgentStatusCode.CODING):
# st.markdown(agent_return.response)
# 清除占位符的当前内容,并显示新内容
with st.container():

View File

@@ -411,12 +411,15 @@ class LMDeployClient(LMDeployServer):
"""
Args:
path (str): The path to the model.
url (str): communicating address 'http://<ip>:<port>' of
api_server
model_name (str): needed when model_path is a pytorch model on
huggingface.co, such as "internlm-chat-7b",
"Qwen-7B-Chat ", "Baichuan2-7B-Chat" and so on.
"""
def __init__(self, path: str, url: str, **kwargs):
BaseModel.__init__(self, path=path, **kwargs)
def __init__(self, url: str, model_name: str, **kwargs):
BaseModel.__init__(self, path=url, **kwargs)
from lmdeploy.serve.openai.api_client import APIClient
self.client = APIClient(url)
self.model_name = model_name