Upload ms-swift/examples/app/base_url/demo.py with huggingface_hub
Browse files
ms-swift/examples/app/base_url/demo.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Alibaba, Inc. and its affiliates.
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
|
| 5 |
+
|
| 6 |
+
if __name__ == '__main__':
|
| 7 |
+
from swift.llm import AppArguments, app_main, DeployArguments, run_deploy
|
| 8 |
+
# Here's a runnable demo provided.
|
| 9 |
+
# In a real scenario, you can simply remove the deployed context.
|
| 10 |
+
with run_deploy(
|
| 11 |
+
DeployArguments(model='Qwen/Qwen2.5-1.5B-Instruct', verbose=False, log_interval=-1, infer_backend='vllm'),
|
| 12 |
+
return_url=True) as url:
|
| 13 |
+
app_main(AppArguments(model='Qwen2.5-1.5B-Instruct', base_url=url, stream=True, max_new_tokens=2048))
|