diff --git a/backend/.env.example b/backend/.env.example index b10fd86..06de962 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -30,8 +30,14 @@ REDIS_URL="redis://localhost:6379/0" # ==================== LLM AI 配置 ==================== # 大语言模型 API 配置 LLM_API_KEY="your_api_key_here" -LLM_BASE_URL="https://api.minimax.chat/v1" -LLM_MODEL_NAME="MiniMax-Text-01" +LLM_BASE_URL="" +LLM_MODEL_NAME="" + +# ==================== Supabase 配置 ==================== +# Supabase 项目配置 +SUPABASE_URL="your_supabase_url_here" +SUPABASE_ANON_KEY="your_supabase_anon_key_here" +SUPABASE_SERVICE_KEY="your_supabase_service_key_here" # ==================== 文件路径配置 ==================== # 上传文件存储目录 (相对于项目根目录) diff --git a/backend/app/config.py b/backend/app/config.py index 879555d..84115f9 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -29,6 +29,11 @@ class Settings(BaseSettings): LLM_BASE_URL: str = "https://api.minimax.chat" LLM_MODEL_NAME: str = "MiniMax-Text-01" + # ==================== Supabase 配置 ==================== + SUPABASE_URL: str = "" + SUPABASE_ANON_KEY: str = "" + SUPABASE_SERVICE_KEY: str = "" + # ==================== 文件路径配置 ==================== BASE_DIR: Path = Path(__file__).resolve().parent.parent.parent UPLOAD_DIR: str = "data/uploads" diff --git a/backend/app/core/database/__pycache__/mongodb.cpython-312.pyc b/backend/app/core/database/__pycache__/mongodb.cpython-312.pyc index 479f37b..1d102ac 100644 Binary files a/backend/app/core/database/__pycache__/mongodb.cpython-312.pyc and b/backend/app/core/database/__pycache__/mongodb.cpython-312.pyc differ diff --git a/backend/app/core/database/mongodb.py b/backend/app/core/database/mongodb.py index a4fb7eb..39763b8 100644 --- a/backend/app/core/database/mongodb.py +++ b/backend/app/core/database/mongodb.py @@ -237,7 +237,6 @@ class MongoDB: # RAG索引集合索引 await self.rag_index.create_index("table_name") await self.rag_index.create_index("field_name") - await self.rag_index.create_index([("embedding", "hnsw", {"type": "knnVector"})]) logger.info("MongoDB 索引创建完成") diff --git a/backend/test_mongodb.py b/backend/test_mongodb.py new file mode 100644 index 0000000..5fa3e02 --- /dev/null +++ b/backend/test_mongodb.py @@ -0,0 +1,46 @@ +""" +MongoDB 数据库连接测试 +""" +import asyncio +from app.core.database.mongodb import mongodb + + +async def test_mongodb(): + print("=" * 50) + print("MongoDB 数据库连接测试") + print("=" * 50) + + try: + # 连接 + await mongodb.connect() + print(f"✓ MongoDB 连接成功: {mongodb.client}") + + # 测试插入 + test_doc = {"test": "hello", "value": 123} + doc_id = await mongodb.client.test_database.test_collection.insert_one(test_doc) + print(f"✓ 写入测试成功, ID: {doc_id.inserted_id}") + + # 测试查询 + doc = await mongodb.client.test_database.test_collection.find_one({"test": "hello"}) + print(f"✓ 读取测试成功: {doc}") + + # 删除测试数据 + await mongodb.client.test_database.test_collection.delete_one({"test": "hello"}) + print(f"✓ 删除测试数据成功") + + # 列出数据库 + dbs = await mongodb.client.list_database_names() + print(f"✓ 数据库列表: {dbs}") + + print("\n✓ MongoDB 测试通过!") + return True + + except Exception as e: + print(f"\n✗ MongoDB 测试失败: {e}") + return False + finally: + await mongodb.close() + + +if __name__ == "__main__": + asyncio.run(test_mongodb()) diff --git a/backend/test_mysql.py b/backend/test_mysql.py new file mode 100644 index 0000000..9e27335 --- /dev/null +++ b/backend/test_mysql.py @@ -0,0 +1,37 @@ +""" +MySQL 数据库连接测试 +""" +import asyncio +from sqlalchemy import text +from app.core.database.mysql import mysql_db + + +async def test_mysql(): + print("=" * 50) + print("MySQL 数据库连接测试") + print("=" * 50) + + try: + # 测试连接 + async with mysql_db.async_session_factory() as session: + result = await session.execute(text("SELECT 1")) + print(f"✓ MySQL 连接成功: {result.fetchone()}") + + # 测试查询数据库 + async with mysql_db.async_session_factory() as session: + result = await session.execute(text("SHOW DATABASES")) + dbs = result.fetchall() + print(f"✓ 数据库列表: {[db[0] for db in dbs]}") + + print("\n✓ MySQL 测试通过!") + return True + + except Exception as e: + print(f"\n✗ MySQL 测试失败: {e}") + return False + finally: + await mysql_db.close() + + +if __name__ == "__main__": + asyncio.run(test_mysql()) diff --git a/backend/test_redis.py b/backend/test_redis.py new file mode 100644 index 0000000..5cdd5d4 --- /dev/null +++ b/backend/test_redis.py @@ -0,0 +1,46 @@ +""" +Redis 数据库连接测试 +""" +import asyncio +from app.core.database.redis_db import redis_db + + +async def test_redis(): + print("=" * 50) + print("Redis 数据库连接测试") + print("=" * 50) + + try: + # 连接 + await redis_db.connect() + print(f"✓ Redis 连接成功") + + # 测试写入 + await redis_db.client.set("test_key", "hello_redis") + print(f"✓ 写入测试成功") + + # 测试读取 + value = await redis_db.client.get("test_key") + print(f"✓ 读取测试成功: {value}") + + # 测试删除 + await redis_db.client.delete("test_key") + print(f"✓ 删除测试成功") + + # 测试任务状态 + await redis_db.set_task_status("test_task", "processing", {"progress": 50}) + status = await redis_db.get_task_status("test_task") + print(f"✓ 任务状态测试成功: {status}") + + print("\n✓ Redis 测试通过!") + return True + + except Exception as e: + print(f"\n✗ Redis 测试失败: {e}") + return False + finally: + await redis_db.close() + + +if __name__ == "__main__": + asyncio.run(test_redis()) diff --git a/frontend/.env b/frontend/.env index 82eaa83..426fac9 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,7 +1,7 @@ VITE_APP_ID=app-a6ww9j3ja3nl -VITE_SUPABASE_URL=https://backend.appmiaoda.com/projects/supabase290100332300644352 +VITE_SUPABASE_URL=https://ojtxpvjgqoybhmadimym.supabase.co -VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoyMDg4NTkyNTA5LCJpc3MiOiJzdXBhYmFzZSIsInJvbGUiOiJhbm9uIiwic3ViIjoiYW5vbiJ9.sdVzWIT_AjxVjEmBaEQcOoFGlHTTT8NH59fYdkaA4WU +VITE_SUPABASE_ANON_KEY=sb_publishable_VMZMg44D-9bKE6bsbUiSsw_x3rUJbu2 VITE_BACKEND_API_URL=http://localhost:8000/api/v1 diff --git a/frontend/src/routes.tsx b/frontend/src/routes.tsx index f3e0e5b..0b405c7 100644 --- a/frontend/src/routes.tsx +++ b/frontend/src/routes.tsx @@ -6,7 +6,6 @@ import FormFill from '@/pages/FormFill'; import Assistant from '@/pages/Assistant'; import ExcelParse from '@/pages/ExcelParse'; import MainLayout from '@/components/layouts/MainLayout'; -import { RouteGuard } from '@/components/common/RouteGuard'; export const routes = [ { @@ -15,11 +14,7 @@ export const routes = [ }, { path: '/', - element: ( - - - - ), + element: , children: [ { path: '/',