Files
rag/main.py
lacerate551 858ee40e5b chore: 同步项目状态
- main.py: 去掉 emoji 避免 GBK 编码崩溃
- docs/curl测试手册.md: 更新模型名和测试日期
- docs/代码审查报告_2026-06-05.md: 删除过期报告
- docs/main分支独有功能说明.md: 新增
- docs/出题系统逻辑.md: 新增
2026-06-19 15:25:57 +08:00

55 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
RAG API 服务 - 统一启动入口
使用方式:
python main.py # 启动服务(默认端口 5001
python main.py --port 8080 # 指定端口
python main.py --host 127.0.0.1 # 仅本机访问
等效于旧入口: python rag_api_server.py
"""
import sys
import os
import argparse
import warnings
# 抑制第三方库的已知警告
warnings.filterwarnings("ignore", message="pkg_resources is deprecated")
warnings.filterwarnings("ignore", category=FutureWarning, module="core.agentic")
# 确保项目根目录在 Python 路径中
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
def main():
parser = argparse.ArgumentParser(description='RAG API 服务')
parser.add_argument('--host', default='0.0.0.0', help='监听地址(默认 0.0.0.0')
parser.add_argument('--port', type=int, default=5001, help='监听端口(默认 5001')
parser.add_argument('--debug', action='store_true', default=False, help='调试模式')
parser.add_argument('--no-debug', action='store_true', help='关闭调试模式')
args = parser.parse_args()
debug = args.debug and not args.no_debug
# 通过工厂函数创建应用
from api import create_app
app = create_app()
print(f"\nRAG API 服务启动: http://{args.host}:{args.port}")
print(f" 调试模式: {'开启' if debug else '关闭'}")
app.run(
host=args.host,
port=args.port,
debug=debug,
threaded=True,
use_reloader=False
)
if __name__ == '__main__':
main()