# 软开-北疆星链-python **Repository Path**: zhao-rui3/rk-bjxl-python ## Basic Information - **Project Name**: 软开-北疆星链-python - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-17 - **Last Updated**: 2025-11-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 北疆星链大模型 - FastAPI版本 基于FastAPI重新实现的AI聊天系统,原项目基于Spring Boot。 ## 项目结构 ``` RK-BJXL-Python/ ├── main.py # 主程序入口 ├── requirements.txt # 依赖包列表 ├── config/ │ ├── __init__.py │ └── settings.py # 应用配置 ├── routers/ │ ├── __init__.py │ ├── chat.py # 聊天相关路由 │ └── crud.py # CRUD操作路由 ├── models/ │ └── tab_command.py # 数据库模型 ├── services/ │ └── chat_service.py # 聊天服务 ├── database/ │ └── database.py # 数据库配置 └── static/ ├── index.html # 主页面 ├── yemianer.html # 聊天页面 ├── 背景.png # 背景图片 ├── css/ # 样式文件 └── js/ # JavaScript文件 ``` ## 功能特性 - ✅ **AI聊天功能**:集成FastGPT API,支持流式响应 - ✅ **数据库操作**:MySQL数据库存储标签和指令数据 - ✅ **RESTful API**:完整的CRUD接口 - ✅ **前端界面**:基于Vue.js的现代化聊天界面 - ✅ **响应式设计**:支持移动端和暗黑模式 ## 安装和运行 ### 1. 安装依赖 ```bash pip install -r requirements.txt ``` ### 2. 配置环境变量 创建 `.env` 文件(可选,默认配置已内置): ```env DEBUG=True HOST=0.0.0.0 PORT=8000 # FastGPT配置 FASTGPT_API_URL=http://45.207.195.154:3000/api/v1/chat/completions FASTGPT_API_KEY=your_api_key_here FASTGPT_MODEL_NAME=gpt-3.5-turbo # 数据库配置 DATABASE_URL=mysql+pymysql://username:password@host:port/database # Redis配置 REDIS_HOST=45.207.195.154 REDIS_PORT=6379 REDIS_PASSWORD=your_redis_password ``` ### 3. 运行应用 ```bash python main.py ``` 或使用uvicorn: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` ### 4. 访问应用 - 主页:http://localhost:8000 - API文档:http://localhost:8000/docs - 聊天页面:http://localhost:8000/yemianer ## API接口 ### 聊天接口 - `GET /api/chat_http` - HTTP聊天接口 - `GET /api/chat` - 流式聊天接口 - `POST /api/chat_http` - POST聊天接口 ### 数据管理接口 #### 标签管理 - `POST /api/tabs` - 创建标签 - `GET /api/tabs` - 获取标签列表 - `GET /api/tabs/{id}` - 获取单个标签 - `PUT /api/tabs/{id}` - 更新标签 - `DELETE /api/tabs/{id}` - 删除标签 #### 指令管理 - `POST /api/commands` - 创建指令 - `GET /api/commands` - 获取指令列表 - `GET /api/commands/{id}` - 获取单个指令 - `GET /api/tabs/{tab_id}/commands` - 根据标签获取指令 - `PUT /api/commands/{id}` - 更新指令 - `DELETE /api/commands/{id}` - 删除指令 ## 技术栈 - **后端框架**:FastAPI - **数据库ORM**:SQLAlchemy - **数据库**:MySQL - **缓存**:Redis - **前端框架**:Vue.js 3 - **样式框架**:Tailwind CSS - **HTTP客户端**:httpx ## 开发说明 ### 数据库模型 项目使用SQLAlchemy ORM,包含两个主要模型: - `TbTab`:标签表,存储标签信息 - `TbCommand`:指令表,存储指令信息并关联标签 ### 聊天服务 `ChatService`类负责与FastGPT API交互: - 支持HTTP和流式两种模式 - 异步处理,提高性能 - 完善的错误处理 ### 前端界面 - 基于Vue.js 3 Composition API - 响应式设计,支持移动端 - 暗黑模式支持 - 实时流式响应展示 - 丰富的用户交互功能 ## 部署建议 ### Docker部署 创建 `Dockerfile`: ```dockerfile FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . EXPOSE 8000 CMD ["python", "main.py"] ``` ### 生产环境配置 1. 使用环境变量管理敏感配置 2. 启用HTTPS 3. 配置反向代理(Nginx) 4. 设置日志记录 5. 配置监控和告警 ## 贡献 欢迎提交Issue和Pull Request来改进项目。 ## 许可证 本项目采用MIT许可证。