From 4a2a07f2354ee55ff76c0d264c0e95dafdf7c02a Mon Sep 17 00:00:00 2001 From: z30057876 Date: Sat, 22 Feb 2025 15:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=94=99=E8=AF=AF=EF=BC=9B?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E8=AF=B7=E6=B1=82=E6=88=AA=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/constants.py | 1 - apps/llm/reasoning.py | 2 +- apps/scheduler/call/api/sanitizer.py | 8 -------- apps/scheduler/executor/flow.py | 5 ++++- apps/scheduler/vector.py | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/constants.py b/apps/constants.py index 39d2dfaa..da02aa25 100644 --- a/apps/constants.py +++ b/apps/constants.py @@ -10,7 +10,6 @@ CURRENT_REVISION_VERSION = "0.0.0" NEW_CHAT = "New Chat" SLIDE_WINDOW_TIME = 60 SLIDE_WINDOW_QUESTION_COUNT = 10 -MAX_API_RESPONSE_LENGTH = 4096 MAX_SCHEDULER_HISTORY_SIZE = 3 LOGGER = logging.getLogger("gunicorn.error") diff --git a/apps/llm/reasoning.py b/apps/llm/reasoning.py index a9844f46..1b29537c 100644 --- a/apps/llm/reasoning.py +++ b/apps/llm/reasoning.py @@ -84,7 +84,7 @@ class ReasoningLLM(metaclass=Singleton): result = "" is_first_chunk = True - is_reasoning = True + is_reasoning = False reasoning_type = "" async for chunk in stream: diff --git a/apps/scheduler/call/api/sanitizer.py b/apps/scheduler/call/api/sanitizer.py index 0a767d4d..bfddfccc 100644 --- a/apps/scheduler/call/api/sanitizer.py +++ b/apps/scheduler/call/api/sanitizer.py @@ -6,9 +6,6 @@ import json from textwrap import dedent from typing import Any, Optional -from untruncate_json import untrunc - -from apps.constants import MAX_API_RESPONSE_LENGTH from apps.entities.plugin import CallResult from apps.scheduler.slot.slot import Slot @@ -80,11 +77,6 @@ class APISanitizer: message=f"调用接口{url}成功,但返回值为空。", ) - if len(response_data) > MAX_API_RESPONSE_LENGTH: - response_data = response_data[:MAX_API_RESPONSE_LENGTH] - response_data = response_data[:response_data.rfind(",") - 1] - response_data = untrunc.complete(response_data) - response_data = APISanitizer._process_response_schema(response_data, response_schema) message = dedent(f"""调用API从外部数据源获取了数据。API和数据源的描述为:{usage}""") diff --git a/apps/scheduler/executor/flow.py b/apps/scheduler/executor/flow.py index 560d7dd2..dbd961a7 100644 --- a/apps/scheduler/executor/flow.py +++ b/apps/scheduler/executor/flow.py @@ -2,9 +2,12 @@ Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. """ +import json import traceback from typing import Optional +from untruncate_json import untrunc + from apps.constants import LOGGER, MAX_SCHEDULER_HISTORY_SIZE from apps.entities.enum import StepStatus from apps.entities.plugin import ( @@ -249,7 +252,7 @@ class Executor: tool_info = { "name": call_name, "description": call_description, - "output": call_result.output, + "output": untrunc.complete(json.dumps(call_result.output)[:6144]), } # 更新背景 self.flow_state.thought = await ExecutorThought().generate( diff --git a/apps/scheduler/vector.py b/apps/scheduler/vector.py index 5cf2c746..141e4386 100644 --- a/apps/scheduler/vector.py +++ b/apps/scheduler/vector.py @@ -27,7 +27,7 @@ def _get_embedding(text: list[str]) -> list[np.ndarray]: :param text: 待向量化文本(多条文本组成List) :return: 文本对应的向量(顺序与text一致,也为List) """ - api = config["EMBEDDING_URL"].rstrip("/") + "/embedding" + api = config["EMBEDDING_URL"].rstrip("/") + "/embeddings" headers = { "Authorization": f"Bearer {config['EMBEDDING_KEY']}", -- Gitee