fix
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -72,10 +72,10 @@ async def delete_asset(
|
|||||||
async def get_assets(request: Request, dao: DAO = Depends(get_dao), type: Optional[str] = None, limit: int = 10, offset: int = 0, current_user: dict = Depends(get_current_user), project_id: Optional[str] = Depends(get_project_id)) -> AssetsResponse:
|
async def get_assets(request: Request, dao: DAO = Depends(get_dao), type: Optional[str] = None, limit: int = 10, offset: int = 0, current_user: dict = Depends(get_current_user), project_id: Optional[str] = Depends(get_project_id)) -> AssetsResponse:
|
||||||
logger.info(f"get_assets called. Limit: {limit}, Offset: {offset}")
|
logger.info(f"get_assets called. Limit: {limit}, Offset: {offset}")
|
||||||
|
|
||||||
user_id_filter = str(current_user["_id"])
|
user_id_filter = current_user["id"]
|
||||||
if project_id:
|
if project_id:
|
||||||
project = await dao.projects.get_project(project_id)
|
project = await dao.projects.get_project(project_id)
|
||||||
if not project or str(current_user["_id"]) not in project.members:
|
if not project or str(current_user["id"]) not in project.members:
|
||||||
raise HTTPException(status_code=403, detail="Project access denied")
|
raise HTTPException(status_code=403, detail="Project access denied")
|
||||||
user_id_filter = None
|
user_id_filter = None
|
||||||
|
|
||||||
|
|||||||
@@ -90,22 +90,24 @@ async def get_character_by_id(character_id: str, request: Request, dao: DAO = De
|
|||||||
@router.post("/", response_model=Character)
|
@router.post("/", response_model=Character)
|
||||||
async def create_character(
|
async def create_character(
|
||||||
char_req: CharacterCreateRequest,
|
char_req: CharacterCreateRequest,
|
||||||
|
project_id: Optional[str] = Depends(get_project_id),
|
||||||
dao: DAO = Depends(get_dao),
|
dao: DAO = Depends(get_dao),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
) -> Character:
|
) -> Character:
|
||||||
logger.info("create_character called")
|
logger.info("create_character called")
|
||||||
|
char_req.project_id = project_id
|
||||||
char_data = char_req.model_dump()
|
char_data = char_req.model_dump()
|
||||||
char_data["created_by"] = str(current_user["_id"])
|
char_data["created_by"] = str(current_user["_id"])
|
||||||
if "id" not in char_data:
|
if "id" not in char_data:
|
||||||
char_data["id"] = None
|
char_data["id"] = None
|
||||||
|
|
||||||
if char_req.project_id:
|
if project_id:
|
||||||
project = await dao.projects.get_project(char_req.project_id)
|
project = await dao.projects.get_project(project_id)
|
||||||
if not project or str(current_user["_id"]) not in project.members:
|
if not project or str(current_user["_id"]) not in project.members:
|
||||||
raise HTTPException(status_code=403, detail="Project access denied")
|
raise HTTPException(status_code=403, detail="Project access denied")
|
||||||
|
|
||||||
new_char = Character(**char_data)
|
new_char = Character(**char_data)
|
||||||
|
new_char.avatar_asset_id = new_char.avatar_image.split("/")[-1]
|
||||||
created_char = await dao.chars.add_character(new_char)
|
created_char = await dao.chars.add_character(new_char)
|
||||||
return created_char
|
return created_char
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -169,11 +169,13 @@ class GenerationService:
|
|||||||
- Focus on lighting, texture, and composition.
|
- Focus on lighting, texture, and composition.
|
||||||
"""
|
"""
|
||||||
if generation.linked_character_id is not None:
|
if generation.linked_character_id is not None:
|
||||||
char_info = await self.dao.chars.get_character(generation.linked_character_id, with_image_data=True)
|
char_info = await self.dao.chars.get_character(generation.linked_character_id)
|
||||||
if char_info is None:
|
if char_info is None:
|
||||||
raise Exception(f"Character ID {generation.linked_character_id} not found")
|
raise Exception(f"Character ID {generation.linked_character_id} not found")
|
||||||
if generation.use_profile_image:
|
if generation.use_profile_image:
|
||||||
media_group_bytes.append(char_info.character_image_data)
|
avatar_asset = await self.dao.assets.get_asset(char_info.avatar_asset_id)
|
||||||
|
if avatar_asset:
|
||||||
|
media_group_bytes.append(avatar_asset.data)
|
||||||
# generation_prompt = generation_prompt.replace("$char_bio_inserted", f"1. CHARACTER BIO (Must be strictly followed): {char_info.character_bio}")
|
# generation_prompt = generation_prompt.replace("$char_bio_inserted", f"1. CHARACTER BIO (Must be strictly followed): {char_info.character_bio}")
|
||||||
|
|
||||||
reference_assets = await self.dao.assets.get_assets_by_ids(generation.assets_list)
|
reference_assets = await self.dao.assets.get_assets_by_ids(generation.assets_list)
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -143,10 +143,10 @@ async def lifespan(app: FastAPI):
|
|||||||
# 2. ЗАПУСК БОТА (в фоне)
|
# 2. ЗАПУСК БОТА (в фоне)
|
||||||
# Важно: handle_signals=False, чтобы бот не перехватывал сигналы остановки у uvicorn
|
# Важно: handle_signals=False, чтобы бот не перехватывал сигналы остановки у uvicorn
|
||||||
# Мы НЕ передаем сюда dao=..., так как он уже подключен через Middleware выше
|
# Мы НЕ передаем сюда dao=..., так как он уже подключен через Middleware выше
|
||||||
polling_task = asyncio.create_task(
|
# polling_task = asyncio.create_task(
|
||||||
dp.start_polling(bot, handle_signals=False)
|
# dp.start_polling(bot, handle_signals=False)
|
||||||
)
|
# )
|
||||||
print("🤖 Bot polling started")
|
# print("🤖 Bot polling started")
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from pydantic_core.core_schema import computed_field
|
|||||||
class Character(BaseModel):
|
class Character(BaseModel):
|
||||||
id: Optional[str] = None
|
id: Optional[str] = None
|
||||||
name: str
|
name: str
|
||||||
|
avatar_asset_id: Optional[str] = None
|
||||||
avatar_image: Optional[str] = None
|
avatar_image: Optional[str] = None
|
||||||
character_image_data: Optional[bytes] = None
|
character_image_data: Optional[bytes] = None
|
||||||
character_image_doc_tg_id: Optional[str] = None
|
character_image_doc_tg_id: Optional[str] = None
|
||||||
@@ -14,4 +15,3 @@ class Character(BaseModel):
|
|||||||
character_bio: Optional[str] = None
|
character_bio: Optional[str] = None
|
||||||
created_by: Optional[str] = None
|
created_by: Optional[str] = None
|
||||||
project_id: Optional[str] = None
|
project_id: Optional[str] = None
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -70,7 +70,10 @@ class AssetsRepo:
|
|||||||
# if not with_data: args["data"] = 0; args["thumbnail"] = 0
|
# if not with_data: args["data"] = 0; args["thumbnail"] = 0
|
||||||
# So list DOES NOT return thumbnails by default.
|
# So list DOES NOT return thumbnails by default.
|
||||||
args["thumbnail"] = 0
|
args["thumbnail"] = 0
|
||||||
|
if created_by:
|
||||||
|
filter["created_by"] = created_by
|
||||||
|
filter['project_id'] = None
|
||||||
|
|
||||||
if project_id:
|
if project_id:
|
||||||
filter["project_id"] = project_id
|
filter["project_id"] = project_id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user