Spaces:
Building
Building
Update admin_routes.py
Browse files- admin_routes.py +116 -7
admin_routes.py
CHANGED
@@ -273,13 +273,122 @@ async def get_environment(username: str = Depends(verify_token)):
|
|
273 |
cfg = ConfigProvider.get()
|
274 |
env_config = cfg.global_config
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
"
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
|
284 |
@router.put("/environment")
|
285 |
async def update_environment(
|
|
|
273 |
cfg = ConfigProvider.get()
|
274 |
env_config = cfg.global_config
|
275 |
|
276 |
+
# Provider tabanlı yeni yapıyı destekle
|
277 |
+
response = {}
|
278 |
+
|
279 |
+
# LLM Provider - eski yapıdan dönüştür
|
280 |
+
if hasattr(env_config, 'llm_provider'):
|
281 |
+
response["llm_provider"] = env_config.llm_provider.model_dump()
|
282 |
+
else:
|
283 |
+
# Eski yapıdan provider bilgisini oluştur
|
284 |
+
response["llm_provider"] = {
|
285 |
+
"name": env_config.work_mode if env_config.work_mode in ["gpt4o", "gpt4o-mini"] else "spark_cloud",
|
286 |
+
"api_key": env_config.cloud_token or "",
|
287 |
+
"endpoint": str(env_config.spark_endpoint),
|
288 |
+
"settings": {
|
289 |
+
"internal_prompt": getattr(env_config, 'internal_prompt', None)
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
# TTS Provider - eski yapıdan dönüştür
|
294 |
+
if hasattr(env_config, 'tts_provider'):
|
295 |
+
response["tts_provider"] = env_config.tts_provider.model_dump()
|
296 |
+
else:
|
297 |
+
response["tts_provider"] = {
|
298 |
+
"name": getattr(env_config, 'tts_engine', 'no_tts'),
|
299 |
+
"api_key": getattr(env_config, 'tts_engine_api_key', None) or "",
|
300 |
+
"endpoint": None,
|
301 |
+
"settings": getattr(env_config, 'tts_settings', {})
|
302 |
+
}
|
303 |
+
|
304 |
+
# STT Provider - eski yapıdan dönüştür
|
305 |
+
if hasattr(env_config, 'stt_provider'):
|
306 |
+
response["stt_provider"] = env_config.stt_provider.model_dump()
|
307 |
+
else:
|
308 |
+
response["stt_provider"] = {
|
309 |
+
"name": getattr(env_config, 'stt_engine', 'no_stt'),
|
310 |
+
"api_key": getattr(env_config, 'stt_engine_api_key', None) or "",
|
311 |
+
"endpoint": None,
|
312 |
+
"settings": getattr(env_config, 'stt_settings', {})
|
313 |
+
}
|
314 |
+
|
315 |
+
# Provider listesi
|
316 |
+
if hasattr(env_config, 'providers'):
|
317 |
+
response["providers"] = [p.model_dump() for p in env_config.providers]
|
318 |
+
else:
|
319 |
+
# Varsayılan provider listesi
|
320 |
+
response["providers"] = [
|
321 |
+
{
|
322 |
+
"type": "llm",
|
323 |
+
"name": "spark_cloud",
|
324 |
+
"display_name": "Spark LLM (Cloud)",
|
325 |
+
"requires_endpoint": True,
|
326 |
+
"requires_api_key": True,
|
327 |
+
"requires_repo_info": False
|
328 |
+
},
|
329 |
+
{
|
330 |
+
"type": "llm",
|
331 |
+
"name": "gpt4o",
|
332 |
+
"display_name": "GPT-4o",
|
333 |
+
"requires_endpoint": True,
|
334 |
+
"requires_api_key": True,
|
335 |
+
"requires_repo_info": False
|
336 |
+
},
|
337 |
+
{
|
338 |
+
"type": "llm",
|
339 |
+
"name": "gpt4o-mini",
|
340 |
+
"display_name": "GPT-4o Mini",
|
341 |
+
"requires_endpoint": True,
|
342 |
+
"requires_api_key": True,
|
343 |
+
"requires_repo_info": False
|
344 |
+
},
|
345 |
+
{
|
346 |
+
"type": "tts",
|
347 |
+
"name": "no_tts",
|
348 |
+
"display_name": "No TTS",
|
349 |
+
"requires_endpoint": False,
|
350 |
+
"requires_api_key": False,
|
351 |
+
"requires_repo_info": False
|
352 |
+
},
|
353 |
+
{
|
354 |
+
"type": "tts",
|
355 |
+
"name": "elevenlabs",
|
356 |
+
"display_name": "ElevenLabs",
|
357 |
+
"requires_endpoint": False,
|
358 |
+
"requires_api_key": True,
|
359 |
+
"requires_repo_info": False
|
360 |
+
},
|
361 |
+
{
|
362 |
+
"type": "stt",
|
363 |
+
"name": "no_stt",
|
364 |
+
"display_name": "No STT",
|
365 |
+
"requires_endpoint": False,
|
366 |
+
"requires_api_key": False,
|
367 |
+
"requires_repo_info": False
|
368 |
+
},
|
369 |
+
{
|
370 |
+
"type": "stt",
|
371 |
+
"name": "google",
|
372 |
+
"display_name": "Google Cloud STT",
|
373 |
+
"requires_endpoint": False,
|
374 |
+
"requires_api_key": True,
|
375 |
+
"requires_repo_info": False
|
376 |
+
}
|
377 |
+
]
|
378 |
+
|
379 |
+
# Parameter collection config
|
380 |
+
if hasattr(env_config, 'parameter_collection_config'):
|
381 |
+
response["parameter_collection_config"] = env_config.parameter_collection_config.model_dump()
|
382 |
+
else:
|
383 |
+
# Varsayılan değerler
|
384 |
+
response["parameter_collection_config"] = {
|
385 |
+
"max_params_per_question": 2,
|
386 |
+
"retry_unanswered": True,
|
387 |
+
"smart_grouping": True,
|
388 |
+
"collection_prompt": "You are a helpful assistant collecting information from the user..."
|
389 |
+
}
|
390 |
+
|
391 |
+
return response
|
392 |
|
393 |
@router.put("/environment")
|
394 |
async def update_environment(
|