Files

1 line
1.7 KiB
JSON

{"repo": "buptlg/appdevelop", "files": {"backend/verify_siliconflow_key.py": {"99389f7fddf74a32149dbf13c25c617f1ea6b3af": {"t": 1785674131.1620636, "n": 1404, "h": "ffd4808afb43e1a7", "c": "import os\nimport sys\n\n# Add current directory to sys.path to ensure app package can be imported\nsys.path.append(os.getcwd())\n\n# Set the API key provided by the user\nos.environ[\"SILICONFLOW_API_KEY\"] = \"sk-uufbxievkcqvebkvvhunbjoehanuyjpqohhycxssxgkxielc\"\n\ntry:\n from app.services.analyzer import analyzer_service\nexcept ImportError as e:\n print(f\"Error importing analyzer_service: {e}\")\n sys.exit(1)\n\n# Path to a test image\ntest_image_path = os.path.join(\"uploads\", \"r_9c6433cd.jpg\")\n\nif not os.path.exists(test_image_path):\n print(f\"Test image not found at {test_image_path}\")\n # Try absolute path\n test_image_path = os.path.abspath(os.path.join(os.path.dirname(__file__), \"uploads\", \"r_9c6433cd.jpg\"))\n if not os.path.exists(test_image_path):\n print(f\"Test image still not found at {test_image_path}\")\n sys.exit(1)\n\nprint(f\"Testing Silicon Flow API with key: {os.environ['SILICONFLOW_API_KEY'][:5]}...***\")\nprint(f\"Analyzing image: {test_image_path}\")\n\ntry:\n result = analyzer_service.analyze_image(test_image_path, scene=\"campus\")\n print(\"\\nAnalysis Result:\")\n print(result)\n \n if result.get(\"overall_risk\") in [\"低\", \"中\", \"高\"]:\n print(\"\\nSUCCESS: API call returned a valid risk level.\")\n else:\n print(\"\\nFAILURE: API call did not return a valid risk level.\")\n \nexcept Exception as e:\n print(f\"\\nError during analysis: {e}\")\n"}}}}