Compare commits
1 Commits
codex/defi
...
codex/expo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cef7c7257 |
@@ -26,7 +26,6 @@ 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
|
||||||
@@ -218,11 +217,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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="uploaded_audio",
|
"project_id": project_id,
|
||||||
project_id=project_id,
|
"type": "uploaded_audio",
|
||||||
origin="podcast.audio.upload",
|
"status": "completed",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
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}")
|
||||||
@@ -456,12 +455,11 @@ 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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="podcast_audio",
|
"scene_id": request.scene_id,
|
||||||
project_id=request.project_id,
|
"scene_title": request.scene_title,
|
||||||
origin="podcast.audio.generate",
|
"status": "completed",
|
||||||
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}")
|
||||||
@@ -623,12 +621,13 @@ 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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="combined_podcast_audio",
|
"project_id": request.project_id,
|
||||||
project_id=request.project_id,
|
"scene_ids": request.scene_ids,
|
||||||
origin="podcast.audio.combine",
|
"scene_count": len(request.scene_ids),
|
||||||
extras={"scene_ids": request.scene_ids, "scene_count": len(request.scene_ids), "total_duration": total_duration},
|
"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,7 +18,6 @@ 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
|
||||||
@@ -112,11 +111,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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="presenter_avatar",
|
"project_id": project_id,
|
||||||
project_id=project_id,
|
"type": "presenter_avatar",
|
||||||
origin="podcast.avatar.upload",
|
"status": "completed",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
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}")
|
||||||
@@ -224,12 +223,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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="transformed_presenter",
|
"project_id": project_id,
|
||||||
project_id=project_id,
|
"type": "transformed_presenter",
|
||||||
origin="podcast.avatar.make_presentable",
|
"original_avatar_url": avatar_url,
|
||||||
extras={"original_avatar_url": avatar_url},
|
"status": "completed",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
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}")
|
||||||
@@ -405,12 +404,14 @@ 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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="generated_presenter",
|
"project_id": project_id,
|
||||||
project_id=project_id,
|
"speaker_number": i + 1,
|
||||||
origin="podcast.avatar.generate",
|
"type": "generated_presenter",
|
||||||
extras={"speaker_number": i + 1, "persona_id": selected_persona_id, "seed": seed},
|
"status": "completed",
|
||||||
),
|
"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,7 +16,6 @@ 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
|
||||||
@@ -418,12 +417,11 @@ 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=build_podcast_asset_metadata(
|
asset_metadata={
|
||||||
asset_role="podcast_scene_image",
|
"scene_id": request.scene_id,
|
||||||
project_id=request.project_id,
|
"scene_title": request.scene_title,
|
||||||
origin="podcast.images.generate",
|
"status": "completed",
|
||||||
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}")
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
"""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"
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
"""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()
|
|
||||||
@@ -698,6 +698,39 @@ class BaseALwrityAgent(ABC):
|
|||||||
"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:
|
||||||
# Capture current system state
|
# Capture current system state
|
||||||
@@ -913,6 +946,83 @@ class BaseALwrityAgent(ABC):
|
|||||||
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"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ class SocialAmplificationAgent(BaseALwrityAgent):
|
|||||||
# 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
|
||||||
|
|
||||||
def _social_monitor_tool(self, context: Dict[str, Any]) -> Dict[str, Any]:
|
def _social_monitor_tool(self, context: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ 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)
|
||||||
@@ -142,12 +140,6 @@ 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,
|
||||||
@@ -162,7 +154,7 @@ def save_asset_to_library(
|
|||||||
description=description,
|
description=description,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
tags=tags or [],
|
tags=tags or [],
|
||||||
asset_metadata=metadata_payload,
|
asset_metadata=asset_metadata or {},
|
||||||
provider=provider,
|
provider=provider,
|
||||||
model=model,
|
model=model,
|
||||||
cost=cost,
|
cost=cost,
|
||||||
|
|||||||
Reference in New Issue
Block a user