Skip to content

Commit

Permalink
feat: include outline and worldbuilding directories, exclude cover an…
Browse files Browse the repository at this point in the history
…d back-cover files

- Added logic to include Markdown files from the outline and worldbuilding directories.
- Excluded cover.md and back-cover.md files from processing.
- Ensured directories are checked for existence before processing files.
  • Loading branch information
Estrada Irribarra, Rodrigo Andres committed Oct 22, 2024
1 parent 1523757 commit 8bf8145
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ First, install **StoryCraftr** using [pipx](https://pypa.github.io/pipx/), a too
To install **StoryCraftr**, run the following command:

```bash
pipx install git+https://github.com/raestrada/storycraftr.git@v0.7.1-alpha3
pipx install git+https://github.com/raestrada/storycraftr.git@v0.7.2-alpha3
```

### Important: Before using StoryCraftr, make sure to set your OpenAI API key:
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ First, install **StoryCraftr** using [pipx](https://pypa.github.io/pipx/), a too
To install **StoryCraftr**, run the following command:

```bash
pipx install git+https://github.com/raestrada/storycraftr.git@v0.7.1-alpha3
pipx install git+https://github.com/raestrada/storycraftr.git@v0.7.2-alpha3
```

### Important: Before running the `storycraftr` command
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h1>Welcome to StoryCraftr 📚✨</h1>
usable but may still have bugs:
<code
>pipx install
git+https://github.com/raestrada/storycraftr.git@v0.7.1-alpha3</code
git+https://github.com/raestrada/storycraftr.git@v0.7.2-alpha3</code
>
</div>
</section>
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "storycraftr"
version = "0.7.1-alpha3"
version = "0.7.2-alpha3"
description = "A CLI tool for writing books using OpenAI."
authors = ["Tu nombre <tuemail@example.com>"]
license = "MIT"
Expand Down
26 changes: 21 additions & 5 deletions storycraftr/agent/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,29 @@ def process_chapters(
file_suffix (str): Suffix for the output file.
**prompt_kwargs: Additional arguments for the prompt template.
"""
# Directories to process
chapters_dir = os.path.join(book_path, "chapters")
if not os.path.exists(chapters_dir):
raise FileNotFoundError(
f"The chapter directory '{chapters_dir}' does not exist."
)
outline_dir = os.path.join(book_path, "outline")
worldbuilding_dir = os.path.join(book_path, "worldbuilding")

# Check if directories exist
for dir_path in [chapters_dir, outline_dir, worldbuilding_dir]:
if not os.path.exists(dir_path):
raise FileNotFoundError(f"The directory '{dir_path}' does not exist.")

# Files to exclude
excluded_files = ["cover.md", "back-cover.md"]

# Get Markdown files from each directory, excluding the unwanted files
files_to_process = []
for dir_path in [chapters_dir, outline_dir, worldbuilding_dir]:
files = [
f
for f in os.listdir(dir_path)
if f.endswith(".md") and f not in excluded_files
]
files_to_process.extend([os.path.join(dir_path, f) for f in files])

files_to_process = [f for f in os.listdir(chapters_dir) if f.endswith(".md")]
if not files_to_process:
raise FileNotFoundError(
"No Markdown (.md) files were found in the chapter directory."
Expand Down

0 comments on commit 8bf8145

Please sign in to comment.