From e2320e517b8f3e3edb76263c0576ce651f20adde Mon Sep 17 00:00:00 2001 From: MING_X <119648793+MING-ZCH@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:13:34 +0800 Subject: [PATCH 1/5] [docs] fix some bugs in docs.md (#249) * Update quickstart.md * Update overview.md * Update overview.md --- docs/en/get_started/overview.md | 2 +- docs/zh_cn/get_started/overview.md | 2 +- docs/zh_cn/get_started/quickstart.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/get_started/overview.md b/docs/en/get_started/overview.md index 356b1481..5be46835 100644 --- a/docs/en/get_started/overview.md +++ b/docs/en/get_started/overview.md @@ -11,7 +11,7 @@ Lagent is an open source LLM agent framework, which enables people to efficientl Lagent consists of 3 main parts, agents, llms, and actions. - **agents** provides agent implementation, such as ReAct, AutoGPT. -- **llms** supports various large language models, including open-sourced models (Llama-2, InterLM) through HuggingFace models or closed-source models like GPT3.5/4. +- **llms** supports various large language models, including open-sourced models (Llama-2, InternLM) through HuggingFace models or closed-source models like GPT3.5/4. - **actions** contains a series of actions, as well as an action executor to manage all actions. ## How to Use diff --git a/docs/zh_cn/get_started/overview.md b/docs/zh_cn/get_started/overview.md index 9250c99b..9f76e45e 100644 --- a/docs/zh_cn/get_started/overview.md +++ b/docs/zh_cn/get_started/overview.md @@ -11,7 +11,7 @@ Lagent 是一个开源的 LLM 智能体框架,允许使用者快速将一个 Lagent 包含三个主要模块:agents,llms 和 actions。 - **agents** 实现了多种智能体,如 ReAct,AutoGPT。 -- **llms** 支持多种大语言模型,包括在 HuggingFace 上托管的开源模型(Llama-2, InterLM)及 GPT3.5/4 等闭源模型。 +- **llms** 支持多种大语言模型,包括在 HuggingFace 上托管的开源模型(Llama-2, InternLM)及 GPT3.5/4 等闭源模型。 - **actions** 包含一系列工具,并提供工具执行器来统一管理。 ## 如何使用 diff --git a/docs/zh_cn/get_started/quickstart.md b/docs/zh_cn/get_started/quickstart.md index ae51f57b..e9a6f24b 100644 --- a/docs/zh_cn/get_started/quickstart.md +++ b/docs/zh_cn/get_started/quickstart.md @@ -15,7 +15,7 @@ from lagent.llms import GPTAPI # 初始化 LLM,你可能需要提供 API 密钥 llm = GPTAPI(model_type='gpt-3.5-turbo', key=['Your OPENAI_API_KEY']) -# 初始化 Goolge 搜索工具,你可能需要提供 API 密钥 +# 初始化 Google 搜索工具,你可能需要提供 API 密钥 search_tool = GoogleSearch(api_key='Your SERPER_API_KEY') # 配置 ReWOO 智能体,创建聊天机器人 From 1a1f65bbc3c5a02861d2a4201fd44eec0cf40420 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 17 Oct 2024 19:07:21 +0800 Subject: [PATCH 2/5] Update requirements (#245) * Update optional.txt * Update runtime.txt --- requirements/optional.txt | 2 +- requirements/runtime.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements/optional.txt b/requirements/optional.txt index 003acdb6..bcecba0a 100644 --- a/requirements/optional.txt +++ b/requirements/optional.txt @@ -4,5 +4,5 @@ pillow python-pptx timeout_decorator torch -transformers>=4.34 +transformers>=4.34,<=4.40 vllm>=0.3.3 diff --git a/requirements/runtime.txt b/requirements/runtime.txt index 868aaa3e..fc30c3b1 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -2,7 +2,7 @@ arxiv distro filelock func_timeout -griffe +griffe<1.0 json5 jsonschema jupyter @@ -13,4 +13,4 @@ streamlit tiktoken timeout-decorator typing-extensions -duckduckgo_search==5.3.1b1 \ No newline at end of file +duckduckgo_search==5.3.1b1 From 238aacf5e711f45cdbdfb26a6c2f4336fb64cd36 Mon Sep 17 00:00:00 2001 From: liukuikun <24622904+Harold-lkk@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:34:31 +0800 Subject: [PATCH 3/5] update requirement (#257) --- requirements/optional.txt | 2 +- requirements/runtime.txt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/requirements/optional.txt b/requirements/optional.txt index bcecba0a..0b095fa3 100644 --- a/requirements/optional.txt +++ b/requirements/optional.txt @@ -1,5 +1,5 @@ google-search-results -lmdeploy>=0.2.3 +lmdeploy<=0.5.3 pillow python-pptx timeout_decorator diff --git a/requirements/runtime.txt b/requirements/runtime.txt index fc30c3b1..9fc7770a 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -1,5 +1,6 @@ arxiv distro +duckduckgo_search==5.3.1b1 filelock func_timeout griffe<1.0 @@ -7,10 +8,10 @@ json5 jsonschema jupyter jupyter_client -phx-class-registry +phx-class-registry==4.1.0 requests streamlit +termcolor tiktoken timeout-decorator typing-extensions -duckduckgo_search==5.3.1b1 From f63e6ef93808db68856aba75b30bee81c7847dd4 Mon Sep 17 00:00:00 2001 From: Lyu Han Date: Mon, 21 Oct 2024 13:16:24 +0800 Subject: [PATCH 4/5] Compatible with lmdeploy (#258) * compatible with lmdeploy * update * update depends * update --------- Co-authored-by: liukuikun <24622904+Harold-lkk@users.noreply.github.com> --- lagent/llms/lmdeploy_wrapper.py | 51 +++++++++++++++++++++++++++++---- requirements/optional.txt | 2 +- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/lagent/llms/lmdeploy_wrapper.py b/lagent/llms/lmdeploy_wrapper.py index 4b11daff..0e9f2380 100644 --- a/lagent/llms/lmdeploy_wrapper.py +++ b/lagent/llms/lmdeploy_wrapper.py @@ -1,3 +1,5 @@ +import copy +import logging from typing import List, Optional, Union from lagent.llms.base_llm import BaseModel @@ -23,7 +25,12 @@ def __init__(self, log_level: str = 'WARNING', **kwargs): super().__init__(path=None, **kwargs) - from lmdeploy.serve.turbomind.chatbot import Chatbot, StatusCode + try: + from lmdeploy.serve.turbomind.chatbot import Chatbot, StatusCode + except Exception as e: + logging.error(f'{e}') + raise RuntimeError('DO NOT use turbomind.chatbot since it has ' + 'been removed by lmdeploy since v0.5.2') self.state_map = { StatusCode.TRITON_STREAM_END: ModelStatusCode.END, StatusCode.TRITON_SERVER_ERR: ModelStatusCode.SERVER_ERR, @@ -226,11 +233,32 @@ def __init__(self, tp: int = 1, pipeline_cfg=dict(), **kwargs): - + import lmdeploy + from lmdeploy import ChatTemplateConfig, TurbomindEngineConfig, pipeline, version_info + + self.str_version = lmdeploy.__version__ + self.version = version_info + self.do_sample = kwargs.pop('do_sample', None) + if self.do_sample is not None and self.version < (0, 6, 0): + raise RuntimeError( + '`do_sample` parameter is not supported by lmdeploy until ' + f'v0.6.0, but currently using lmdeloy {self.str_version}') super().__init__(path=path, **kwargs) - from lmdeploy import pipeline + backend_config = copy.deepcopy(pipeline_cfg) + backend_config.update(tp=tp) + backend_config = { + k: v + for k, v in backend_config.items() + if hasattr(TurbomindEngineConfig, k) + } + backend_config = TurbomindEngineConfig(**backend_config) + chat_template_config = ChatTemplateConfig( + model_name=model_name) if model_name else None self.model = pipeline( - model_path=self.path, model_name=model_name, tp=tp, **pipeline_cfg) + model_path=self.path, + backend_config=backend_config, + chat_template_config=chat_template_config, + log_level='WARNING') def generate(self, inputs: Union[str, List[str]], @@ -249,13 +277,26 @@ def generate(self, (a list of/batched) text/chat completion """ from lmdeploy.messages import GenerationConfig - batched = True if isinstance(inputs, str): inputs = [inputs] batched = False prompt = inputs + do_sample = kwargs.pop('do_sample', None) gen_params = self.update_gen_params(**kwargs) + + if do_sample is None: + do_sample = self.do_sample + if do_sample is not None and self.version < (0, 6, 0): + raise RuntimeError( + '`do_sample` parameter is not supported by lmdeploy until ' + f'v0.6.0, but currently using lmdeloy {self.str_version}') + if self.version >= (0, 6, 0): + if do_sample is None: + do_sample = gen_params['top_k'] > 1 or gen_params[ + 'temperature'] > 0 + gen_params.update(do_sample=do_sample) + gen_config = GenerationConfig( skip_special_tokens=skip_special_tokens, **gen_params) response = self.model.batch_infer( diff --git a/requirements/optional.txt b/requirements/optional.txt index 0b095fa3..75645dbe 100644 --- a/requirements/optional.txt +++ b/requirements/optional.txt @@ -1,5 +1,5 @@ google-search-results -lmdeploy<=0.5.3 +lmdeploy>=0.2.5 pillow python-pptx timeout_decorator From b41ade6a13f51769b4e6ce39142646aefcba0ca3 Mon Sep 17 00:00:00 2001 From: liukuikun <24622904+Harold-lkk@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:14:26 +0800 Subject: [PATCH 5/5] [Version] v0.2.4 (#261) --- lagent/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lagent/version.py b/lagent/version.py index ff1c2005..92f5d587 100644 --- a/lagent/version.py +++ b/lagent/version.py @@ -1,5 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. -__version__ = '0.2.3' +__version__ = '0.2.4' def parse_version_info(version_str: str, length: int = 4) -> tuple: