Sfoglia il codice sorgente

Feat/2070 glm 4 and glm 3 turbo (#2114)

crazywoola 1 anno fa
parent
commit
8438d820ad

+ 2 - 2
api/core/file/message_file_parser.py

@@ -2,7 +2,7 @@ from typing import Dict, List, Optional, Union
 
 import requests
 from core.file.file_obj import FileObj, FileTransferMethod, FileType
-from core.file.upload_file_parser import SUPPORT_EXTENSIONS
+from services.file_service import IMAGE_EXTENSIONS
 from extensions.ext_database import db
 from models.account import Account
 from models.model import AppModelConfig, EndUser, MessageFile, UploadFile
@@ -83,7 +83,7 @@ class MessageFileParser:
                             UploadFile.tenant_id == self.tenant_id,
                             UploadFile.created_by == user.id,
                             UploadFile.created_by_role == ('account' if isinstance(user, Account) else 'end_user'),
-                            UploadFile.extension.in_(SUPPORT_EXTENSIONS)
+                            UploadFile.extension.in_(IMAGE_EXTENSIONS)
                         ).first())
 
                         # check upload file is belong to tenant and user

+ 3 - 3
api/core/file/upload_file_parser.py

@@ -9,8 +9,8 @@ from typing import Optional
 from extensions.ext_storage import storage
 from flask import current_app
 
-SUPPORT_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'svg']
-
+IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'svg']
+IMAGE_EXTENSIONS.extend([ext.upper() for ext in IMAGE_EXTENSIONS])
 
 class UploadFileParser:
     @classmethod
@@ -18,7 +18,7 @@ class UploadFileParser:
         if not upload_file:
             return None
 
-        if upload_file.extension not in SUPPORT_EXTENSIONS:
+        if upload_file.extension not in IMAGE_EXTENSIONS:
             return None
 
         if current_app.config['MULTIMODAL_SEND_IMAGE_FORMAT'] == 'url' or force_url:

File diff suppressed because it is too large
+ 42 - 0
api/core/model_runtime/model_providers/zhipuai/llm/glm_3_turbo.yaml


File diff suppressed because it is too large
+ 42 - 0
api/core/model_runtime/model_providers/zhipuai/llm/glm_4.yaml


+ 1 - 1
api/requirements.txt

@@ -35,7 +35,7 @@ chardet~=5.1.0
 docx2txt==0.8
 pypdfium2==4.16.0
 resend~=0.7.0
-pyjwt~=2.6.0
+pyjwt~=2.8.0
 anthropic~=0.7.7
 newspaper3k==0.2.8
 google-api-python-client==2.90.0

+ 2 - 0
api/services/file_service.py

@@ -16,6 +16,8 @@ from werkzeug.datastructures import FileStorage
 from werkzeug.exceptions import NotFound
 
 IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'svg']
+IMAGE_EXTENSIONS.extend([ext.upper() for ext in IMAGE_EXTENSIONS])
+
 ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx', 'docx', 'doc', 'csv'] + IMAGE_EXTENSIONS
 UNSTRUSTURED_ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx',
                                       'docx', 'doc', 'csv', 'eml', 'msg', 'pptx', 'ppt', 'xml'] + IMAGE_EXTENSIONS