更新后端
This commit is contained in:
@@ -30,8 +30,14 @@ REDIS_URL="redis://localhost:6379/0"
|
|||||||
# ==================== LLM AI 配置 ====================
|
# ==================== LLM AI 配置 ====================
|
||||||
# 大语言模型 API 配置
|
# 大语言模型 API 配置
|
||||||
LLM_API_KEY="your_api_key_here"
|
LLM_API_KEY="your_api_key_here"
|
||||||
LLM_BASE_URL="https://api.minimax.chat/v1"
|
LLM_BASE_URL=""
|
||||||
LLM_MODEL_NAME="MiniMax-Text-01"
|
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"
|
||||||
|
|
||||||
# ==================== 文件路径配置 ====================
|
# ==================== 文件路径配置 ====================
|
||||||
# 上传文件存储目录 (相对于项目根目录)
|
# 上传文件存储目录 (相对于项目根目录)
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ class Settings(BaseSettings):
|
|||||||
LLM_BASE_URL: str = "https://api.minimax.chat"
|
LLM_BASE_URL: str = "https://api.minimax.chat"
|
||||||
LLM_MODEL_NAME: str = "MiniMax-Text-01"
|
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
|
BASE_DIR: Path = Path(__file__).resolve().parent.parent.parent
|
||||||
UPLOAD_DIR: str = "data/uploads"
|
UPLOAD_DIR: str = "data/uploads"
|
||||||
|
|||||||
Binary file not shown.
@@ -237,7 +237,6 @@ class MongoDB:
|
|||||||
# RAG索引集合索引
|
# RAG索引集合索引
|
||||||
await self.rag_index.create_index("table_name")
|
await self.rag_index.create_index("table_name")
|
||||||
await self.rag_index.create_index("field_name")
|
await self.rag_index.create_index("field_name")
|
||||||
await self.rag_index.create_index([("embedding", "hnsw", {"type": "knnVector"})])
|
|
||||||
|
|
||||||
logger.info("MongoDB 索引创建完成")
|
logger.info("MongoDB 索引创建完成")
|
||||||
|
|
||||||
|
|||||||
46
backend/test_mongodb.py
Normal file
46
backend/test_mongodb.py
Normal file
@@ -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())
|
||||||
37
backend/test_mysql.py
Normal file
37
backend/test_mysql.py
Normal file
@@ -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())
|
||||||
46
backend/test_redis.py
Normal file
46
backend/test_redis.py
Normal file
@@ -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())
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
VITE_APP_ID=app-a6ww9j3ja3nl
|
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
|
VITE_BACKEND_API_URL=http://localhost:8000/api/v1
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import FormFill from '@/pages/FormFill';
|
|||||||
import Assistant from '@/pages/Assistant';
|
import Assistant from '@/pages/Assistant';
|
||||||
import ExcelParse from '@/pages/ExcelParse';
|
import ExcelParse from '@/pages/ExcelParse';
|
||||||
import MainLayout from '@/components/layouts/MainLayout';
|
import MainLayout from '@/components/layouts/MainLayout';
|
||||||
import { RouteGuard } from '@/components/common/RouteGuard';
|
|
||||||
|
|
||||||
export const routes = [
|
export const routes = [
|
||||||
{
|
{
|
||||||
@@ -15,11 +14,7 @@ export const routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
element: (
|
element: <MainLayout />,
|
||||||
<RouteGuard>
|
|
||||||
<MainLayout />
|
|
||||||
</RouteGuard>
|
|
||||||
),
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|||||||
Reference in New Issue
Block a user