Skip to content

Commit

Permalink
lmdeploy 升级为 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shell-nlp committed Oct 30, 2024
1 parent 0cfd445 commit 264b612
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ streamlit run server_ui.py
| glm-4v-9b |chatglm| × | × | × ||
| InternVL2 |internvl2| × | × |||
| MiniCPM-V-2_6 |minicpmv | × ||| × |
| Qwen2-VL |qwen | × || × | × |
| Qwen2-VL |qwen | × || × | |
<br>

### Embedding模型
Expand Down
2 changes: 1 addition & 1 deletion gpt_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def check_lmdeploy_lib():
lmdeploy_path = os.path.dirname(get_module_path(module_name))
if not check_lmdeploy_lib():
logger.warning("不存在lmdeploy的lib文件目录,系统将会自动下载!")
cmd = "pip install --force-reinstall lmdeploy==0.6.0 --no-deps"
cmd = "pip install --force-reinstall lmdeploy==0.6.2 --no-deps"
logger.info(f"正在执行命令:{cmd}")
os.system(cmd)
logger.info("安装成功,请重新启动服务!")
Expand Down
21 changes: 19 additions & 2 deletions gpt_server/model_worker/base/model_worker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from abc import ABC, abstractmethod
from fastapi import BackgroundTasks, Request, FastAPI
from fastapi.responses import JSONResponse, StreamingResponse
from fastchat.utils import get_context_length as get_context_length_

from fastchat.utils import SEQUENCE_LENGTH_KEYS
from loguru import logger
import os
from transformers import (
Expand All @@ -23,6 +22,24 @@
app = FastAPI()


def get_context_length_(config):
"""Get the context length of a model from a huggingface model config."""
rope_scaling = getattr(config, "rope_scaling", None)
if rope_scaling:
try:
rope_scaling_factor = config.rope_scaling["factor"]
except KeyError:
rope_scaling_factor = 1
else:
rope_scaling_factor = 1

for key in SEQUENCE_LENGTH_KEYS:
val = getattr(config, key, None)
if val is not None:
return int(rope_scaling_factor * val)
return 2048


class ModelWorkerBase(BaseModelWorker, ABC):
def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip install -r requirements.txt
pip install --force-reinstall lmdeploy==0.6.0 --no-deps
pip install --force-reinstall lmdeploy==0.6.2 --no-deps
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = [
"torchvision==0.19",
"transformers==4.45.2",
"vllm==0.6.3",
"qwen_vl_utils"
]


Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ fschat==0.2.36
transformers==4.45.2
accelerate
vllm==0.6.3
git+https://gitee.com/liuyu_1997/lmdeploy.git#egg=lmdeploy # lmdeploy==0.6.0
git+https://gitee.com/liuyu_1997/lmdeploy.git # lmdeploy==0.6.2
openai==1.44.0
loguru
fastapi==0.114.1
infinity-emb[all]==0.0.53
git+https://gitee.com/liuyu_1997/ffmpy.git # 解决setuptools最新版本导致的重大事故
gradio==4.26.0
streamlit==1.39.0
streamlit==1.39.0
qwen_vl_utils
19 changes: 18 additions & 1 deletion tests/test_openai_vl_chat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import base64
from openai import OpenAI


def image_to_base64(image_path):
"""将图片转换为Base64字符串"""
base64_prefix = "data:image/png;base64,"

with open(image_path, "rb") as image_file:
base64_string = base64.b64encode(image_file.read()).decode("utf-8")
return base64_prefix + base64_string


image_path = "../assets/logo.png"
# 使用本地的图片
url = image_to_base64(image_path)
# 使用网络图片
url = "https://opencompass.oss-cn-shanghai.aliyuncs.com/image/compass-hub/botchat_banner.png"

# 新版本 opnai
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")

Expand All @@ -17,7 +34,7 @@
{
"type": "image_url",
"image_url": {
"url": "https://opencompass.oss-cn-shanghai.aliyuncs.com/image/compass-hub/botchat_banner.png",
"url": url,
},
},
],
Expand Down
61 changes: 58 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 264b612

Please sign in to comment.