feat:测试验证
This commit is contained in:
Binary file not shown.
@@ -10,7 +10,7 @@ class Config:
|
||||
ALIBABA_MODEL_NAME = "qwen-plus-latest"
|
||||
|
||||
# 数据库配置
|
||||
DATABASE_URL = "mysql+pymysql://tsp_assistant:123456@43.134.68.207/tsp_assistant?charset=utf8mb4"
|
||||
DATABASE_URL = "mysql+pymysql://tsp_assistant:123456@jeason.online/tsp_assistant?charset=utf8mb4"
|
||||
|
||||
# 知识库配置
|
||||
KNOWLEDGE_BASE_PATH = "data/knowledge_base"
|
||||
|
||||
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
||||
@dataclass
|
||||
class DatabaseConfig:
|
||||
"""数据库配置"""
|
||||
url: str = "mysql+pymysql://tsp_assistant:password@43.134.68.207/tsp_assistant?charset=utf8mb4"
|
||||
url: str = "mysql+pymysql://tsp_assistant:password@jeason.online/tsp_assistant?charset=utf8mb4"
|
||||
pool_size: int = 10
|
||||
max_overflow: int = 20
|
||||
pool_timeout: int = 30
|
||||
|
||||
Binary file not shown.
@@ -34,10 +34,13 @@ class DatabaseManager:
|
||||
max_overflow=30, # 增加溢出连接数
|
||||
pool_pre_ping=True,
|
||||
pool_recycle=1800, # 减少回收时间
|
||||
pool_timeout=10, # 连接超时
|
||||
pool_timeout=30, # 连接池超时(秒)
|
||||
connect_args={
|
||||
"charset": "utf8mb4",
|
||||
"autocommit": False
|
||||
"autocommit": False,
|
||||
"connect_timeout": 30, # 连接超时(秒)- 适用于网络延迟较大的情况
|
||||
"read_timeout": 30, # 读取超时(秒)
|
||||
"write_timeout": 30, # 写入超时(秒)
|
||||
}
|
||||
)
|
||||
else:
|
||||
|
||||
BIN
src/utils/__pycache__/encoding_helper.cpython-311.pyc
Normal file
BIN
src/utils/__pycache__/encoding_helper.cpython-311.pyc
Normal file
Binary file not shown.
66
src/utils/encoding_helper.py
Normal file
66
src/utils/encoding_helper.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
编码辅助工具
|
||||
提供UTF-8编码相关的辅助函数
|
||||
"""
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
|
||||
|
||||
def setup_utf8_output():
|
||||
"""设置标准输出为UTF-8编码(Windows系统)"""
|
||||
if sys.platform == 'win32':
|
||||
try:
|
||||
# 设置标准输出编码
|
||||
if hasattr(sys.stdout, 'buffer'):
|
||||
sys.stdout = io.TextIOWrapper(
|
||||
sys.stdout.buffer,
|
||||
encoding='utf-8',
|
||||
errors='replace',
|
||||
line_buffering=True
|
||||
)
|
||||
if hasattr(sys.stderr, 'buffer'):
|
||||
sys.stderr = io.TextIOWrapper(
|
||||
sys.stderr.buffer,
|
||||
encoding='utf-8',
|
||||
errors='replace',
|
||||
line_buffering=True
|
||||
)
|
||||
# 设置控制台代码页为UTF-8
|
||||
os.system('chcp 65001 >nul 2>&1')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def safe_print(*args, **kwargs):
|
||||
"""安全的UTF-8打印函数"""
|
||||
try:
|
||||
print(*args, **kwargs)
|
||||
except UnicodeEncodeError:
|
||||
# 如果输出失败,尝试使用ASCII安全版本
|
||||
safe_args = []
|
||||
for arg in args:
|
||||
if isinstance(arg, str):
|
||||
try:
|
||||
safe_args.append(arg.encode('ascii', 'replace').decode('ascii'))
|
||||
except:
|
||||
safe_args.append(repr(arg))
|
||||
else:
|
||||
safe_args.append(arg)
|
||||
print(*safe_args, **kwargs)
|
||||
|
||||
|
||||
def read_file_utf8(file_path: str) -> str:
|
||||
"""读取UTF-8编码的文件"""
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def write_file_utf8(file_path: str, content: str):
|
||||
"""写入UTF-8编码的文件"""
|
||||
os.makedirs(os.path.dirname(file_path) if os.path.dirname(file_path) else '.', exist_ok=True)
|
||||
with open(file_path, 'w', encoding='utf-8', newline='\n') as f:
|
||||
f.write(content)
|
||||
|
||||
Reference in New Issue
Block a user