From dfe916b10625051642f3c1846358e095dd6c2b90 Mon Sep 17 00:00:00 2001 From: sufubao Date: Tue, 13 Jan 2026 14:38:25 +0000 Subject: [PATCH 1/2] fix openai v1 --- lightllm/models/qwen2/model.py | 2 +- lightllm/server/api_models.py | 5 +++-- lightllm/server/api_openai.py | 4 ++-- lightllm/server/core/objs/sampling_params.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lightllm/models/qwen2/model.py b/lightllm/models/qwen2/model.py index d2f067c42c..106610ff09 100644 --- a/lightllm/models/qwen2/model.py +++ b/lightllm/models/qwen2/model.py @@ -18,7 +18,7 @@ def __init__(self, kvargs): def _init_config(self): super()._init_config() - if self.config["sliding_window"] is None: + if self.config.get("sliding_window", None) is None: self.config["sliding_window"] = self.max_total_token_num # rename key [SYM: to be confirmed] return diff --git a/lightllm/server/api_models.py b/lightllm/server/api_models.py index 7b9cdd5012..f30ecc55fe 100644 --- a/lightllm/server/api_models.py +++ b/lightllm/server/api_models.py @@ -24,9 +24,10 @@ class Message(BaseModel): class Function(BaseModel): """Function descriptions.""" - description: Optional[str] = Field(default=None, examples=[None]) name: Optional[str] = None - parameters: Optional[object] = None + description: Optional[str] = Field(default=None, examples=[None]) + parameters: Optional[dict] = None + response: Optional[dict] = None class Tool(BaseModel): diff --git a/lightllm/server/api_openai.py b/lightllm/server/api_openai.py index 6a8c232dc5..795e553e05 100644 --- a/lightllm/server/api_openai.py +++ b/lightllm/server/api_openai.py @@ -81,7 +81,7 @@ def _process_tool_call_id( # SGLang sets call_item.tool_index to the *local* position inside that message. # Therefore, the index must be corrected by using # `history_tool_calls_cnt + call_item.tool_index` to ensure globally unique and properly ordered. - tool_call_id = f"functions.{call_item.name}:{history_tool_calls_cnt+call_item.tool_index}" + tool_call_id = f"functions.{call_item.name}:{history_tool_calls_cnt + call_item.tool_index}" logger.debug( f"Process tool call idx, parser: {tool_call_parser}, \ tool_call_id: {tool_call_id}, \ @@ -292,7 +292,7 @@ async def chat_completions_impl(request: ChatCompletionRequest, raw_request: Req # 为 tool_call_parser 提供默认值 tool_parser = getattr(g_objs.args, "tool_call_parser", None) or "llama3" parser = FunctionCallParser(tools, tool_parser) - full_normal_text, call_info_list = parser.parse_non_stream(full_text) + _, call_info_list = parser.parse_non_stream(full_text) tool_calls = [] history_tool_calls_cnt = _get_history_tool_calls_cnt(request) for call_info in call_info_list: diff --git a/lightllm/server/core/objs/sampling_params.py b/lightllm/server/core/objs/sampling_params.py index f073319d79..d955aa6a87 100644 --- a/lightllm/server/core/objs/sampling_params.py +++ b/lightllm/server/core/objs/sampling_params.py @@ -7,7 +7,7 @@ _SAMPLING_EPS = 1e-5 DEFAULT_INPUT_PENALTY = os.getenv("INPUT_PENALTY", "False").upper() in ["ON", "TRUE", "1"] -SKIP_SPECIAL_TOKENS = os.getenv("SKIP_SPECIAL_TOKENS", "True").upper() in ["ON", "TRUE", "1"] +SKIP_SPECIAL_TOKENS = os.getenv("SKIP_SPECIAL_TOKENS", "False").upper() in ["ON", "TRUE", "1"] # 从环境变量获取最大长度限制 STOP_SEQUENCE_MAX_LENGTH = int(os.getenv("LIGHTLLM_STOP_SEQUENCE_MAX_LENGTH", 256)) From dedf005a4e5c47dbaf39282890dcb17f4301055a Mon Sep 17 00:00:00 2001 From: shihaobai <42648726+shihaobai@users.noreply.github.com> Date: Tue, 13 Jan 2026 22:55:58 +0800 Subject: [PATCH 2/2] fix --- lightllm/server/api_openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightllm/server/api_openai.py b/lightllm/server/api_openai.py index 795e553e05..d91bb1d947 100644 --- a/lightllm/server/api_openai.py +++ b/lightllm/server/api_openai.py @@ -292,7 +292,7 @@ async def chat_completions_impl(request: ChatCompletionRequest, raw_request: Req # 为 tool_call_parser 提供默认值 tool_parser = getattr(g_objs.args, "tool_call_parser", None) or "llama3" parser = FunctionCallParser(tools, tool_parser) - _, call_info_list = parser.parse_non_stream(full_text) + full_normal_text, call_info_list = parser.parse_non_stream(full_text) tool_calls = [] history_tool_calls_cnt = _get_history_tool_calls_cnt(request) for call_info in call_info_list: