MCPcopy
hub / github.com/sligter/LandPPT / test_image_service

Function test_image_service

src/landppt/api/image_api.py:183–296  ·  view source on GitHub ↗

测试图片服务

(
    user: User = Depends(get_current_user_required)
)

Source from the content-addressed store, hash-verified

181
182@router.post("/api/image/test")
183async def test_image_service(
184 user: User = Depends(get_current_user_required)
185):
186 """测试图片服务"""
187 try:
188 image_service = get_image_service()
189 image_config = get_image_config()
190 config = image_config.get_config()
191
192 test_results = {
193 "providers": {},
194 "cache_info": {}
195 }
196
197 # 测试DALL-E
198 if config.get('dalle', {}).get('api_key'):
199 try:
200 # 这里可以添加实际的DALL-E测试逻辑
201 test_results["providers"]["dalle"] = {
202 "available": True,
203 "message": "DALL-E API密钥已配置"
204 }
205 except Exception as e:
206 test_results["providers"]["dalle"] = {
207 "available": False,
208 "message": f"DALL-E测试失败: {str(e)}"
209 }
210 else:
211 test_results["providers"]["dalle"] = {
212 "available": False,
213 "message": "DALL-E API密钥未配置"
214 }
215
216 # 测试Stable Diffusion
217 if config.get('stable_diffusion', {}).get('api_key'):
218 try:
219 test_results["providers"]["stable_diffusion"] = {
220 "available": True,
221 "message": "Stable Diffusion API密钥已配置"
222 }
223 except Exception as e:
224 test_results["providers"]["stable_diffusion"] = {
225 "available": False,
226 "message": f"Stable Diffusion测试失败: {str(e)}"
227 }
228 else:
229 test_results["providers"]["stable_diffusion"] = {
230 "available": False,
231 "message": "Stable Diffusion API密钥未配置"
232 }
233
234 # 测试SiliconFlow
235 if config.get('siliconflow', {}).get('api_key'):
236 try:
237 test_results["providers"]["siliconflow"] = {
238 "available": True,
239 "message": "SiliconFlow API密钥已配置"
240 }

Callers

nothing calls this directly

Calls 6

get_image_serviceFunction · 0.85
get_image_configFunction · 0.85
PathFunction · 0.85
errorMethod · 0.80
get_configMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected