MCPcopy Create free account
hub / github.com/THESIS-AGENT/AIRouter / check_source_availability

Function check_source_availability

test_performance.py:265–294  ·  view source on GitHub ↗

检查各源的可用性

()

Source from the content-addressed store, hash-verified

263 print(f"❌ 获取统计信息异常: {str(e)}")
264
265def check_source_availability():
266 """检查各源的可用性"""
267 print("\n🔍 检查源可用性")
268 test_sources = get_available_sources()
269
270 if not test_sources:
271 print("❌ 无法获取源列表")
272 return
273
274 print(f"检查 {len(test_sources)} 个源...")
275
276 for source in test_sources:
277 try:
278 start_time = time.time()
279 response = requests.post(
280 f"{API_KEY_MANAGER_URL}/get_apikey",
281 json={"source_name": source},
282 timeout=5
283 )
284 end_time = time.time()
285 response_time = (end_time - start_time) * 1000 # 转换为毫秒
286
287 if response.status_code == 200:
288 print(f" ✅ {source}: 可用 ({response_time:.1f}ms)")
289 elif response.status_code == 404:
290 print(f" ❌ {source}: 未找到源 ({response_time:.1f}ms)")
291 else:
292 print(f" ⚠️ {source}: HTTP {response.status_code} ({response_time:.1f}ms)")
293 except Exception as e:
294 print(f" 💥 {source}: 异常 - {str(e)}")
295
296if __name__ == "__main__":
297 print("🧪 API密钥管理器性能测试工具")

Callers 1

Calls 1

get_available_sourcesFunction · 0.70

Tested by

no test coverage detected