本项目是一个用于 AI 行为研究的综合平台,专注于研究 AI 的行为模式、社会关系及决策过程。
- 🤖 模块化的 AI 行为研究系统
- 🌟 支持多种大语言模型(OpenAI、Ollama等)
- 💬 实时对话生成与分析
- 📊 数据可视化与轨迹追踪
- 🔄 交互式研究环境
- 📅 完整的历史记录系统
- AI 角色扮演对话系统
- 支持人机交互和 AI 自主对话
- 对话历史记录与分析
- 灵活的角色切换机制
- 二维坐标系中的 AI 移动行为分析
- 实时轨迹可视化
- 基于历史数据的决策分析
- 轨迹记录与回放功能
two/
├── app.py # 主应用入口
├── config.py # 全局配置
├── main.py # Streamlit主程序
├── requirements.txt # 项目依赖
├── .env.example # 环境变量示例
│
├── modules/ # 核心模块
│ ├── services/ # 服务层
│ │ ├── __init__.py
│ │ ├── ai_service.py # AI服务接口
│ │ ├── auth_service.py # 认证服务
│ │ └── data_service.py # 数据服务
│ │
│ └── spatial_decision/ # 空间决策模块
│ ├── __init__.py
│ ├── analysis/ # 分析组件
│ │ ├── __init__.py
│ │ ├── trajectory_analysis.py # 轨迹分析
│ │ └── pattern_recognition.py # 模式识别
│ │
│ ├── coordinate/ # 坐标系统
│ │ ├── __init__.py
│ │ ├── grid.py # 网格系统
│ │ └── transform.py # 坐标转换
│ │
│ └── visualization/ # 可视化组件
│ ├── __init__.py
│ ├── trajectory_plot.py # 轨迹绘制
│ └── heatmap.py # 热力图
│
├── data/ # 数据文件
│ ├── config/ # 配置文件
│ ├── trajectories/ # 轨迹数据
│ └── messages/ # 对话记录
│
├── pages/ # Streamlit页面
├── tests/ # 测试文件
├── utils/ # 工具函数
└── assets/ # 静态资源
服务层提供核心功能接口:
- ai_service.py:
- AI模型接口封装
- 提示词管理
- 对话上下文处理
- 模型响应处理
- auth_service.py:
- 用户认证
- 权限管理
- 会话控制
- data_service.py:
- 数据存储接口
- 数据格式转换
- 数据验证
- trajectory_analysis.py:
- 轨迹数据预处理
- 路径特征提取
- 移动模式分析
- 决策点识别
- pattern_recognition.py:
- 行为模式识别
- 异常检测
- 趋势分析
- grid.py:
- 网格系统实现
- 空间索引
- 碰撞检测
- transform.py:
- 坐标系转换
- 投影变换
- 比例尺处理
- trajectory_plot.py:
- 轨迹实时绘制
- 路径动画
- 多轨迹对比
- heatmap.py:
- 活动热力图
- 密度分布
- 时空分布可视化
- 克隆项目
git clone https://github.com/yourusername/two.git
cd two- 创建虚拟环境
python -m venv venv
source venv/bin/activate # Linux/Mac
# 或
.\venv\Scripts\activate # Windows- 安装依赖
pip install -r requirements.txt- 环境变量配置
cp .env.example .env
# 编辑 .env 文件,配置必要的环境变量streamlit run main.py访问 http://localhost:8501 开始使用
- 支持 OpenAI API 和本地 Ollama 模型
- 在
.env文件中配置 API 密钥和模型参数 - 可在
data/config/prompts_config.json中自定义提示词
- Python 3.8+
- 稳定的网络连接(使用 OpenAI API 时)
- 充足的系统内存(使用本地模型时)
- 对话历史:
data/messages/ - 轨迹数据:
data/trajectories/ - 配置文件:
data/config/
- 内置数据分析工具
- 可视化图表生成
- 轨迹回放功能
- 在相应模块目录创建新文件
- 遵循现有的代码结构和命名规范
- 编写单元测试
- 更新文档
- 遵循 PEP 8 规范
- 使用类型注解
- 编写详细的文档字符串
-
Q: 如何切换 AI 模型? A: 在配置文件中修改 model_provider 设置
-
Q: 数据如何备份? A: 所有数据自动保存在 data 目录,建议定期备份该目录
-
Q: 如何自定义研究场景? A: 修改
data/config/prompts_config.json中的场景设置
- 初始版本发布
- 实现基础对话功能
- 集成 OpenAI 和 Ollama 模型
- 添加空间决策分析模块
MIT License
欢迎提交 Issue 和 Pull Request!
This project is a comprehensive platform for AI behavior research, focusing on studying AI behavioral patterns, social relationships, and decision-making processes.
- 🤖 Modular AI behavior research system
- 🌟 Support for multiple LLMs (OpenAI, Ollama, etc.)
- 💬 Real-time dialogue generation and analysis
- 📊 Data visualization and trajectory tracking
- 🔄 Interactive research environment
- 📅 Complete history recording system
- AI role-playing dialogue system
- Support for human-AI interaction and AI autonomous dialogue
- Dialogue history recording and analysis
- Flexible role-switching mechanism
- AI movement behavior analysis in 2D coordinate system
- Real-time trajectory visualization
- Decision analysis based on historical data
- Trajectory recording and playback
[Same as Chinese version above]
Service layer provides core functional interfaces:
- ai_service.py:
- AI model interface encapsulation
- Prompt management
- Dialogue context handling
- Model response processing
- auth_service.py:
- User authentication
- Permission management
- Session control
- data_service.py:
- Data storage interface
- Data format conversion
- Data validation
- trajectory_analysis.py:
- Trajectory data preprocessing
- Path feature extraction
- Movement pattern analysis
- Decision point identification
- pattern_recognition.py:
- Behavior pattern recognition
- Anomaly detection
- Trend analysis
- grid.py:
- Grid system implementation
- Spatial indexing
- Collision detection
- transform.py:
- Coordinate system conversion
- Projection transformation
- Scale handling
- trajectory_plot.py:
- Real-time trajectory plotting
- Path animation
- Multi-trajectory comparison
- heatmap.py:
- Activity heatmap
- Density distribution
- Spatiotemporal distribution visualization
[... Keep the original content ...]