Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug of TritonClient #141

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions lagent/llms/lmdepoly_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ def generate(self,
for status, res, _ in self.chatbot._stream_infer(
self.chatbot._session, prompt, max_tokens, sequence_start,
sequence_end):
if status.value < 0:
break
if status.value == 0:
self.chatbot._session.histories = (
self.chatbot._session.histories +
self.chatbot._session.prompt + self.chatbot._session.response)
# remove stop_words
res = filter_suffix(res, self.gen_params.get('stop_words'))
return res
else:
return ''
status = self.state_map.get(status)
if status < ModelStatusCode.END:
return ''
elif status == ModelStatusCode.END:
self.chatbot._session.histories = (
self.chatbot._session.histories +
self.chatbot._session.prompt +
self.chatbot._session.response)
# remove stop_words
res = filter_suffix(res, self.gen_params.get('stop_words'))
return res

def stream_chat(self,
inputs: List[dict],
Expand All @@ -130,7 +130,7 @@ def stream_chat(self,
tuple(Status, str, int): status, text/chat completion,
generated token number
"""
from lmdeploy.serve.turbomind.chatbot import Session, StatusCode, get_logger
from lmdeploy.serve.turbomind.chatbot import Session, get_logger
assert isinstance(session_id, int), \
f'INT session id is required, but got {type(session_id)}'

Expand Down Expand Up @@ -158,19 +158,19 @@ def stream_chat(self,
for status, res, _ in self.chatbot._stream_infer(
self.chatbot._session, prompt, max_tokens, sequence_start,
sequence_end):
if status == StatusCode.TRITON_STREAM_END: # remove stop_words
status = self.state_map.get(status)
if status < ModelStatusCode.END:
return status, res, _
elif status == ModelStatusCode.END: # remove stop_words
res = filter_suffix(res, self.gen_params.get('stop_words'))
if status.value < 0:
self.chatbot._session.histories = (
self.chatbot._session.histories +
self.chatbot._session.prompt +
self.chatbot._session.response)
yield status, res, _
break
else:
yield self.state_map.get(status), res, _
if status.value == 0:
self.chatbot._session.histories = (
self.chatbot._session.histories +
self.chatbot._session.prompt + self.chatbot._session.response)
yield self.state_map.get(status), res, _
else:
return self.state_map.get(status), res, _
yield status, res, _

def _update_gen_params(self, **kwargs):
import mmengine
Expand Down