Skip to content

Commit

Permalink
Fix bug of LMDeployClient (#140)
Browse files Browse the repository at this point in the history
* Fix bug of LMDeployClient

* fix bug of web_demo
  • Loading branch information
liujiangning30 committed Feb 1, 2024
1 parent e20a768 commit 42c6d26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions examples/internlm2_agent_web_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def init_model(self, option, ip=None):
"""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,
Expand Down Expand Up @@ -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():
Expand Down
9 changes: 6 additions & 3 deletions lagent/llms/lmdepoly_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 42c6d26

Please sign in to comment.