Recovered state: integrated TrendSurferAgent, restored frontend/backend files, and cleaned up recovery scripts

This commit is contained in:
ajaysi
2026-02-08 13:56:57 +05:30
parent 1db10ccd0f
commit e404a86502
333 changed files with 42223 additions and 10875 deletions

View File

@@ -22,7 +22,7 @@ class EnhancedContentGenerator:
self.transitioner = TransitionGenerator()
self.flow = FlowAnalyzer()
async def generate_section(self, section: Any, research: Any, mode: str = "polished") -> Dict[str, Any]:
async def generate_section(self, section: Any, research: Any, mode: str = "polished", user_id: str = None) -> Dict[str, Any]:
prev_summary = self.memory.build_previous_sections_summary(limit=2)
urls = self.url_manager.pick_relevant_urls(section, research)
prompt = self._build_prompt(section, research, prev_summary, urls)
@@ -33,6 +33,7 @@ class EnhancedContentGenerator:
prompt=prompt,
json_struct=None,
system_prompt=None,
user_id=user_id
)
if isinstance(ai_resp, dict) and ai_resp.get("text"):
content_text = ai_resp.get("text", "")

View File

@@ -254,4 +254,35 @@ class MediumBlogGenerator:
logger.warning(f"Failed to cache content result: {cache_error}")
# Don't fail the entire operation if caching fails
# Save content to user workspace if db session is available
if user_id and db:
try:
# Construct full blog content
full_content = f"# {result.title}\n\n"
for section in result.sections:
full_content += f"## {section.heading}\n\n"
full_content += f"{section.content}\n\n"
# Save to workspace
save_and_track_text_content(
db=db,
user_id=user_id,
content=full_content,
source_module="medium_blog_writer",
title=result.title,
description=f"Generated medium blog: {result.title}",
tags=req.researchKeywords or ["medium_blog", "ai_generated"],
asset_metadata={
"model": result.model,
"generation_time_ms": result.generation_time_ms,
"word_count": sum(s.wordCount for s in result.sections)
},
subdirectory="medium_blogs"
)
logger.info(f"Saved medium blog content to user workspace for user {user_id}")
except Exception as e:
logger.error(f"Failed to save medium blog content to workspace: {e}")
elif not db:
logger.warning("Database session not provided, skipping workspace save for medium blog")
return result