How eeman1113/story works
Project type and purpose
• This is a Python-based, single-process, command-line “pipeline” application (no separate frontend/backend) that orchestrates a sequence of Langchain/LLM “chains” to generate a complete long-form narrative (a novel) from inputs (PDF resume, story premise, author style, genre). It uses Ollama-hosted LLMs locally and produces a .docx output.
File structure
Top-level:
• main.py / supercomputer_wont_be_enough_main.py / ULTIMATE_POWER.py / novel_generator.py – potential orchestration/entry-point scripts
• character.py, subject.py – specialized chain modules (e.g., MainCharacterChain)
• docs/ – stores resumes (PDFs), intermediary .ipynb experiments, story drafts, and final output folder
• requirements.txt – Python dependencies
• numerous notebooks (.ipynb) and throwaway scripts (100.py, try.py, etc.) – for prototyping
No separate “frontend” or “backend” folders; everything lives in one codebase.
README for additional insights
• The README describes a linear pipeline of nine specialized Langchain chains (MainCharacterChain, SettingChain, ThemeChain, TitleChain, PlotChain, ChaptersChain, EventChain, WriterChain, RefinementChain) orchestrated by app_v2.py (or its analog in your code: main.py or supercomputer_wont_be_enough_main.py).
• It also references a DocWriter class to assemble and write the .docx file.
a. Main Components
1. Inputs
• PDF Resume (docs/divi_1.pdf or similar)
• Story Premise/Subject (CLI argument or config in main)
• Author Style (CLI/config)
• Genre (CLI/config)
2. Orchestrator Script
• main.py (or supercomputer_wont_be_enough_main.py) – glues everything together
3. LLM Host
• Ollama Service (gemma2, llama3, etc.)
4. Chain Modules
• MainCharacterChain (character.py)
• SettingChain, ThemeChain, TitleChain, PlotChain, ChaptersChain, EventChain, WriterChain, RefinementChain (may be defined in main.py or separate modules)
5. DocWriter
• Assembles front matter and full narrative, writes .docx via python-docx
6. Output
• Sanitized_Title.docx in docs/ (or configured output folder)
b. Relationships and Data Flow
1. User inputs → Orchestrator
2. Orchestrator initializes LLM connection via create_llm()
3. For each chain i=1..9:
• Orchestrator calls Chain_i.run(...)
• Chain_i invokes LLMChain → Ollama → returns structured result
• Orchestrator collects and passes outputs as inputs to the next chain
4. After all narrative chains complete, Orchestrator passes accumulated data → DocWriter
5. DocWriter writes .docx → Output folder
c. Architectural Patterns & Design Principles
• Pipeline pattern – sequential data processing stages
• Separation of concerns – each narrative component is its own “chain” module
• Dependency injection of LLM config via create_llm() (temperature, top_k, top_p)
• Robust error handling at each stage to continue generation where possible
d. Key Technologies & Libraries
• Python 3.x
• Ollama (local LLM service)
• Langchain: OllamaLLM, LLMChain, PromptTemplate, PyPDFLoader
• python-docx for output
• python-dotenv for config
• re (regex) for parsing
Detail to capture
• Chain sequence and handoff of context variables (character profile → setting → themes → title → plot → chapters → events → paragraphs → optional refinement)
• Configuration injection (.env / constants)
• Error-handling branches (e.g., if a chain fails, pass “N/A” forward)
• Document assembly step