main
HuangHai 4 weeks ago
parent a631df99d6
commit 73bada7433

@ -5,8 +5,7 @@ pip install pymilvus gensim
from pymilvus import FieldSchema, DataType, utility from pymilvus import FieldSchema, DataType, utility
from Config.Config import MS_HOST, MS_PORT, MS_MAX_CONNECTIONS, MS_COLLECTION_NAME, MS_DIMENSION from Config.Config import MS_HOST, MS_PORT, MS_MAX_CONNECTIONS, MS_COLLECTION_NAME, MS_DIMENSION
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager from Backup.Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
# 1. 使用连接池管理 Milvus 连接 # 1. 使用连接池管理 Milvus 连接
milvus_pool = MilvusConnectionPool(host=MS_HOST, port=MS_PORT, max_connections=MS_MAX_CONNECTIONS) milvus_pool = MilvusConnectionPool(host=MS_HOST, port=MS_PORT, max_connections=MS_MAX_CONNECTIONS)

@ -1,5 +1,4 @@
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager from Backup.Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
from Config.Config import * from Config.Config import *
# 1. 使用连接池管理 Milvus 连接 # 1. 使用连接池管理 Milvus 连接

@ -64,7 +64,7 @@ def save_to_txt(content, file_path, mode='w'):
return False return False
if __name__ == "__main__": if __name__ == "__main__":
input_file = '../static/Txt/小学数学教学中的若干问题_MATH_1.docx' input_file = '../../static/Txt/小学数学教学中的若干问题_MATH_1.docx'
#input_file = '../static/Txt/小学数学知识点_MATH_2.docx' #input_file = '../static/Txt/小学数学知识点_MATH_2.docx'
#input_file = '../static/Txt/高中文言文_CHINESE_1.docx' #input_file = '../static/Txt/高中文言文_CHINESE_1.docx'
output_dir = '../Txt/processed_chunks' output_dir = '../Txt/processed_chunks'

@ -1,6 +1,5 @@
from Config.Config import * from Config.Config import *
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager from Backup.Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
from gensim.models import KeyedVectors from gensim.models import KeyedVectors
import jieba import jieba
import os import os

@ -1,5 +1,4 @@
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager from Backup.Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
from Config.Config import * from Config.Config import *
# 1. 使用连接池管理 Milvus 连接 # 1. 使用连接池管理 Milvus 连接

@ -1,7 +1,6 @@
import time import time
import jieba # 导入 jieba 分词库 import jieba # 导入 jieba 分词库
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager from Backup.Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
from Config.Config import * from Config.Config import *
from gensim.models import KeyedVectors from gensim.models import KeyedVectors

@ -26,7 +26,7 @@ from Util.ALiYunUtil import ALiYunUtil
# 初始化日志 # 初始化日志
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
handler = RotatingFileHandler('Logs/start.log', maxBytes=1024 * 1024, backupCount=5) handler = RotatingFileHandler('../Logs/start.log', maxBytes=1024 * 1024, backupCount=5)
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
logger.addHandler(handler) logger.addHandler(handler)
@ -60,7 +60,7 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan) app = FastAPI(lifespan=lifespan)
# 挂载静态文件目录 # 挂载静态文件目录
app.mount("/static", StaticFiles(directory="Static"), name="static") app.mount("../static", StaticFiles(directory="Static"), name="static")
# 将文本转换为嵌入向量 # 将文本转换为嵌入向量

@ -1,26 +1,20 @@
import logging
import os import os
import subprocess import subprocess
import tempfile import tempfile
import urllib.parse import urllib.parse
import uuid import uuid
from contextlib import asynccontextmanager
from io import BytesIO from io import BytesIO
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
from typing import List from typing import List
import jieba # 导入 jieba 分词库
import uvicorn import uvicorn
from fastapi import FastAPI, Request, HTTPException from fastapi import FastAPI, Request, HTTPException
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
from gensim.models import KeyedVectors from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, ValidationError
from starlette.responses import StreamingResponse from starlette.responses import StreamingResponse
from Config.Config import MS_MODEL_PATH, MS_MODEL_LIMIT, MS_HOST, MS_PORT, MS_MAX_CONNECTIONS, MS_NPROBE, \ from Config.Config import ES_CONFIG
MS_COLLECTION_NAME, ES_CONFIG
from Milvus.Utils.MilvusCollectionManager import MilvusCollectionManager
from Milvus.Utils.MilvusConnectionPool import *
from Milvus.Utils.MilvusConnectionPool import MilvusConnectionPool
from Util.ALiYunUtil import ALiYunUtil from Util.ALiYunUtil import ALiYunUtil
from Util.EsSearchUtil import EsSearchUtil from Util.EsSearchUtil import EsSearchUtil
Loading…
Cancel
Save