FashionAgent:人工智能驱动的时尚零售预测
📖 引言
FashionAgent是一种人工智能驱动的解决方案,旨在增强时尚零售业的预测和决策能力。通过整合各种数据源,它提供了可操作的见解,以优化库存管理和销售策略。
🛠️ 安装说明
1.克隆存储库
git clone https://github.com/yourusername/FashionAgent.git
cd FashionAgent_HybridSetup_Prod_Repo2.创建虚拟环境
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt3.配置环境变量
编辑 run_mcp.sh 设置您的Salesforce、Azure SQL、Snowflake和Slack凭据。该脚本包含以下环境变量的占位符:
SALESFORCE_USERNAME:您的Salesforce用户名SALESFORCE_PASSWORD:您的Salesforce密码SALESFORCE_TOKEN:您的Salesforce安全令牌AZURESQL_CONN:您的Azure SQL连接字符串SNOWFLAKE_CONN:您的Snowflake连接字符串(格式:“用户=用户名密码=密码帐户=帐户仓库=仓库数据库=数据库架构=架构”)SLACK_WEBHOOK:您的Slack webhook URLMCP_URL:MCP服务器URL(默认值:“http://localhost:8000")MCP_API_KEY:用于MCP身份验证的可选API密钥SF_OBJECT:要查询的Salesforce对象(默认值:“Opportunity”)EXCEL_FOLDER:Excel文件的路径(默认:“/dbfs/mnt/Excel_drop”)HORIZON:预测范围(以天为单位)(默认值:28)
4.运行MCP服务器
bash run_mcp.sh这将在以下位置启动FastAPI MCP服务器 http://localhost:8000.
5.上传到copula
- 首选 数据砖CE
- 创建一个集群(Python 3.x,小节点)
- 导入
orchestrator.py - 附加
requirements.txt作为一个图书馆 - 运行作业
6.查看预测和警报
- 预测输出存储在Delta表(ViewModel)中。
- 松弛警报将发送到配置的通道。
______________________________________________________________________
📊 工作流示例
- 从Salesforce Sandbox获取CRM数据。
- 从Excel(谷歌云端硬盘/本地)加载库存表。
- 从Azure SQL查询销售交易记录。
- 从Snowflake取回仓库库存。
- 将数据合并到单个特征存储中。
- 跑
demand_forecaster.py预测需求。 - 比较需求与库存。
- 如果预测到库存短缺,则触发Slack警报。
______________________________________________________________________
🧑💻 技术栈
- copula (Spark编排)
- MCP协议 (本地FastAPI服务器)
- Salesforce沙盒 (客户关系管理)
- Azure SQL、Snowflake、Excel (数据来源)
- PySpark,Pandas,MLlib (预测)
- 松弛API (警报)
______________________________________________________________________
📌 后续步骤
- 扩展MCP以支持外部应用程序的工具清单。
- 添加实时API触发器,而不是批量处理。
- 在Azure应用服务上部署MCP服务器以实现可扩展性。
______________________________________________________________________
✅ 通过此设置,您可以演示一个与时尚行业招聘人员和基于产品的公司产生共鸣的企业级AI Agent。
______________________________________________________________________
📁 项目结构
FashionAgent/
├── README.md # Project documentation
├── requirements.txt # Python dependencies
├── agent/ # Main agent module
│ ├── agent.py # Main agent class and logic
│ ├── config.py # Configuration management
│ ├── logging_conf.py # Logging configuration
│ ├── mcp_client.py # MCP client implementation
│ ├── orchestrator.py # Workflow orchestration
│ ├── actions/ # Action handlers
│ │ └── alert.py # Alert generation and handling
│ ├── connectors/ # Data source connectors
│ │ ├── __init__.py
│ │ ├── azuresql_connector.py # Azure SQL connector
│ │ ├── excel_connector.py # Excel file connector
│ │ ├── pos_connector.py # POS system connector
│ │ ├── salesforce_connector.py # Salesforce CRM connector
│ │ ├── snowflake_connector.py # Snowflake data warehouse connector
│ │ └── social_connector.py # Social media data connector
│ └── forecasting/ # Forecasting module
│ ├── __init__.py
│ ├── features.py # Feature engineering
│ └── model.py # ML model implementation
└── mcp_server/ # MCP server implementation
└── app.py # FastAPI MCP server application此结构将代码组织成逻辑模块:
- 代理商/:核心AI代理功能
- 连接器/:数据源集成
- 预测/:机器学习和预测逻辑
- mcp服务器/:模型上下文协议服务器
- 行动/:具体行动实施
