From fb8b96779c384056ffbb7b698f6a0642754f495d Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 6 Dec 2024 10:49:37 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=9F=90=E4=BA=9B?= =?UTF-8?q?pdf=E4=B8=AD=E4=B8=8D=E5=8C=85=E6=8B=AC=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=92=8C=E5=86=85=E9=83=A8=E9=93=BE=E6=8E=A5=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E5=AF=BC=E5=85=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/handle/impl/pdf_split_handle.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/common/handle/impl/pdf_split_handle.py b/apps/common/handle/impl/pdf_split_handle.py index 8de0129e1..fa8f62fa5 100644 --- a/apps/common/handle/impl/pdf_split_handle.py +++ b/apps/common/handle/impl/pdf_split_handle.py @@ -31,6 +31,16 @@ default_pattern_list = [re.compile('(?<=^)# .*|(?<=\\n)# .*'), max_kb = logging.getLogger("max_kb") +def check_links_in_pdf(doc): + for page_number in range(len(doc)): + page = doc[page_number] + links = page.get_links() + if links: + for link in links: + if link['kind'] == 1: + return True + return False + class PdfSplitHandle(BaseSplitHandle): def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): with tempfile.NamedTemporaryFile(delete=False) as temp_file: @@ -175,6 +185,9 @@ class PdfSplitHandle(BaseSplitHandle): @staticmethod def handle_links(doc, pattern_list, with_filter, limit): + # 检查文档是否包含内部链接 + if not check_links_in_pdf(doc): + return # 创建存储章节内容的数组 chapters = [] toc_start_page = -1 From 40a1070b819bf87631dd9d63b518c7f8082ffeea Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:14:48 +0800 Subject: [PATCH 2/7] =?UTF-8?q?build:=20=E4=BF=AE=E5=A4=8D=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=20(#1780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- installer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/Dockerfile b/installer/Dockerfile index c990f0afe..bc3d8a4b2 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -42,7 +42,7 @@ ENV MAXKB_VERSION="${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_C MAXKB_DB_PASSWORD=Password123@postgres \ MAXKB_EMBEDDING_MODEL_NAME=/opt/maxkb/model/embedding/shibing624_text2vec-base-chinese \ MAXKB_EMBEDDING_MODEL_PATH=/opt/maxkb/model/embedding \ - MAXKB_SANDBOX=true \ + MAXKB_SANDBOX=1 \ LANG=en_US.UTF-8 \ PATH=/opt/py3/bin:$PATH \ POSTGRES_USER=root \ From b87c214cb5c2e1b2b1e7e5bbc49657a490baab73 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 6 Dec 2024 11:30:50 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix:=20=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E4=BF=A1=E6=81=AF=E9=85=8D=E7=BD=AE=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1050048 --user=王孝刚 【企业微信-扫码登录】配置信息错误 https://www.tapd.cn/57709429/s/1626175 --- ui/src/views/authentication/component/EditModal.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/src/views/authentication/component/EditModal.vue b/ui/src/views/authentication/component/EditModal.vue index 01259e6ab..2bc9fb279 100644 --- a/ui/src/views/authentication/component/EditModal.vue +++ b/ui/src/views/authentication/component/EditModal.vue @@ -120,6 +120,8 @@ const open = async (platform: Platform) => { let defaultCallbackUrl = window.location.origin switch (platform.key) { case 'wecom': + currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/wecom` + break case 'dingtalk': if (currentPlatform.config.agent_id && currentPlatform.key === 'dingtalk') { currentPlatform.config.corp_id = currentPlatform.config.agent_id From 88b565fe6dd65599a079c6a2d0304294c0446628 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 6 Dec 2024 14:42:40 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E4=BF=A1=E6=81=AF=E9=85=8D=E7=BD=AE=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1050048 --user=王孝刚 【企业微信-扫码登录】配置信息错误 https://www.tapd.cn/57709429/s/1626175 --- ui/src/views/authentication/component/EditModal.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/src/views/authentication/component/EditModal.vue b/ui/src/views/authentication/component/EditModal.vue index 2bc9fb279..917bd0147 100644 --- a/ui/src/views/authentication/component/EditModal.vue +++ b/ui/src/views/authentication/component/EditModal.vue @@ -120,10 +120,14 @@ const open = async (platform: Platform) => { let defaultCallbackUrl = window.location.origin switch (platform.key) { case 'wecom': + if (currentPlatform.config.app_key) { + currentPlatform.config.agent_id = currentPlatform.config.app_key + delete currentPlatform.config.app_key + } currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/wecom` break case 'dingtalk': - if (currentPlatform.config.agent_id && currentPlatform.key === 'dingtalk') { + if (currentPlatform.config.agent_id) { currentPlatform.config.corp_id = currentPlatform.config.agent_id delete currentPlatform.config.agent_id } From acebb7b366991488f739da9a6ca53fc28a1e6cf0 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 6 Dec 2024 15:37:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=99=BA?= =?UTF-8?q?=E8=B0=B1=E5=9B=BE=E7=89=87=E7=90=86=E8=A7=A3=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhipu_model_provider/credential/image.py | 47 +++++++++++++++++++ .../impl/zhipu_model_provider/model/image.py | 26 ++++++++++ .../zhipu_model_provider.py | 26 +++++++++- 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 apps/setting/models_provider/impl/zhipu_model_provider/credential/image.py create mode 100644 apps/setting/models_provider/impl/zhipu_model_provider/model/image.py diff --git a/apps/setting/models_provider/impl/zhipu_model_provider/credential/image.py b/apps/setting/models_provider/impl/zhipu_model_provider/credential/image.py new file mode 100644 index 000000000..0eb05bb91 --- /dev/null +++ b/apps/setting/models_provider/impl/zhipu_model_provider/credential/image.py @@ -0,0 +1,47 @@ +# coding=utf-8 +import base64 +import os +from typing import Dict + +from langchain_core.messages import HumanMessage + +from common import forms +from common.exception.app_exception import AppApiException +from common.forms import BaseForm +from setting.models_provider.base_model_provider import BaseModelCredential, ValidCode + + +class ZhiPuImageModelCredential(BaseForm, BaseModelCredential): + api_key = forms.PasswordInputField('API Key', required=True) + + def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], provider, + raise_exception=False): + model_type_list = provider.get_model_type_list() + if not any(list(filter(lambda mt: mt.get('value') == model_type, model_type_list))): + raise AppApiException(ValidCode.valid_error.value, f'{model_type} 模型类型不支持') + + for key in ['api_key']: + if key not in model_credential: + if raise_exception: + raise AppApiException(ValidCode.valid_error.value, f'{key} 字段为必填字段') + else: + return False + try: + model = provider.get_model(model_type, model_name, model_credential) + res = model.stream([HumanMessage(content=[{"type": "text", "text": "你好"}])]) + for chunk in res: + print(chunk) + except Exception as e: + if isinstance(e, AppApiException): + raise e + if raise_exception: + raise AppApiException(ValidCode.valid_error.value, f'校验失败,请检查参数是否正确: {str(e)}') + else: + return False + return True + + def encryption_dict(self, model: Dict[str, object]): + return {**model, 'api_key': super().encryption(model.get('api_key', ''))} + + def get_model_params_setting_form(self, model_name): + pass diff --git a/apps/setting/models_provider/impl/zhipu_model_provider/model/image.py b/apps/setting/models_provider/impl/zhipu_model_provider/model/image.py new file mode 100644 index 000000000..d1658a0c0 --- /dev/null +++ b/apps/setting/models_provider/impl/zhipu_model_provider/model/image.py @@ -0,0 +1,26 @@ +from typing import Dict + +from langchain_openai.chat_models import ChatOpenAI + +from common.config.tokenizer_manage_config import TokenizerManage +from setting.models_provider.base_model_provider import MaxKBBaseModel + + +def custom_get_token_ids(text: str): + tokenizer = TokenizerManage.get_tokenizer() + return tokenizer.encode(text) + + +class ZhiPuImage(MaxKBBaseModel, ChatOpenAI): + + @staticmethod + def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs): + optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs) + return ZhiPuImage( + model_name=model_name, + openai_api_key=model_credential.get('api_key'), + openai_api_base='https://open.bigmodel.cn/api/paas/v4', + # stream_options={"include_usage": True}, + streaming=True, + **optional_params, + ) diff --git a/apps/setting/models_provider/impl/zhipu_model_provider/zhipu_model_provider.py b/apps/setting/models_provider/impl/zhipu_model_provider/zhipu_model_provider.py index ab19b1567..b24c8dd0d 100644 --- a/apps/setting/models_provider/impl/zhipu_model_provider/zhipu_model_provider.py +++ b/apps/setting/models_provider/impl/zhipu_model_provider/zhipu_model_provider.py @@ -11,18 +11,40 @@ import os from common.util.file_util import get_file_content from setting.models_provider.base_model_provider import ModelProvideInfo, ModelTypeConst, ModelInfo, IModelProvider, \ ModelInfoManage +from setting.models_provider.impl.zhipu_model_provider.credential.image import ZhiPuImageModelCredential from setting.models_provider.impl.zhipu_model_provider.credential.llm import ZhiPuLLMModelCredential +from setting.models_provider.impl.zhipu_model_provider.model.image import ZhiPuImage from setting.models_provider.impl.zhipu_model_provider.model.llm import ZhipuChatModel from smartdoc.conf import PROJECT_DIR qwen_model_credential = ZhiPuLLMModelCredential() +zhipu_image_model_credential = ZhiPuImageModelCredential() + model_info_list = [ ModelInfo('glm-4', '', ModelTypeConst.LLM, qwen_model_credential, ZhipuChatModel), ModelInfo('glm-4v', '', ModelTypeConst.LLM, qwen_model_credential, ZhipuChatModel), ModelInfo('glm-3-turbo', '', ModelTypeConst.LLM, qwen_model_credential, ZhipuChatModel) ] -model_info_manage = ModelInfoManage.builder().append_model_info_list(model_info_list).append_default_model_info( - ModelInfo('glm-4', '', ModelTypeConst.LLM, qwen_model_credential, ZhipuChatModel)).build() + +model_info_image_list = [ + ModelInfo('glm-4v-plus', '具有强大的多模态理解能力。能够同时理解多达五张图像,并支持视频内容理解', + ModelTypeConst.IMAGE, zhipu_image_model_credential, + ZhiPuImage), + ModelInfo('glm-4v', '专注于单图理解。适用于需要高效图像解析的场景', + ModelTypeConst.IMAGE, zhipu_image_model_credential, + ZhiPuImage), + ModelInfo('glm-4v-flash', '专注于单图理解。适用于需要高效图像解析的场景(免费)', + ModelTypeConst.IMAGE, zhipu_image_model_credential, + ZhiPuImage), +] + +model_info_manage = ( + ModelInfoManage.builder() + .append_model_info_list(model_info_list) + .append_default_model_info(ModelInfo('glm-4', '', ModelTypeConst.LLM, qwen_model_credential, ZhipuChatModel)) + .append_model_info_list(model_info_image_list) + .build() +) class ZhiPuModelProvider(IModelProvider): From 28a2c9897d26bdcea4a79057bc2236596ccb2905 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 6 Dec 2024 18:23:32 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E5=AD=97=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/common-list/index.vue | 2 ++ ui/src/styles/element-plus.scss | 4 ++++ ui/src/views/template/index.vue | 13 ++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/src/components/common-list/index.vue b/ui/src/components/common-list/index.vue index 3a8194d11..58fb39f55 100644 --- a/ui/src/components/common-list/index.vue +++ b/ui/src/components/common-list/index.vue @@ -73,6 +73,8 @@ defineExpose({ li { padding: 10px 16px; font-weight: 400; + color: var(--el-text-color-regular); + font-size: 14px; &.active { background: var(--el-color-primary-light-9); border-radius: 4px; diff --git a/ui/src/styles/element-plus.scss b/ui/src/styles/element-plus.scss index ef51fa7ba..e0177f493 100644 --- a/ui/src/styles/element-plus.scss +++ b/ui/src/styles/element-plus.scss @@ -133,6 +133,7 @@ .el-card { --el-card-padding: calc(var(--app-base-px) * 2); + color: var(--el-text-color-regular); } .el-dropdown { color: var(--app-text-color); @@ -267,6 +268,9 @@ .el-select-group .el-select-dropdown__item { padding-left: 11px; } +.el-select-dropdown__item { + font-weight: 400; +} .el-select__caret { color: var(--app-text-color-secondary); diff --git a/ui/src/views/template/index.vue b/ui/src/views/template/index.vue index 20c9a62e5..1216409f1 100644 --- a/ui/src/views/template/index.vue +++ b/ui/src/views/template/index.vue @@ -2,7 +2,7 @@
-

供应商

+

供应商