Merge branch 'dev' into test

This commit is contained in:
sophie committed 2026-05-13 08:09:28 +08:00
commit f3a2007299
3 files changed
+43 -16

No files matched your search

+5 -4
View File
@@ -1,4 +1,4 @@
FROM python:3.12-slim-bookworm
FROM python:3.12-slim-bookworm
WORKDIR /app
@@ -10,11 +10,12 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Copy backend code and bundled Text2SQL schema docs
COPY backend/ .
COPY docs /app/docs
ENV ORACLE_HOME=/app/oracle_client/instantclient_19_31
ENV LD_LIBRARY_PATH=/app/oracle_client/instantclient_19_31:/app/oracle_client:${LD_LIBRARY_PATH}
+35 -9
View File
@@ -154,15 +154,41 @@ class Text2SQLService:
@classmethod
def get_schema(cls):
if cls._schema_text is None:
try:
# docs is at the project root: c:\Users\PC\Desktop\HX工作目录\hxops\hxops\docs
# This file is in backend/app/services/text2sql.py
base_dir = cls._project_root()
doc_path = os.path.join(base_dir, 'docs', '(表+字段).md')
with open(doc_path, 'r', encoding='utf-8') as f:
cls._schema_text = f.read()
except Exception as e:
cls._schema_text = f"Failed to load schema: {e}"
schema_filename = '(表+字段).md'
env_path = (os.getenv("TEXT2SQL_SCHEMA_PATH") or "").strip()
candidate_paths = []
if env_path:
candidate_paths.append(env_path)
candidate_paths.extend([
os.path.join(cls._backend_dir(), 'docs', schema_filename),
os.path.join(cls._project_root(), 'docs', schema_filename),
os.path.join(os.getcwd(), 'docs', schema_filename),
])
unique_paths = []
seen = set()
for path in candidate_paths:
normalized = os.path.normpath(path)
if normalized not in seen:
seen.add(normalized)
unique_paths.append(path)
for doc_path in unique_paths:
try:
if not os.path.exists(doc_path):
continue
with open(doc_path, 'r', encoding='utf-8') as f:
cls._schema_text = f.read()
cls._log("info", f"Loaded Text2SQL schema from {doc_path}")
break
except Exception as exc:
cls._log("warning", f"Failed to load Text2SQL schema from {doc_path}: {exc}")
if cls._schema_text is None:
tried = ", ".join(unique_paths)
cls._schema_text = f"Failed to load schema: schema file not found. Tried: {tried}"
cls._log("warning", cls._schema_text)
return cls._schema_text
@staticmethod
+3 -3
View File
@@ -1,12 +1,12 @@
services:
services:
# ==============================================================================
# hxops-backend: Flask 后端服务 (端口: 5000)
# ==============================================================================
hxops-backend:
image: ${BACKEND_IMAGE:-hxops-backend:local}
build:
context: ./backend
dockerfile: Dockerfile
context: .
dockerfile: backend/Dockerfile
container_name: hxops-backend
restart: always
# 与 scripts/deploy_compose.sh 使用的 .env.<ENV_NAME> 对齐(通过 COMPOSE_ENV_BASENAME)