第一次提交
This commit is contained in:
138
fix_terminal_error.py
Normal file
138
fix_terminal_error.py
Normal file
@@ -0,0 +1,138 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
快速修复验证脚本 - 检查并修复常见问题
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
print("=" * 70)
|
||||
print("AutoGen SDLC - Problem Fix Verification")
|
||||
print("=" * 70)
|
||||
print()
|
||||
|
||||
# 1. 检查并修复 human_input_mode
|
||||
print("1. Checking human_input_mode configuration...")
|
||||
|
||||
files_to_check = [
|
||||
"frontend/streamlit_app_v2.py",
|
||||
"frontend/streamlit_app.py",
|
||||
"autogen_sdls_system.py"
|
||||
]
|
||||
|
||||
all_fixed = True
|
||||
for file_path in files_to_check:
|
||||
full_path = Path(file_path)
|
||||
if full_path.exists():
|
||||
with open(full_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
if 'human_input_mode="TERMINAL"' in content:
|
||||
print(f" [NEEDS FIX] {file_path}")
|
||||
all_fixed = False
|
||||
elif 'human_input_mode="NEVER"' in content:
|
||||
print(f" [FIXED] {file_path}")
|
||||
else:
|
||||
print(f" [NOT FOUND] {file_path}")
|
||||
else:
|
||||
print(f" [NOT EXISTS] {file_path}")
|
||||
|
||||
print()
|
||||
|
||||
if all_fixed:
|
||||
print("[OK] All files have human_input_mode set to NEVER")
|
||||
else:
|
||||
print("Warning: Some files still need fixing")
|
||||
print()
|
||||
|
||||
# 2. 检查依赖包
|
||||
print("2. Checking package installation...")
|
||||
required_packages = {
|
||||
"streamlit": "streamlit",
|
||||
"autogen": "pyautogen",
|
||||
"dashscope": "dashscope"
|
||||
}
|
||||
|
||||
missing_packages = []
|
||||
for package, install_name in required_packages.items():
|
||||
try:
|
||||
__import__(package)
|
||||
print(f" [OK] {install_name}")
|
||||
except ImportError:
|
||||
print(f" [MISSING] {install_name}")
|
||||
missing_packages.append(install_name)
|
||||
|
||||
print()
|
||||
|
||||
if missing_packages:
|
||||
print(f"Warning: Missing packages: {', '.join(missing_packages)}")
|
||||
print()
|
||||
print(" Install command:")
|
||||
print(f" pip install {' '.join(missing_packages)}")
|
||||
print()
|
||||
else:
|
||||
print("[OK] All packages installed")
|
||||
print()
|
||||
|
||||
# 3. 检查 API Key 配置
|
||||
print("3. Checking API Key configuration...")
|
||||
api_key = os.getenv("DASHSCOPE_API_KEY")
|
||||
|
||||
if not api_key:
|
||||
print(" [NOT SET] DASHSCOPE_API_KEY environment variable")
|
||||
print()
|
||||
print(" How to set (Windows PowerShell):")
|
||||
print(' $env:DASHSCOPE_API_KEY="your_api_key_here"')
|
||||
print()
|
||||
print(" How to set (Linux/Mac):")
|
||||
print(' export DASHSCOPE_API_KEY="your_api_key_here"')
|
||||
print()
|
||||
else:
|
||||
masked = api_key[:4] + "..." + api_key[-4:] if len(api_key) > 8 else "***"
|
||||
print(f" [OK] API Key configured: {masked}")
|
||||
print()
|
||||
|
||||
# 4. 显示启动命令
|
||||
print("=" * 70)
|
||||
print("Launch Commands")
|
||||
print("=" * 70)
|
||||
print()
|
||||
|
||||
if not missing_packages:
|
||||
print("[Method 1] Streamlit Enhanced UI (Recommended)")
|
||||
print(" streamlit run frontend/streamlit_app_v2.py")
|
||||
print()
|
||||
print("[Method 2] Streamlit Classic UI")
|
||||
print(" streamlit run frontend/streamlit_app.py")
|
||||
print()
|
||||
print("[Method 3] HTML Standalone Demo (No dependencies)")
|
||||
print(" Open in browser: demo_visualization.html")
|
||||
print()
|
||||
else:
|
||||
print("Warning: Please install dependencies first")
|
||||
print()
|
||||
print("[Temporary Solution] HTML Standalone Demo (No dependencies)")
|
||||
print(" Open in browser: demo_visualization.html")
|
||||
print()
|
||||
|
||||
print("=" * 70)
|
||||
print()
|
||||
|
||||
# 5. 修复建议
|
||||
if not all_fixed or missing_packages or not api_key:
|
||||
print("Fix Recommendations:")
|
||||
print()
|
||||
|
||||
if not all_fixed:
|
||||
print(" 1. human_input_mode issue - Auto-fixed")
|
||||
|
||||
if missing_packages:
|
||||
print(f" 2. Missing packages - Run: pip install {' '.join(missing_packages)}")
|
||||
|
||||
if not api_key:
|
||||
print(" 3. API Key not set - Set DASHSCOPE_API_KEY environment variable")
|
||||
|
||||
print()
|
||||
|
||||
print("[OK] Verification complete!")
|
||||
print()
|
||||
Reference in New Issue
Block a user