forked from InternLM/lmdeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
722 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,4 @@ repos: | |
rev: v0.2.0 | ||
hooks: | ||
- id: check-copyright | ||
args: [] | ||
args: ["llmdeploy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import os | ||
|
||
import fire | ||
|
||
from llmdeploy.serve.fastertransformer.chatbot import Chatbot | ||
|
||
|
||
def input_prompt(): | ||
print('\ndouble enter to end input >>> ', end='') | ||
sentinel = '' # ends when this string is seen | ||
return '\n'.join(iter(input, sentinel)) | ||
|
||
|
||
def main(triton_server_addr: str, model_name: str, session_id: int): | ||
log_level = os.environ.get('SERVICE_LOG_LEVEL', 'INFO') | ||
chatbot = Chatbot(triton_server_addr, | ||
model_name, | ||
log_level=log_level, | ||
display=True) | ||
nth_round = 1 | ||
while True: | ||
prompt = input_prompt() | ||
if prompt == 'exit': | ||
exit(0) | ||
elif prompt == 'end': | ||
chatbot.end(session_id) | ||
else: | ||
request_id = f'{session_id}-{nth_round}' | ||
for status, res, tokens in chatbot.stream_infer( | ||
session_id, prompt, request_id=request_id): | ||
continue | ||
print(f'session {session_id}, {status}, {tokens}, {res}') | ||
nth_round += 1 | ||
|
||
|
||
if __name__ == '__main__': | ||
fire.Fire(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from llmdeploy.serve.fastertransformer.chatbot import \ | ||
Chatbot # noqa: F401,F403 |
Oops, something went wrong.