Initial commit: skills library
- 70 skills with code and documentation - Add .gitignore (ignore __pycache__, output/, temp/, venv/) - Clean up test intermediates and caches
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for agent-vision-awareness skill
|
||||
|
||||
This script tests the vision detection and processing capabilities.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_detection():
|
||||
"""Test visual content detection."""
|
||||
print("Testing visual content detection...")
|
||||
|
||||
from .vision_detector import VisionContentDetector, DetectionConfidence
|
||||
|
||||
detector = VisionContentDetector()
|
||||
|
||||
test_cases = [
|
||||
("帮我分析这个截图 error.png", DetectionConfidence.HIGH),
|
||||
("描述这张图片的内容", DetectionConfidence.LOW),
|
||||
("根据架构图 design/architecture.png 生成部署方案", DetectionConfidence.HIGH),
|
||||
("写一个 Python 脚本", DetectionConfidence.NONE),
|
||||
(" 显示什么?", DetectionConfidence.HIGH),
|
||||
]
|
||||
|
||||
for test_input, expected_confidence in test_cases:
|
||||
confidence, items = detector.detect_visual_content(test_input)
|
||||
status = "✅" if confidence == expected_confidence else "❌"
|
||||
print(f"{status} Input: {test_input}")
|
||||
print(f" Expected: {expected_confidence.value}, Got: {confidence.value}")
|
||||
if items:
|
||||
print(f" Detected: {items}")
|
||||
print()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def test_integration():
|
||||
"""Test integration with vision analyzer (if API key available)."""
|
||||
print("Testing vision integration...")
|
||||
|
||||
# Check if API key is available
|
||||
api_key = os.environ.get("VOLCENGINE_API_KEY") or os.environ.get(
|
||||
"DASHSCOPE_API_KEY"
|
||||
)
|
||||
if not api_key:
|
||||
print("⚠️ No API key found. Skipping integration test.")
|
||||
print(
|
||||
" Set VOLCENGINE_API_KEY or DASHSCOPE_API_KEY environment variable to test."
|
||||
)
|
||||
return False
|
||||
|
||||
try:
|
||||
from .integrate_vision import process_user_input
|
||||
|
||||
# Test with a simple request (won't actually process image without file)
|
||||
result = process_user_input(
|
||||
"测试视觉处理",
|
||||
"这是一个测试",
|
||||
config={
|
||||
"api_key": api_key,
|
||||
"base_url": "https://ark.cn-beijing.volces.com/api/coding/v3",
|
||||
"model": "doubao-seed-code",
|
||||
},
|
||||
)
|
||||
|
||||
if result["status"] == "success":
|
||||
print("✅ Integration test passed (configuration valid)")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Integration test failed: {result.get('error', 'Unknown error')}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Integration test failed: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
"""Run all tests."""
|
||||
print("🧪 Testing Agent Vision Awareness Skill")
|
||||
print("=" * 50)
|
||||
|
||||
success = True
|
||||
|
||||
# Test detection
|
||||
success &= test_detection()
|
||||
|
||||
# Test integration (if possible)
|
||||
success &= test_integration()
|
||||
|
||||
print("=" * 50)
|
||||
if success:
|
||||
print("✅ All tests passed!")
|
||||
else:
|
||||
print("⚠️ Some tests failed or were skipped.")
|
||||
|
||||
return success
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user