187 lines
5.0 KiB
Python
187 lines
5.0 KiB
Python
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""
|
||
|
|
快速启动脚本 - 验证安装并展示基本功能
|
||
|
|
"""
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
def check_installation():
|
||
|
|
"""检查依赖包安装情况"""
|
||
|
|
print("=" * 60)
|
||
|
|
print("Checking environment configuration")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
required_packages = {
|
||
|
|
"autogen": "pyautogen",
|
||
|
|
"dashscope": "dashscope",
|
||
|
|
"streamlit": "streamlit",
|
||
|
|
"pytest": "pytest"
|
||
|
|
}
|
||
|
|
|
||
|
|
missing = []
|
||
|
|
installed = []
|
||
|
|
|
||
|
|
for package, install_name in required_packages.items():
|
||
|
|
try:
|
||
|
|
__import__(package)
|
||
|
|
installed.append(install_name)
|
||
|
|
print(f"[OK] {install_name}: Installed")
|
||
|
|
except ImportError:
|
||
|
|
missing.append(install_name)
|
||
|
|
print(f"[MISSING] {install_name}: Not installed")
|
||
|
|
|
||
|
|
print()
|
||
|
|
|
||
|
|
if missing:
|
||
|
|
print(f"Warning: Missing dependencies: {', '.join(missing)}")
|
||
|
|
print(f"Tip: Run: pip install -r requirements.txt")
|
||
|
|
return False
|
||
|
|
else:
|
||
|
|
print("All dependencies installed successfully!")
|
||
|
|
return True
|
||
|
|
|
||
|
|
|
||
|
|
def check_api_key():
|
||
|
|
"""检查 API Key 配置"""
|
||
|
|
import os
|
||
|
|
|
||
|
|
print("\n" + "=" * 60)
|
||
|
|
print("Checking API Key configuration")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
api_key = os.getenv("DASHSCOPE_API_KEY")
|
||
|
|
|
||
|
|
if not api_key:
|
||
|
|
print("[ERROR] DASHSCOPE_API_KEY environment variable not set")
|
||
|
|
print("\nHow to set:")
|
||
|
|
print(" Windows (PowerShell):")
|
||
|
|
print(' $env:DASHSCOPE_API_KEY="your_api_key_here"')
|
||
|
|
print("\n Linux/Mac:")
|
||
|
|
print(' export DASHSCOPE_API_KEY="your_api_key_here"')
|
||
|
|
return False
|
||
|
|
else:
|
||
|
|
masked_key = api_key[:4] + "..." + api_key[-4:] if len(api_key) > 8 else "***"
|
||
|
|
print(f"[OK] API Key configured: {masked_key}")
|
||
|
|
return True
|
||
|
|
|
||
|
|
|
||
|
|
def show_project_structure():
|
||
|
|
"""展示项目结构"""
|
||
|
|
print("\n" + "=" * 60)
|
||
|
|
print("Project Structure")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
structure = """
|
||
|
|
project/
|
||
|
|
+--- agents/ # Agent modules
|
||
|
|
| +--- pm_agent.py # Product Manager Agent
|
||
|
|
| +--- qa_agent.py # QA Engineer Agent
|
||
|
|
| +--- dev_agent.py # Developer Agent
|
||
|
|
| +--- orchestrator.py # Orchestrator Agent
|
||
|
|
+--- config/ # Configuration
|
||
|
|
| +--- llm_config.py # LLM config & prompts
|
||
|
|
+--- frontend/ # Frontend UI
|
||
|
|
| +--- streamlit_app.py
|
||
|
|
+--- utils/ # Utilities
|
||
|
|
| +--- logger.py # Logging
|
||
|
|
| +--- callback_handler.py
|
||
|
|
+--- tests/ # Unit tests
|
||
|
|
| +--- test_agents.py
|
||
|
|
+--- workspace/ # Working directory
|
||
|
|
+--- logs/ # Log directory
|
||
|
|
+--- autogen_sdls_system.py # Main entry
|
||
|
|
+--- autogen_self_healing_demo.py # Self-healing demo
|
||
|
|
+--- usage_examples.py # Usage examples
|
||
|
|
+--- requirements.txt # Dependencies
|
||
|
|
"""
|
||
|
|
print(structure)
|
||
|
|
|
||
|
|
|
||
|
|
def show_usage_guide():
|
||
|
|
"""展示使用指南"""
|
||
|
|
print("=" * 60)
|
||
|
|
print("Usage Guide")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
guide = """
|
||
|
|
[Method 1] Run full SDLC workflow:
|
||
|
|
python autogen_sdls_system.py
|
||
|
|
|
||
|
|
[Method 2] Start Streamlit frontend:
|
||
|
|
streamlit run frontend/streamlit_app.py
|
||
|
|
|
||
|
|
[Method 3] Self-healing feature demo:
|
||
|
|
python autogen_self_healing_demo.py
|
||
|
|
|
||
|
|
[Method 4] View usage examples:
|
||
|
|
python usage_examples.py
|
||
|
|
|
||
|
|
[Method 5] Run unit tests:
|
||
|
|
pytest tests/test_agents.py -v
|
||
|
|
"""
|
||
|
|
print(guide)
|
||
|
|
|
||
|
|
|
||
|
|
def demo_basic_import():
|
||
|
|
"""演示基本导入"""
|
||
|
|
print("\n" + "=" * 60)
|
||
|
|
print("Testing basic functionality")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
try:
|
||
|
|
from config.llm_config import get_llm_config, PM_PROMPT, QA_PROMPT
|
||
|
|
print("[OK] Configuration module imported")
|
||
|
|
|
||
|
|
# 测试配置生成
|
||
|
|
config = get_llm_config(model="qwen3.5-flash", api_key="test")
|
||
|
|
print(f"[OK] LLM config generated: {config['config_list'][0]['model']}")
|
||
|
|
|
||
|
|
# 测试提示词
|
||
|
|
print(f"[OK] PM prompt length: {len(PM_PROMPT)} chars")
|
||
|
|
print(f"[OK] QA prompt length: {len(QA_PROMPT)} chars")
|
||
|
|
|
||
|
|
return True
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"[ERROR] Import failed: {e}")
|
||
|
|
return False
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
"""主函数"""
|
||
|
|
print("\n")
|
||
|
|
print("=" * 60)
|
||
|
|
print(" " * 15 + "AutoGen SDLC System")
|
||
|
|
print(" " * 10 + "Powered by AutoGen + Qwen3.5-flash")
|
||
|
|
print("=" * 60)
|
||
|
|
print()
|
||
|
|
|
||
|
|
# 检查环境
|
||
|
|
env_ok = check_installation()
|
||
|
|
api_ok = check_api_key()
|
||
|
|
|
||
|
|
# 展示项目结构
|
||
|
|
show_project_structure()
|
||
|
|
|
||
|
|
# 展示使用指南
|
||
|
|
show_usage_guide()
|
||
|
|
|
||
|
|
# 测试基本功能
|
||
|
|
if env_ok:
|
||
|
|
demo_ok = demo_basic_import()
|
||
|
|
if demo_ok:
|
||
|
|
print("\nSystem initialization completed!")
|
||
|
|
print("\nNext steps:")
|
||
|
|
print(" 1. Get API Key from Alibaba Cloud DashScope console")
|
||
|
|
print(" 2. Set env var: export DASHSCOPE_API_KEY='your_key'")
|
||
|
|
print(" 3. Run: python autogen_sdls_system.py")
|
||
|
|
|
||
|
|
print("\n" + "=" * 60)
|
||
|
|
print("For details, see: README.md")
|
||
|
|
print("=" * 60)
|
||
|
|
print()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|