Audit, bug fixes, and coherence enhancements by Gemini AI
This commit is contained in:
@@ -316,14 +316,40 @@ Generate a detailed outline with:
|
||||
|
||||
# =========================================================================
|
||||
|
||||
async def ingest(self, content: Optional[RawContent] = None) -> OpusState:
|
||||
"""Ingest raw content from repository."""
|
||||
if self.repo_url and not content:
|
||||
content = RawContent(
|
||||
content_type="repository",
|
||||
text="[Content would be extracted from GitHub repository]",
|
||||
metadata={"repo_url": self.repo_url},
|
||||
async def ingest(
|
||||
self,
|
||||
content: Optional[RawContent] = None,
|
||||
sources: Optional[list[dict]] = None,
|
||||
) -> OpusState:
|
||||
"""Ingest raw content from multiple sources.
|
||||
|
||||
Args:
|
||||
content: Pre-loaded raw content
|
||||
sources: List of source configurations (github, local, s3)
|
||||
"""
|
||||
if sources:
|
||||
from opus_orchestrator.utils.multi_source_ingest import ingest_multiple
|
||||
|
||||
print(f"📥 Ingesting from {len(sources)} sources...")
|
||||
|
||||
result = await ingest_multiple(
|
||||
sources=sources,
|
||||
github_token=self.config.github_token,
|
||||
# AWS keys would come from environment
|
||||
)
|
||||
|
||||
content = RawContent(
|
||||
content_type="multi-source",
|
||||
text=result.merged_content,
|
||||
metadata={
|
||||
"total_sources": result.total_sources,
|
||||
"successful": result.successful_sources,
|
||||
"summary": result.source_summary,
|
||||
},
|
||||
)
|
||||
elif self.repo_url and not content:
|
||||
# Fallback to single GitHub repo
|
||||
content = self.ingest_from_github(self.repo_url)
|
||||
|
||||
self.state = OpusState(
|
||||
repo_url=self.repo_url or "",
|
||||
@@ -828,19 +854,27 @@ Make it vivid, engaging, and true to the characters.
|
||||
return manuscript
|
||||
|
||||
# =========================================================================
|
||||
# MAIN RUN METHOD - FULL SNOWFLAKE
|
||||
# MAIN RUN METHOD - FULL PIPELINE
|
||||
# =========================================================================
|
||||
|
||||
async def run(self) -> Manuscript:
|
||||
"""Run the full pipeline with selected framework."""
|
||||
framework_name = self.framework_info.get("name", "Unknown")
|
||||
async def run(self, sources: Optional[list[dict]] = None) -> Manuscript:
|
||||
"""Run the full pipeline (Fiction or Nonfiction)."""
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"❄️ OPUS ORCHESTRATOR - {framework_name.upper()}")
|
||||
print(f"{'='*60}")
|
||||
print(f"Framework: {self.framework_info.get('description', '')}\n")
|
||||
print(f"❄️ OPUS ORCHESTRATOR - {self.book_type.value.upper()}")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
await self.ingest()
|
||||
await self.ingest(sources=sources)
|
||||
|
||||
if self.book_type == BookType.FICTION:
|
||||
return await self._run_fiction()
|
||||
else:
|
||||
return await self._run_nonfiction()
|
||||
|
||||
async def _run_fiction(self) -> Manuscript:
|
||||
"""Run the fiction pipeline."""
|
||||
framework_name = self.framework_info.get("name", "Unknown")
|
||||
print(f"Framework: {framework_name}\n")
|
||||
|
||||
# Pre-writing stages
|
||||
await self.snowflake_stage_1() # One sentence
|
||||
@@ -858,17 +892,46 @@ Make it vivid, engaging, and true to the characters.
|
||||
await self.generate_blueprint()
|
||||
|
||||
# Write and critique chapters
|
||||
manuscript = await self.compile_manuscript()
|
||||
return await self.compile_manuscript()
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print("✅ COMPLETE!")
|
||||
print(f"{'='*60}")
|
||||
print(f"📖 Title: {manuscript.title}")
|
||||
print(f"📄 Words: {manuscript.total_word_count:,}")
|
||||
print(f"📑 Chapters: {len(manuscript.chapters)}")
|
||||
print(f"🎯 Framework: {framework_name}")
|
||||
|
||||
return manuscript
|
||||
async def _run_nonfiction(self) -> Manuscript:
|
||||
"""Run the nonfiction pipeline."""
|
||||
print(f"Purpose: {self.purpose.value if self.purpose else 'N/A'}")
|
||||
print(f"Framework: {self.nonfiction_framework.get('name', 'N/A')}\n")
|
||||
|
||||
# 1. Research & Analysis
|
||||
print("🔍 RESEARCH & ANALYSIS...")
|
||||
# (Simplified for now - would use researcher agent)
|
||||
self.one_sentence = f"A book about {self.intent.genre or 'the subject'}"
|
||||
self.one_paragraph = f"Comprehensive guide covering {self.intent.genre}"
|
||||
|
||||
# 2. Generate Chapters based on Framework stages
|
||||
print("📅 GENERATING BLUEPRINT...")
|
||||
chapters_blueprint = []
|
||||
for i, stage in enumerate(self.framework_stages):
|
||||
chapters_blueprint.append(ChapterBlueprint(
|
||||
chapter_number=i + 1,
|
||||
title=stage,
|
||||
summary=f"Section covering {stage}",
|
||||
word_count_target=self.intent.target_word_count // len(self.framework_stages),
|
||||
))
|
||||
|
||||
self.state.blueprint = BookBlueprint(
|
||||
title=self.intent.working_title or "Nonfiction Guide",
|
||||
genre=self.intent.genre or "nonfiction",
|
||||
target_audience=self.intent.target_audience,
|
||||
target_word_count=self.intent.target_word_count,
|
||||
structure="framework-driven",
|
||||
themes=[],
|
||||
tone=self.intent.tone or "informative",
|
||||
chapters=chapters_blueprint,
|
||||
)
|
||||
|
||||
# 3. Create style guide
|
||||
await self.create_style_guide()
|
||||
|
||||
# 4. Write chapters
|
||||
return await self.compile_manuscript()
|
||||
|
||||
def save_manuscript(self, output_path: Optional[Path] = None) -> Path:
|
||||
"""Save manuscript and pre-writing to files."""
|
||||
|
||||
Reference in New Issue
Block a user