Spaces:
Building
Building
Update admin_routes.py
Browse files- admin_routes.py +62 -37
admin_routes.py
CHANGED
@@ -403,50 +403,75 @@ async def get_project(
|
|
403 |
log(f"Failed to get project: {e}")
|
404 |
raise HTTPException(status_code=500, detail=str(e))
|
405 |
|
|
|
406 |
@router.post("/projects")
|
407 |
async def create_project(
|
408 |
-
project_data:
|
409 |
-
username: str = Depends(verify_token)
|
410 |
):
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
"deleted": False,
|
427 |
-
"
|
428 |
-
"
|
429 |
-
|
430 |
-
|
431 |
-
"test_users": project_data.get("test_users", []),
|
432 |
-
"versions": [],
|
433 |
-
"last_update_date": datetime.utcnow().isoformat()
|
434 |
-
}
|
435 |
-
|
436 |
-
config.setdefault("projects", []).append(new_project)
|
437 |
-
save_config(config)
|
438 |
|
439 |
-
|
440 |
-
|
441 |
-
"project", new_id, new_project["name"])
|
442 |
-
save_config(config)
|
443 |
|
444 |
-
|
445 |
-
|
|
|
446 |
|
447 |
-
|
448 |
-
log(f"Failed to create project: {e}")
|
449 |
-
raise HTTPException(status_code=500, detail=str(e))
|
450 |
|
451 |
@router.put("/projects/{project_id}")
|
452 |
async def update_project(
|
|
|
403 |
log(f"Failed to get project: {e}")
|
404 |
raise HTTPException(status_code=500, detail=str(e))
|
405 |
|
406 |
+
# POST /api/projects
|
407 |
@router.post("/projects")
|
408 |
async def create_project(
|
409 |
+
project_data: ProjectCreate,
|
410 |
+
username: str = Depends(verify_token)
|
411 |
):
|
412 |
+
cfg = load_config()
|
413 |
+
|
414 |
+
# 1️⃣ Yeni proje ID’si
|
415 |
+
project_id = cfg["config"].get("project_id_counter", 0) + 1
|
416 |
+
cfg["config"]["project_id_counter"] = project_id
|
417 |
+
|
418 |
+
# 2️⃣ Proje gövdesi
|
419 |
+
new_project = {
|
420 |
+
"id": project_id,
|
421 |
+
"name": project_data.name,
|
422 |
+
"caption": project_data.caption,
|
423 |
+
"icon": project_data.icon or "folder",
|
424 |
+
"description": project_data.description or "",
|
425 |
+
"enabled": False,
|
426 |
+
"deleted": False,
|
427 |
+
"created_date": datetime.utcnow().isoformat(),
|
428 |
+
"created_by": username,
|
429 |
+
"last_update_date": datetime.utcnow().isoformat(),
|
430 |
+
"last_update_user": username,
|
431 |
+
|
432 |
+
# *** Versiyon sayaçları ***
|
433 |
+
"version_id_counter": 1,
|
434 |
+
|
435 |
+
# *** İlk versiyon (no = 1) ***
|
436 |
+
"versions": [{
|
437 |
+
"id": 1,
|
438 |
+
"no": 1,
|
439 |
+
"caption": "Version 1",
|
440 |
+
"description": "Initial version",
|
441 |
+
"published": False,
|
442 |
+
"default_api": "",
|
443 |
+
"llm": {
|
444 |
+
"repo_id": "",
|
445 |
+
"generation_config": {
|
446 |
+
"max_new_tokens": 512,
|
447 |
+
"temperature": 0.7,
|
448 |
+
"top_p": 0.95,
|
449 |
+
"top_k": 50,
|
450 |
+
"repetition_penalty": 1.1
|
451 |
+
},
|
452 |
+
"use_fine_tune": False,
|
453 |
+
"fine_tune_zip": ""
|
454 |
+
},
|
455 |
+
"intents": [],
|
456 |
+
"parameters": [],
|
457 |
+
"created_date": datetime.utcnow().isoformat(),
|
458 |
+
"created_by": username,
|
459 |
+
"last_update_date": datetime.utcnow().isoformat(),
|
460 |
+
"last_update_user": username,
|
461 |
"deleted": False,
|
462 |
+
"publish_date": None,
|
463 |
+
"published_by": None
|
464 |
+
}]
|
465 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
|
467 |
+
cfg.setdefault("projects", []).append(new_project)
|
468 |
+
save_config(cfg)
|
|
|
|
|
469 |
|
470 |
+
add_activity_log(cfg, username, "CREATE_PROJECT",
|
471 |
+
"project", project_id, new_project["name"])
|
472 |
+
save_config(cfg)
|
473 |
|
474 |
+
return new_project # 201 CREATED
|
|
|
|
|
475 |
|
476 |
@router.put("/projects/{project_id}")
|
477 |
async def update_project(
|