13bce7500c
This commit includes: - A full code review and bug fixes for language drift, package loading, and CLI crashes. - The generated 15,000-word philosophy manuscript. - CODE_REVIEW.md and CHANGELOG.md documenting the process.
195 lines
6.0 KiB
Python
195 lines
6.0 KiB
Python
"""Opus Orchestrator - AI Book Generation System.
|
|
|
|
Version: 0.2.0
|
|
|
|
Quick Start:
|
|
opus generate --concept "Your book idea"
|
|
opus serve --port 8000
|
|
|
|
For full documentation, see README.md
|
|
"""
|
|
|
|
# Lazy imports to avoid circular dependency on cold starts
|
|
# See: https://peps.python.org/pep-0562/
|
|
def __getattr__(name: str):
|
|
"""Lazy import for module-level attributes to break circular imports."""
|
|
|
|
# Core exports
|
|
if name == "OpusOrchestrator":
|
|
from opus_orchestrator.orchestrator import OpusOrchestrator
|
|
return OpusOrchestrator
|
|
if name == "run_opus":
|
|
from opus_orchestrator.langgraph_workflow import run_opus
|
|
return run_opus
|
|
if name == "OpusConfig":
|
|
from opus_orchestrator.config import OpusConfig
|
|
return OpusConfig
|
|
if name == "get_config":
|
|
from opus_orchestrator.config import get_config
|
|
return get_config
|
|
if name == "set_config":
|
|
from opus_orchestrator.config import set_config
|
|
return set_config
|
|
if name == "OpusState":
|
|
from opus_orchestrator.state import OpusState
|
|
return OpusState
|
|
if name == "NonfictionGenerator":
|
|
from opus_orchestrator.nonfiction_generator import NonfictionGenerator
|
|
return NonfictionGenerator
|
|
if name == "OpusLogger":
|
|
from opus_orchestrator.logging import OpusLogger
|
|
return OpusLogger
|
|
if name == "get_logger":
|
|
from opus_orchestrator.logging import get_logger
|
|
return get_logger
|
|
|
|
# Frameworks
|
|
if name == "StoryFramework":
|
|
from opus_orchestrator.frameworks import StoryFramework
|
|
return StoryFramework
|
|
if name == "FRAMEWORKS":
|
|
from opus_orchestrator.frameworks import FRAMEWORKS
|
|
return FRAMEWORKS
|
|
if name == "get_framework_for_genre":
|
|
from opus_orchestrator.frameworks import get_framework_for_genre
|
|
return get_framework_for_genre
|
|
if name == "get_framework_prompt":
|
|
from opus_orchestrator.frameworks import get_framework_prompt
|
|
return get_framework_prompt
|
|
|
|
# Schemas
|
|
if name == "BookBlueprint":
|
|
from opus_orchestrator.schemas import BookBlueprint
|
|
return BookBlueprint
|
|
if name == "BookIntent":
|
|
from opus_orchestrator.schemas import BookIntent
|
|
return BookIntent
|
|
if name == "BookType":
|
|
from opus_orchestrator.schemas import BookType
|
|
return BookType
|
|
if name == "Chapter":
|
|
from opus_orchestrator.schemas import Chapter
|
|
return Chapter
|
|
if name == "ChapterBlueprint":
|
|
from opus_orchestrator.schemas import ChapterBlueprint
|
|
return ChapterBlueprint
|
|
if name == "ChapterCritique":
|
|
from opus_orchestrator.schemas import ChapterCritique
|
|
return ChapterCritique
|
|
if name == "ChapterDraft":
|
|
from opus_orchestrator.schemas import ChapterDraft
|
|
return ChapterDraft
|
|
if name == "Manuscript":
|
|
from opus_orchestrator.schemas import Manuscript
|
|
return Manuscript
|
|
if name == "RawContent":
|
|
from opus_orchestrator.schemas import RawContent
|
|
return RawContent
|
|
|
|
# Utilities
|
|
if name == "LLMClient":
|
|
from opus_orchestrator.utils.llm import LLMClient
|
|
return LLMClient
|
|
if name == "get_llm_client":
|
|
from opus_orchestrator.utils.llm import get_llm_client
|
|
return get_llm_client
|
|
if name == "RetryHandler":
|
|
from opus_orchestrator.utils.retry import RetryHandler
|
|
return RetryHandler
|
|
if name == "CircuitBreaker":
|
|
from opus_orchestrator.utils.retry import CircuitBreaker
|
|
return CircuitBreaker
|
|
if name == "with_retry":
|
|
from opus_orchestrator.utils.retry import with_retry
|
|
return with_retry
|
|
|
|
# Scrivener Export
|
|
if name == "ScrivenerExporter":
|
|
from opus_orchestrator.scrivener_export import ScrivenerExporter
|
|
return ScrivenerExporter
|
|
if name == "export_to_scrivener":
|
|
from opus_orchestrator.scrivener_export import export_to_scrivener
|
|
return export_to_scrivener
|
|
if name == "ExportOptions":
|
|
from opus_orchestrator.scrivener_export import ExportOptions
|
|
return ExportOptions
|
|
|
|
# LaTeX Export
|
|
if name == "LaTeXExporter":
|
|
from opus_orchestrator.latex_compile import LaTeXExporter
|
|
return LaTeXExporter
|
|
if name == "CompileOptions":
|
|
from opus_orchestrator.latex_compile import CompileOptions
|
|
return CompileOptions
|
|
if name == "export_to_latex":
|
|
from opus_orchestrator.latex_compile import export_to_latex
|
|
return export_to_latex
|
|
if name == "compile_pdf":
|
|
from opus_orchestrator.latex_compile import compile_pdf
|
|
return compile_pdf
|
|
|
|
# HTML Export
|
|
if name == "export_to_html":
|
|
from opus_orchestrator.html_export import export_to_html
|
|
return export_to_html
|
|
if name == "export_to_pdf":
|
|
from opus_orchestrator.html_export import export_to_pdf
|
|
return export_to_pdf
|
|
if name == "HTMLExporter":
|
|
from opus_orchestrator.html_export import HTMLExporter
|
|
return HTMLExporter
|
|
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
|
|
|
|
__version__ = "0.2.0"
|
|
|
|
# Explicit __all__ for static analysis and IDE support
|
|
__all__ = [
|
|
# Core
|
|
"OpusOrchestrator",
|
|
"OpusConfig",
|
|
"get_config",
|
|
"set_config",
|
|
"OpusState",
|
|
"NonfictionGenerator",
|
|
"run_opus",
|
|
# Logging
|
|
"OpusLogger",
|
|
"get_logger",
|
|
# Frameworks
|
|
"StoryFramework",
|
|
"FRAMEWORKS",
|
|
"get_framework_for_genre",
|
|
"get_framework_prompt",
|
|
# Schemas
|
|
"BookBlueprint",
|
|
"BookIntent",
|
|
"BookType",
|
|
"Chapter",
|
|
"ChapterBlueprint",
|
|
"ChapterCritique",
|
|
"ChapterDraft",
|
|
"Manuscript",
|
|
"RawContent",
|
|
# Utilities
|
|
"LLMClient",
|
|
"get_llm_client",
|
|
"RetryHandler",
|
|
"CircuitBreaker",
|
|
"with_retry",
|
|
# Scrivener Export
|
|
"ScrivenerExporter",
|
|
"export_to_scrivener",
|
|
"ExportOptions",
|
|
# LaTeX Export
|
|
"LaTeXExporter",
|
|
"CompileOptions",
|
|
"export_to_latex",
|
|
"compile_pdf",
|
|
# HTML Export
|
|
"export_to_html",
|
|
"export_to_pdf",
|
|
"HTMLExporter",
|
|
]
|