Compare commits
1 Commits
codex/expo
...
codex/defi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
761740de12 |
@@ -26,6 +26,7 @@ from services.database import get_db
|
|||||||
from middleware.auth_middleware import get_current_user, get_current_user_with_query_token
|
from middleware.auth_middleware import get_current_user, get_current_user_with_query_token
|
||||||
from api.story_writer.utils.auth import require_authenticated_user
|
from api.story_writer.utils.auth import require_authenticated_user
|
||||||
from utils.asset_tracker import save_asset_to_library
|
from utils.asset_tracker import save_asset_to_library
|
||||||
|
from models.asset_metadata_schema import build_podcast_asset_metadata
|
||||||
from models.story_models import StoryAudioResult
|
from models.story_models import StoryAudioResult
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from ..constants import get_podcast_audio_service, get_podcast_media_dir
|
from ..constants import get_podcast_audio_service, get_podcast_media_dir
|
||||||
@@ -217,11 +218,11 @@ async def upload_podcast_audio(
|
|||||||
title=f"Uploaded Audio - {project_id}",
|
title=f"Uploaded Audio - {project_id}",
|
||||||
description="Uploaded podcast audio/voice sample",
|
description="Uploaded podcast audio/voice sample",
|
||||||
tags=["podcast", "audio", "upload", project_id],
|
tags=["podcast", "audio", "upload", project_id],
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"project_id": project_id,
|
asset_role="uploaded_audio",
|
||||||
"type": "uploaded_audio",
|
project_id=project_id,
|
||||||
"status": "completed",
|
origin="podcast.audio.upload",
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save audio asset: {e}")
|
logger.warning(f"[Podcast] Failed to save audio asset: {e}")
|
||||||
@@ -455,11 +456,12 @@ async def generate_podcast_audio(
|
|||||||
provider=result.get("provider"),
|
provider=result.get("provider"),
|
||||||
model=result.get("model"),
|
model=result.get("model"),
|
||||||
cost=result.get("cost"),
|
cost=result.get("cost"),
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"scene_id": request.scene_id,
|
asset_role="podcast_audio",
|
||||||
"scene_title": request.scene_title,
|
project_id=request.project_id,
|
||||||
"status": "completed",
|
origin="podcast.audio.generate",
|
||||||
},
|
extras={"scene_id": request.scene_id, "scene_title": request.scene_title},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save audio asset: {e}")
|
logger.warning(f"[Podcast] Failed to save audio asset: {e}")
|
||||||
@@ -621,13 +623,12 @@ async def combine_podcast_audio(
|
|||||||
title=f"Combined Podcast - {request.project_id}",
|
title=f"Combined Podcast - {request.project_id}",
|
||||||
description=f"Combined podcast audio from {len(request.scene_ids)} scenes",
|
description=f"Combined podcast audio from {len(request.scene_ids)} scenes",
|
||||||
tags=["podcast", "audio", "combined", request.project_id],
|
tags=["podcast", "audio", "combined", request.project_id],
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"project_id": request.project_id,
|
asset_role="combined_podcast_audio",
|
||||||
"scene_ids": request.scene_ids,
|
project_id=request.project_id,
|
||||||
"scene_count": len(request.scene_ids),
|
origin="podcast.audio.combine",
|
||||||
"total_duration": total_duration,
|
extras={"scene_ids": request.scene_ids, "scene_count": len(request.scene_ids), "total_duration": total_duration},
|
||||||
"status": "completed",
|
),
|
||||||
},
|
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save combined audio asset: {e}")
|
logger.warning(f"[Podcast] Failed to save combined audio asset: {e}")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from api.story_writer.utils.auth import require_authenticated_user
|
|||||||
from services.llm_providers.main_image_generation import generate_image
|
from services.llm_providers.main_image_generation import generate_image
|
||||||
from services.llm_providers.main_image_editing import edit_image
|
from services.llm_providers.main_image_editing import edit_image
|
||||||
from utils.asset_tracker import save_asset_to_library
|
from utils.asset_tracker import save_asset_to_library
|
||||||
|
from models.asset_metadata_schema import build_podcast_asset_metadata
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from ..constants import get_podcast_media_dir, PODCAST_AVATARS_SUBDIR
|
from ..constants import get_podcast_media_dir, PODCAST_AVATARS_SUBDIR
|
||||||
from ..presenter_personas import choose_persona_id, get_persona
|
from ..presenter_personas import choose_persona_id, get_persona
|
||||||
@@ -111,11 +112,11 @@ async def upload_podcast_avatar(
|
|||||||
title=f"Podcast Presenter Avatar - {project_id}",
|
title=f"Podcast Presenter Avatar - {project_id}",
|
||||||
description="Podcast presenter avatar image",
|
description="Podcast presenter avatar image",
|
||||||
tags=["podcast", "avatar", project_id],
|
tags=["podcast", "avatar", project_id],
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"project_id": project_id,
|
asset_role="presenter_avatar",
|
||||||
"type": "presenter_avatar",
|
project_id=project_id,
|
||||||
"status": "completed",
|
origin="podcast.avatar.upload",
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save avatar asset (non-fatal): {e}")
|
logger.warning(f"[Podcast] Failed to save avatar asset (non-fatal): {e}")
|
||||||
@@ -223,12 +224,12 @@ async def make_avatar_presentable(
|
|||||||
tags=["podcast", "avatar", "presenter", "transformed", project_id],
|
tags=["podcast", "avatar", "presenter", "transformed", project_id],
|
||||||
provider=result.provider,
|
provider=result.provider,
|
||||||
model=result.model,
|
model=result.model,
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"project_id": project_id,
|
asset_role="transformed_presenter",
|
||||||
"type": "transformed_presenter",
|
project_id=project_id,
|
||||||
"original_avatar_url": avatar_url,
|
origin="podcast.avatar.make_presentable",
|
||||||
"status": "completed",
|
extras={"original_avatar_url": avatar_url},
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save transformed avatar asset: {e}")
|
logger.warning(f"[Podcast] Failed to save transformed avatar asset: {e}")
|
||||||
@@ -404,14 +405,12 @@ async def generate_podcast_presenters(
|
|||||||
tags=["podcast", "avatar", "presenter", project_id],
|
tags=["podcast", "avatar", "presenter", project_id],
|
||||||
provider=result.provider,
|
provider=result.provider,
|
||||||
model=result.model,
|
model=result.model,
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"project_id": project_id,
|
asset_role="generated_presenter",
|
||||||
"speaker_number": i + 1,
|
project_id=project_id,
|
||||||
"type": "generated_presenter",
|
origin="podcast.avatar.generate",
|
||||||
"status": "completed",
|
extras={"speaker_number": i + 1, "persona_id": selected_persona_id, "seed": seed},
|
||||||
"persona_id": selected_persona_id,
|
),
|
||||||
"seed": seed,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save presenter asset: {e}")
|
logger.warning(f"[Podcast] Failed to save presenter asset: {e}")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from middleware.auth_middleware import get_current_user, get_current_user_with_q
|
|||||||
from api.story_writer.utils.auth import require_authenticated_user
|
from api.story_writer.utils.auth import require_authenticated_user
|
||||||
from services.llm_providers.main_image_generation import generate_image, generate_character_image
|
from services.llm_providers.main_image_generation import generate_image, generate_character_image
|
||||||
from utils.asset_tracker import save_asset_to_library
|
from utils.asset_tracker import save_asset_to_library
|
||||||
|
from models.asset_metadata_schema import build_podcast_asset_metadata
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from ..constants import get_podcast_media_dir
|
from ..constants import get_podcast_media_dir
|
||||||
from ..models import PodcastImageRequest, PodcastImageResponse
|
from ..models import PodcastImageRequest, PodcastImageResponse
|
||||||
@@ -417,11 +418,12 @@ async def generate_podcast_scene_image(
|
|||||||
tags=["podcast", "scene", request.scene_id],
|
tags=["podcast", "scene", request.scene_id],
|
||||||
provider=result.provider,
|
provider=result.provider,
|
||||||
model=result.model,
|
model=result.model,
|
||||||
asset_metadata={
|
asset_metadata=build_podcast_asset_metadata(
|
||||||
"scene_id": request.scene_id,
|
asset_role="podcast_scene_image",
|
||||||
"scene_title": request.scene_title,
|
project_id=request.project_id,
|
||||||
"status": "completed",
|
origin="podcast.images.generate",
|
||||||
},
|
extras={"scene_id": request.scene_id, "scene_title": request.scene_title},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[Podcast] Failed to save image asset: {e}")
|
logger.warning(f"[Podcast] Failed to save image asset: {e}")
|
||||||
|
|||||||
76
backend/models/asset_metadata_schema.py
Normal file
76
backend/models/asset_metadata_schema.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
"""Shared schema/builders for content asset metadata."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any, Dict, Optional, Tuple
|
||||||
|
|
||||||
|
SCHEMA_VERSION = "1.0"
|
||||||
|
PODCAST_FEATURE = "podcast_maker"
|
||||||
|
|
||||||
|
REQUIRED_KEYS = (
|
||||||
|
"schema_version",
|
||||||
|
"feature",
|
||||||
|
"asset_role",
|
||||||
|
"project_id",
|
||||||
|
"status",
|
||||||
|
"origin",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def build_asset_metadata(
|
||||||
|
*,
|
||||||
|
feature: str,
|
||||||
|
asset_role: str,
|
||||||
|
project_id: Optional[str],
|
||||||
|
status: str,
|
||||||
|
origin: str,
|
||||||
|
extras: Optional[Dict[str, Any]] = None,
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
"""Build normalized, versioned asset metadata payload."""
|
||||||
|
metadata: Dict[str, Any] = {
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"feature": feature,
|
||||||
|
"asset_role": asset_role,
|
||||||
|
"project_id": project_id or "unknown",
|
||||||
|
"status": status,
|
||||||
|
"origin": origin,
|
||||||
|
}
|
||||||
|
if extras:
|
||||||
|
metadata.update({k: v for k, v in extras.items() if v is not None})
|
||||||
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
|
def build_podcast_asset_metadata(
|
||||||
|
*,
|
||||||
|
asset_role: str,
|
||||||
|
project_id: Optional[str],
|
||||||
|
status: str = "completed",
|
||||||
|
origin: str,
|
||||||
|
extras: Optional[Dict[str, Any]] = None,
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
"""Podcast-specific metadata builder."""
|
||||||
|
return build_asset_metadata(
|
||||||
|
feature=PODCAST_FEATURE,
|
||||||
|
asset_role=asset_role,
|
||||||
|
project_id=project_id,
|
||||||
|
status=status,
|
||||||
|
origin=origin,
|
||||||
|
extras=extras,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_asset_metadata(metadata: Optional[Dict[str, Any]]) -> Tuple[bool, str]:
|
||||||
|
"""Validate minimum schema requirements."""
|
||||||
|
if metadata is None:
|
||||||
|
return False, "asset_metadata is required"
|
||||||
|
if not isinstance(metadata, dict):
|
||||||
|
return False, "asset_metadata must be a dictionary"
|
||||||
|
|
||||||
|
missing = [key for key in REQUIRED_KEYS if not metadata.get(key)]
|
||||||
|
if missing:
|
||||||
|
return False, f"asset_metadata missing required keys: {', '.join(missing)}"
|
||||||
|
|
||||||
|
if str(metadata.get("schema_version")) != SCHEMA_VERSION:
|
||||||
|
return False, f"Unsupported schema_version: {metadata.get('schema_version')}"
|
||||||
|
|
||||||
|
return True, "ok"
|
||||||
63
backend/scripts/backfill_podcast_asset_metadata.py
Normal file
63
backend/scripts/backfill_podcast_asset_metadata.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
"""Backfill recent podcast assets with normalized metadata schema."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from sqlalchemy import desc
|
||||||
|
|
||||||
|
from services.database import SessionLocal
|
||||||
|
from models.content_asset_models import ContentAsset, AssetSource
|
||||||
|
from models.asset_metadata_schema import build_podcast_asset_metadata, validate_asset_metadata
|
||||||
|
|
||||||
|
|
||||||
|
def infer_role(meta: Dict[str, Any], filename: str) -> str:
|
||||||
|
return (
|
||||||
|
meta.get("asset_role")
|
||||||
|
or meta.get("type")
|
||||||
|
or ("podcast_audio" if filename.lower().endswith((".mp3", ".wav", ".m4a")) else "podcast_asset")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main(days: int = 90) -> None:
|
||||||
|
db = SessionLocal()
|
||||||
|
updated = 0
|
||||||
|
scanned = 0
|
||||||
|
since = datetime.utcnow() - timedelta(days=days)
|
||||||
|
try:
|
||||||
|
assets = (
|
||||||
|
db.query(ContentAsset)
|
||||||
|
.filter(ContentAsset.source_module == AssetSource.PODCAST_MAKER)
|
||||||
|
.filter(ContentAsset.created_at >= since)
|
||||||
|
.order_by(desc(ContentAsset.created_at))
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
|
for asset in assets:
|
||||||
|
scanned += 1
|
||||||
|
meta = asset.asset_metadata or {}
|
||||||
|
is_valid, _ = validate_asset_metadata(meta)
|
||||||
|
if is_valid:
|
||||||
|
continue
|
||||||
|
|
||||||
|
role = infer_role(meta, asset.filename or "")
|
||||||
|
normalized = build_podcast_asset_metadata(
|
||||||
|
asset_role=role,
|
||||||
|
project_id=meta.get("project_id"),
|
||||||
|
status=meta.get("status", "completed"),
|
||||||
|
origin=meta.get("origin", "migration.backfill_podcast_asset_metadata"),
|
||||||
|
extras=meta,
|
||||||
|
)
|
||||||
|
asset.asset_metadata = normalized
|
||||||
|
db.add(asset)
|
||||||
|
updated += 1
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
print(f"Scanned={scanned} Updated={updated} Since={since.isoformat()}")
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -697,39 +697,6 @@ class BaseALwrityAgent(ABC):
|
|||||||
"action_id": action.action_id,
|
"action_id": action.action_id,
|
||||||
"agent_id": self.agent_id,
|
"agent_id": self.agent_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
capability_decision = self._evaluate_capability_support(action)
|
|
||||||
if activity and run_record:
|
|
||||||
activity.log_event(
|
|
||||||
event_type="decision",
|
|
||||||
severity="info" if capability_decision.get("supported", False) else "warning",
|
|
||||||
message=capability_decision.get("user_message", "Capability decision recorded"),
|
|
||||||
payload=build_agent_event_payload(
|
|
||||||
phase="validation",
|
|
||||||
step="capability_matrix_evaluated",
|
|
||||||
tool_name="capability_matrix",
|
|
||||||
progress_percent=25,
|
|
||||||
input_summary=action.action_type,
|
|
||||||
output_summary="Supported action" if capability_decision.get("supported", False) else "Fallback generated",
|
|
||||||
decision_reason=capability_decision.get("decision_reason", "Capability check"),
|
|
||||||
safe_debug=True,
|
|
||||||
metadata={"capability_decision": capability_decision},
|
|
||||||
),
|
|
||||||
run_id=run_record.id,
|
|
||||||
agent_type=self.agent_type,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not capability_decision.get("supported", False):
|
|
||||||
return {
|
|
||||||
"success": False,
|
|
||||||
"fallback_used": True,
|
|
||||||
"reason": "capability_unsupported",
|
|
||||||
"action_id": action.action_id,
|
|
||||||
"agent_id": self.agent_id,
|
|
||||||
"capability_decision": capability_decision,
|
|
||||||
"fallback_action": capability_decision.get("fallback_action"),
|
|
||||||
"user_message": capability_decision.get("user_message"),
|
|
||||||
}
|
|
||||||
|
|
||||||
# 2. Create rollback checkpoint
|
# 2. Create rollback checkpoint
|
||||||
try:
|
try:
|
||||||
@@ -945,83 +912,6 @@ class BaseALwrityAgent(ABC):
|
|||||||
Please execute this action and provide a detailed response.
|
Please execute this action and provide a detailed response.
|
||||||
Consider user goals, safety constraints, and potential impacts.
|
Consider user goals, safety constraints, and potential impacts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get_social_capability_matrix(self) -> Dict[str, Dict[str, bool]]:
|
|
||||||
"""Capability matrix for social platform integration managers."""
|
|
||||||
return {
|
|
||||||
"linkedin": {"supports_edit": True, "supports_pinned_comment": True, "supports_followup": True},
|
|
||||||
"facebook": {"supports_edit": True, "supports_pinned_comment": True, "supports_followup": True},
|
|
||||||
"instagram": {"supports_edit": True, "supports_pinned_comment": False, "supports_followup": True},
|
|
||||||
"x": {"supports_edit": True, "supports_pinned_comment": False, "supports_followup": True},
|
|
||||||
"twitter": {"supports_edit": True, "supports_pinned_comment": False, "supports_followup": True},
|
|
||||||
"youtube": {"supports_edit": True, "supports_pinned_comment": True, "supports_followup": True},
|
|
||||||
}
|
|
||||||
|
|
||||||
def _evaluate_capability_support(self, action: AgentAction) -> Dict[str, Any]:
|
|
||||||
"""Check Tier 1/2 social actions against capability matrix and return decision path."""
|
|
||||||
platform = str(action.parameters.get("platform", "")).strip().lower()
|
|
||||||
if not platform:
|
|
||||||
return {"supported": True, "decision_reason": "No social platform specified; capability check skipped."}
|
|
||||||
|
|
||||||
matrix = self._get_social_capability_matrix()
|
|
||||||
platform_caps = matrix.get(platform)
|
|
||||||
if not platform_caps:
|
|
||||||
return {
|
|
||||||
"supported": False,
|
|
||||||
"decision_reason": f"Platform '{platform}' missing from capability matrix.",
|
|
||||||
"fallback_action": self._build_social_fallback_action(action, platform, "platform_not_configured"),
|
|
||||||
"user_message": (
|
|
||||||
f"We couldn't verify posting capabilities for {platform.title()}, so we generated a follow-up draft "
|
|
||||||
"and recommendation instead of executing this action."
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
action_tier = str(action.parameters.get("action_tier", "")).strip().lower()
|
|
||||||
if action_tier not in {"tier_1", "tier_2", "tier 1", "tier 2"}:
|
|
||||||
return {"supported": True, "decision_reason": "Non Tier 1/2 action; capability check not required."}
|
|
||||||
|
|
||||||
action_type = action.action_type.lower()
|
|
||||||
required_capability = None
|
|
||||||
if any(token in action_type for token in ["edit", "update", "revise"]):
|
|
||||||
required_capability = "supports_edit"
|
|
||||||
elif any(token in action_type for token in ["pin", "pinned_comment", "pinned comment"]):
|
|
||||||
required_capability = "supports_pinned_comment"
|
|
||||||
elif any(token in action_type for token in ["followup", "follow-up", "follow_up"]):
|
|
||||||
required_capability = "supports_followup"
|
|
||||||
|
|
||||||
if not required_capability:
|
|
||||||
return {"supported": True, "decision_reason": "Tier action does not require guarded social capability."}
|
|
||||||
|
|
||||||
supported = bool(platform_caps.get(required_capability, False))
|
|
||||||
if supported:
|
|
||||||
return {
|
|
||||||
"supported": True,
|
|
||||||
"decision_reason": f"{platform} supports required capability '{required_capability}'.",
|
|
||||||
"required_capability": required_capability,
|
|
||||||
"platform_capabilities": platform_caps,
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"supported": False,
|
|
||||||
"decision_reason": f"{platform} does not support required capability '{required_capability}'.",
|
|
||||||
"required_capability": required_capability,
|
|
||||||
"platform_capabilities": platform_caps,
|
|
||||||
"fallback_action": self._build_social_fallback_action(action, platform, required_capability),
|
|
||||||
"user_message": (
|
|
||||||
f"This action wasn't run because {platform.title()} does not support {required_capability}. "
|
|
||||||
"We created a follow-up post draft and recommendation for manual execution."
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
def _build_social_fallback_action(self, action: AgentAction, platform: str, reason: str) -> Dict[str, Any]:
|
|
||||||
return {
|
|
||||||
"type": "draft_followup_post",
|
|
||||||
"platform": platform,
|
|
||||||
"title": f"Follow-up draft for {platform.title()}",
|
|
||||||
"draft": f"Follow-up for original action '{action.action_type}' on {action.target_resource}.",
|
|
||||||
"recommendation": "Review and publish manually, then notify the team.",
|
|
||||||
"reason": reason,
|
|
||||||
}
|
|
||||||
|
|
||||||
async def _validate_action_safety(self, action: AgentAction) -> bool:
|
async def _validate_action_safety(self, action: AgentAction) -> bool:
|
||||||
"""Validate action against safety constraints"""
|
"""Validate action against safety constraints"""
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ class SocialAmplificationAgent(BaseALwrityAgent):
|
|||||||
# Instruction will be provided via orchestrator context or initial prompt
|
# Instruction will be provided via orchestrator context or initial prompt
|
||||||
# Instruction should be provided during invocation or via orchestrator context
|
# Instruction should be provided during invocation or via orchestrator context
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_social_integration_capabilities(self) -> Dict[str, Dict[str, bool]]:
|
|
||||||
"""Expose platform capability flags used by social integration managers."""
|
|
||||||
return self._get_social_capability_matrix()
|
|
||||||
|
|
||||||
# Tool Implementations
|
# Tool Implementations
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from models.asset_metadata_schema import validate_asset_metadata
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Maximum file size (100MB)
|
# Maximum file size (100MB)
|
||||||
@@ -140,6 +142,12 @@ def save_asset_to_library(
|
|||||||
if len(title) > 200:
|
if len(title) > 200:
|
||||||
title = title[:197] + '...'
|
title = title[:197] + '...'
|
||||||
|
|
||||||
|
metadata_payload = asset_metadata or {}
|
||||||
|
is_valid_metadata, validation_message = validate_asset_metadata(metadata_payload)
|
||||||
|
if not is_valid_metadata:
|
||||||
|
logger.error(f"Invalid asset metadata: {validation_message}")
|
||||||
|
return None
|
||||||
|
|
||||||
service = ContentAssetService(db)
|
service = ContentAssetService(db)
|
||||||
asset = service.create_asset(
|
asset = service.create_asset(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
@@ -154,7 +162,7 @@ def save_asset_to_library(
|
|||||||
description=description,
|
description=description,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
tags=tags or [],
|
tags=tags or [],
|
||||||
asset_metadata=asset_metadata or {},
|
asset_metadata=metadata_payload,
|
||||||
provider=provider,
|
provider=provider,
|
||||||
model=model,
|
model=model,
|
||||||
cost=cost,
|
cost=cost,
|
||||||
|
|||||||
Reference in New Issue
Block a user