Skip to content

Commit 264b612

Browse files
committed
lmdeploy 升级为 0.6.2
1 parent 0cfd445 commit 264b612

File tree

8 files changed

+102
-11
lines changed

8 files changed

+102
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ streamlit run server_ui.py
258258
| glm-4v-9b |chatglm| × | × | × ||
259259
| InternVL2 |internvl2| × | × |||
260260
| MiniCPM-V-2_6 |minicpmv | × ||| × |
261-
| Qwen2-VL |qwen | × || × | × |
261+
| Qwen2-VL |qwen | × || × | |
262262
<br>
263263

264264
### Embedding模型

gpt_server/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def check_lmdeploy_lib():
2222
lmdeploy_path = os.path.dirname(get_module_path(module_name))
2323
if not check_lmdeploy_lib():
2424
logger.warning("不存在lmdeploy的lib文件目录,系统将会自动下载!")
25-
cmd = "pip install --force-reinstall lmdeploy==0.6.0 --no-deps"
25+
cmd = "pip install --force-reinstall lmdeploy==0.6.2 --no-deps"
2626
logger.info(f"正在执行命令:{cmd}")
2727
os.system(cmd)
2828
logger.info("安装成功,请重新启动服务!")

gpt_server/model_worker/base/model_worker_base.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from abc import ABC, abstractmethod
55
from fastapi import BackgroundTasks, Request, FastAPI
66
from fastapi.responses import JSONResponse, StreamingResponse
7-
from fastchat.utils import get_context_length as get_context_length_
8-
7+
from fastchat.utils import SEQUENCE_LENGTH_KEYS
98
from loguru import logger
109
import os
1110
from transformers import (
@@ -23,6 +22,24 @@
2322
app = FastAPI()
2423

2524

25+
def get_context_length_(config):
26+
"""Get the context length of a model from a huggingface model config."""
27+
rope_scaling = getattr(config, "rope_scaling", None)
28+
if rope_scaling:
29+
try:
30+
rope_scaling_factor = config.rope_scaling["factor"]
31+
except KeyError:
32+
rope_scaling_factor = 1
33+
else:
34+
rope_scaling_factor = 1
35+
36+
for key in SEQUENCE_LENGTH_KEYS:
37+
val = getattr(config, key, None)
38+
if val is not None:
39+
return int(rope_scaling_factor * val)
40+
return 2048
41+
42+
2643
class ModelWorkerBase(BaseModelWorker, ABC):
2744
def __init__(
2845
self,

install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pip install -r requirements.txt
2-
pip install --force-reinstall lmdeploy==0.6.0 --no-deps
2+
pip install --force-reinstall lmdeploy==0.6.2 --no-deps

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies = [
2222
"torchvision==0.19",
2323
"transformers==4.45.2",
2424
"vllm==0.6.3",
25+
"qwen_vl_utils"
2526
]
2627

2728

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ fschat==0.2.36
55
transformers==4.45.2
66
accelerate
77
vllm==0.6.3
8-
git+https://gitee.com/liuyu_1997/lmdeploy.git#egg=lmdeploy # lmdeploy==0.6.0
8+
git+https://gitee.com/liuyu_1997/lmdeploy.git # lmdeploy==0.6.2
99
openai==1.44.0
1010
loguru
1111
fastapi==0.114.1
1212
infinity-emb[all]==0.0.53
1313
git+https://gitee.com/liuyu_1997/ffmpy.git # 解决setuptools最新版本导致的重大事故
1414
gradio==4.26.0
15-
streamlit==1.39.0
15+
streamlit==1.39.0
16+
qwen_vl_utils

tests/test_openai_vl_chat.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
import base64
12
from openai import OpenAI
23

4+
5+
def image_to_base64(image_path):
6+
"""将图片转换为Base64字符串"""
7+
base64_prefix = "data:image/png;base64,"
8+
9+
with open(image_path, "rb") as image_file:
10+
base64_string = base64.b64encode(image_file.read()).decode("utf-8")
11+
return base64_prefix + base64_string
12+
13+
14+
image_path = "../assets/logo.png"
15+
# 使用本地的图片
16+
url = image_to_base64(image_path)
17+
# 使用网络图片
18+
url = "https://opencompass.oss-cn-shanghai.aliyuncs.com/image/compass-hub/botchat_banner.png"
19+
320
# 新版本 opnai
421
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")
522

@@ -17,7 +34,7 @@
1734
{
1835
"type": "image_url",
1936
"image_url": {
20-
"url": "https://opencompass.oss-cn-shanghai.aliyuncs.com/image/compass-hub/botchat_banner.png",
37+
"url": url,
2138
},
2239
},
2340
],

uv.lock

+58-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)