Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file modified .DS_Store
Binary file not shown.
86 changes: 86 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Agentic-AI 环境配置模板
# 复制此文件为 .env 并填入真实的配置值

# ===== 基础配置 =====
# 环境类型 (local/test/prod)
ENVIRONMENT=local

# 调试模式
DEBUG=true

# 日志级别 (DEBUG/INFO/WARNING/ERROR)
LOG_LEVEL=INFO

# ===== LLM 模型配置 =====
# 默认使用的 LLM 模型
# 支持的格式: openai:gpt-4, dashscope:qwen3-max, deepseek:deepseek-chat
NOBEL_LLM_MODEL=dashscope:qwen3-max

# ===== API Keys =====
# OpenAI API Key (用于 GPT 模型)
OPENAI_API_KEY=your_openai_api_key_here

# Dashscope API Key (用于 Qwen 模型)
DASHSCOPE_API_KEY=your_dashscope_api_key_here

# DeepSeek API Key (用于 DeepSeek 模型)
DEEPSEEK_API_KEY=your_deepseek_api_key_here

# ===== 本地开发配置 =====
# 本地 aisuite 路径 (可选,用于使用本地克隆版本)
# AISUITE_PATH=/path/to/your/local/aisuite

# ===== 缓存配置 =====
# 启用缓存
ENABLE_CACHE=true

# 缓存目录
CACHE_DIR=.cache

# ===== API Key 管理配置 =====
# 启用 API Key 自动更新
ENABLE_API_KEY_AUTO_UPDATE=false

# API Key 加密密钥 (生产环境必须设置)
# API_KEY_ENCRYPTION_KEY=your_encryption_key_here

# ===== MCP 服务器配置 =====
# MCP 服务器端口
MCP_SERVER_PORT=3000

# MCP 服务器主机
MCP_SERVER_HOST=localhost

# ===== 数据和输出配置 =====
# 数据目录
DATA_DIR=data

# 输出目录
OUTPUT_DIR=outputs

# 工件目录
ARTIFACTS_DIR=artifacts

# ===== 性能配置 =====
# 并发请求数限制
MAX_CONCURRENT_REQUESTS=5

# 请求超时时间 (秒)
REQUEST_TIMEOUT=30

# ===== 安全配置 =====
# 启用请求验证
ENABLE_REQUEST_VALIDATION=true

# 允许的主机列表 (生产环境)
# ALLOWED_HOSTS=localhost,127.0.0.1

# ===== 监控和日志配置 =====
# 启用性能监控
ENABLE_PERFORMANCE_MONITORING=false

# 日志文件路径
LOG_FILE_PATH=logs/app.log

# 启用详细日志
ENABLE_VERBOSE_LOGGING=false
29 changes: 29 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# Git pre-commit hook 示例
#
# 安装方法:
# cp .githooks/pre-commit .git/hooks/pre-commit
# chmod +x .git/hooks/pre-commit
#
# 或者配置Git使用这个hooks目录:
# git config core.hooksPath .githooks
#

echo "🔍 运行预提交检查..."

# 运行预提交测试脚本
python pre_commit_test.py

# 检查退出状态
if [ $? -ne 0 ]; then
echo ""
echo "❌ 预提交检查失败!"
echo "请修复问题后重新提交。"
echo ""
echo "跳过检查 (不推荐): git commit --no-verify"
exit 1
fi

echo "✅ 预提交检查通过!"
exit 0
101 changes: 92 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,121 @@ name: CI

on:
push:
branches: [ main ]
branches: [ main, develop ]
pull_request:
branches: [ main ]
branches: [ main, develop ]
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
exclude:
# 减少矩阵组合,保留关键测试
- os: macos-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.10'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt', 'requirements-test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-py${{ matrix.python-version }}-pip-

- name: Install system dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y xvfb

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt

- name: Lint with flake8
run: |
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Run tests with coverage (Ubuntu)
if: matrix.os == 'ubuntu-latest'
env:
PYTHONPATH: .
DISPLAY: :99
run: |
xvfb-run -a python -m pytest tests/ -v --cov=src --cov-report=xml --cov-report=term-missing

- name: Run tests (macOS)
if: matrix.os == 'macos-latest'
env:
PYTHONPATH: .
run: |
python -m pytest tests/ -v

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella

integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
- name: Run integration tests
env:
PYTHONPATH: .
DISPLAY: :99
run: |
python -m unittest discover -s tests -p "test_*.py"
sudo apt-get update
sudo apt-get install -y xvfb
xvfb-run -a python -c "
import sys
sys.path.append('.')
from src.analysis.enhanced_viz import EnhancedVizAgent
from src.analysis.nobel_analysis import NobelAnalysisAgent
import pandas as pd

# 测试基本功能
print('Testing EnhancedVizAgent...')
agent = EnhancedVizAgent()
templates = agent.list_available_templates()
print(f'Available templates: {len(templates)}')

# 测试数据分析
print('Testing NobelAnalysisAgent...')
nobel_agent = NobelAnalysisAgent()
print('Integration tests passed!')
"
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,21 @@ cython_debug/
marimo/_static/
marimo/_lsp/
__marimo__/

# Project-specific ignores
# Runtime logs and outputs
run_log_*.json
mcp_result_*.json
eval_*.json
*.zip

# Test artifacts and temporary directories
artifacts/nobel/runs/*/
artifacts/nobel/test_*/
outputs/figures/*/
enhanced_figures/

# Temporary files and directories
temp/
tmp/
.temp/
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# Agentic-AI
Learning use agentic ai and develop the agent

## 🧪 测试

本项目配置了完整的测试系统,帮助你在推送代码前验证更改。

### 快速开始

```bash
# 安装依赖
pip install -r requirements.txt
pip install -r requirements-test.txt

# 运行所有测试
pytest tests/

# 预提交检查
python pre_commit_test.py
```

### 测试选项

```bash
# 使用测试运行器
python run_tests.py --help
python run_tests.py --fast # 快速测试
python run_tests.py --coverage # 带覆盖率的测试
python run_tests.py --lint # 代码质量检查
```

### CI/CD

项目配置了GitHub Actions自动化测试,支持:
- 多Python版本 (3.9-3.12)
- 多操作系统 (Ubuntu, macOS)
- 自动化测试和覆盖率报告

详细测试文档请参考 [TESTING.md](./TESTING.md)
Loading
Loading