StoryForge 0.0.1b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- storyforge-0.0.1b1/LICENSE +21 -0
- storyforge-0.0.1b1/PKG-INFO +179 -0
- storyforge-0.0.1b1/README.md +155 -0
- storyforge-0.0.1b1/StoryForge.egg-info/PKG-INFO +179 -0
- storyforge-0.0.1b1/StoryForge.egg-info/SOURCES.txt +21 -0
- storyforge-0.0.1b1/StoryForge.egg-info/dependency_links.txt +1 -0
- storyforge-0.0.1b1/StoryForge.egg-info/entry_points.txt +2 -0
- storyforge-0.0.1b1/StoryForge.egg-info/requires.txt +14 -0
- storyforge-0.0.1b1/StoryForge.egg-info/top_level.txt +6 -0
- storyforge-0.0.1b1/pyproject.toml +102 -0
- storyforge-0.0.1b1/setup.cfg +4 -0
- storyforge-0.0.1b1/storytime/StoryTime.py +970 -0
- storyforge-0.0.1b1/storytime/__init__.py +0 -0
- storyforge-0.0.1b1/storytime/context.py +184 -0
- storyforge-0.0.1b1/storytime/gemini_backend.py +144 -0
- storyforge-0.0.1b1/storytime/llm_backend.py +193 -0
- storyforge-0.0.1b1/storytime/prompt.py +412 -0
- storyforge-0.0.1b1/tests/test_StoryTime.py +90 -0
- storyforge-0.0.1b1/tests/test_cli_integration.py +409 -0
- storyforge-0.0.1b1/tests/test_context.py +325 -0
- storyforge-0.0.1b1/tests/test_gemini_backend.py +77 -0
- storyforge-0.0.1b1/tests/test_llm_backend.py +145 -0
- storyforge-0.0.1b1/tests/test_prompt.py +434 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chris
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: StoryForge
|
|
3
|
+
Version: 0.0.1b1
|
|
4
|
+
Summary: A cli app that generates short stories and AI images from prompts using a language model.
|
|
5
|
+
Author: wom
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: google-genai>=1.23.0
|
|
11
|
+
Requires-Dist: pillow>=11.2.1
|
|
12
|
+
Requires-Dist: textual[syntax]>=0.54.1
|
|
13
|
+
Requires-Dist: textual-dev>=0.00.1
|
|
14
|
+
Requires-Dist: typer>=0.9.0
|
|
15
|
+
Requires-Dist: rich>=13.0.0
|
|
16
|
+
Requires-Dist: platformdirs>=4.2.0
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=8.2.0; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff>=0.12.1; extra == "dev"
|
|
20
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pip>=25.1.1; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# StoryTime
|
|
26
|
+
|
|
27
|
+
StoryTime is a Textual-based terminal application that uses Google's Gemini API to generate short stories and AI-generated images from user prompts. The app provides a simple TUI (Text User Interface) for entering prompts, confirming actions, and viewing results. When a user submits a prompt, the app generates a story and a corresponding image, saving the image to disk with a descriptive filename. The project is designed for creative exploration, rapid prototyping, and as a demonstration of integrating LLMs and generative image models into a modern Python TUI.
|
|
28
|
+
|
|
29
|
+
**Features:**
|
|
30
|
+
- Enter a custom story prompt and generate a short story using LLM.
|
|
31
|
+
- Generate AI image illustrations for your story with flexible options:
|
|
32
|
+
- Use the story as context and describe the image yourself
|
|
33
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
34
|
+
- Skip image generation if desired
|
|
35
|
+
- Save generated images to disk with creative, context-aware filenames.
|
|
36
|
+
- All interactions are handled in a modern, responsive terminal UI.
|
|
37
|
+
- Includes unit tests for core logic and easy setup with uv and pytest.
|
|
38
|
+
|
|
39
|
+
## Setup
|
|
40
|
+
|
|
41
|
+
This project uses [uv](https://github.com/astral-sh/uv) for fast Python virtual environment and dependency management.
|
|
42
|
+
|
|
43
|
+
### 1. Create and activate a virtual environment
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
uv venv .venv
|
|
47
|
+
source .venv/bin/activate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Install all dependencies (including dev dependencies) and the package in editable mode
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or, if you want to use uv:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
uv pip install .[dev]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Running the Unit Tests
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pytest
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or, if not in an activated venv:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
.venv/bin/pytest
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Running the Program
|
|
75
|
+
|
|
76
|
+
After installing in editable mode, run the app with:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
storytime
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This command is available as long as your virtual environment is activated.
|
|
83
|
+
|
|
84
|
+
### CLI Usage
|
|
85
|
+
|
|
86
|
+
You can use the command-line interface directly with the unified entry point:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
storytime story "Tell me a story about a robot"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
After generating a story, you will be prompted to choose how to generate illustrations:
|
|
93
|
+
- Use the story as context and describe the image yourself
|
|
94
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
95
|
+
- Skip image generation
|
|
96
|
+
|
|
97
|
+
You can also generate a standalone image:
|
|
98
|
+
```bash
|
|
99
|
+
storytime image "A beautiful sunset over mountains"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or launch the interactive TUI:
|
|
103
|
+
```bash
|
|
104
|
+
storytime tui
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Tab Completion
|
|
108
|
+
|
|
109
|
+
StoryTime CLI supports tab completion for commands, options, and arguments.
|
|
110
|
+
|
|
111
|
+
### Quick Setup (Automatic)
|
|
112
|
+
|
|
113
|
+
Enable tab completion with:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
storytime --install-completion
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Note:** If you get an error about existing files, use the manual setup below.
|
|
120
|
+
|
|
121
|
+
### Manual Setup
|
|
122
|
+
|
|
123
|
+
If automatic installation doesn't work, you can set up completion manually for your shell:
|
|
124
|
+
|
|
125
|
+
**Bash** (add to `~/.bashrc`):
|
|
126
|
+
```bash
|
|
127
|
+
eval "$(storytime --show-completion)"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Zsh** (add to `~/.zshrc`):
|
|
131
|
+
```bash
|
|
132
|
+
eval "$(storytime --show-completion)"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Fish** (add to `~/.config/fish/config.fish`):
|
|
136
|
+
```bash
|
|
137
|
+
storytime --show-completion | source
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
After adding the line to your shell configuration, restart your terminal or run:
|
|
141
|
+
```bash
|
|
142
|
+
source ~/.bashrc # for bash
|
|
143
|
+
source ~/.zshrc # for zsh
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Using Tab Completion
|
|
147
|
+
|
|
148
|
+
Once enabled, you can use tab completion for:
|
|
149
|
+
|
|
150
|
+
- **Commands**: `storytime <TAB>` shows available commands (`story`, `image`, `tui`)
|
|
151
|
+
- **Options**: `storytime story --<TAB>` shows options like `--output-dir`, `--verbose`, etc.
|
|
152
|
+
- **Help**: Use `storytime <command> --help` to see all available options
|
|
153
|
+
|
|
154
|
+
## Editing and Debugging
|
|
155
|
+
|
|
156
|
+
- All source code is in the `storytime/` package. When editing or adding files, use package imports (e.g., `from storytime.gemini_backend import GeminiBackend`).
|
|
157
|
+
- To add a new backend, create a new file in `storytime/` and implement the `LLMBackend` interface.
|
|
158
|
+
- To debug, you can add print statements or use a debugger in any module in the `storytime/` package.
|
|
159
|
+
- After making changes, rerun the tests with `pytest` to ensure everything works.
|
|
160
|
+
|
|
161
|
+
## Adding New Dependencies
|
|
162
|
+
|
|
163
|
+
- To add a new main (runtime) dependency:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
uv pip install <package>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- To add a new dev (test/tooling) dependency:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
uv pip install --extra dev <package>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- After adding dependencies, uv will update your `pyproject.toml` and `uv.lock` automatically.
|
|
176
|
+
|
|
177
|
+
## Notes
|
|
178
|
+
- Make sure you have a valid `GEMINI_API_KEY` in your environment before running the program.
|
|
179
|
+
- The TUI requires a terminal that supports Textual applications.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# StoryTime
|
|
2
|
+
|
|
3
|
+
StoryTime is a Textual-based terminal application that uses Google's Gemini API to generate short stories and AI-generated images from user prompts. The app provides a simple TUI (Text User Interface) for entering prompts, confirming actions, and viewing results. When a user submits a prompt, the app generates a story and a corresponding image, saving the image to disk with a descriptive filename. The project is designed for creative exploration, rapid prototyping, and as a demonstration of integrating LLMs and generative image models into a modern Python TUI.
|
|
4
|
+
|
|
5
|
+
**Features:**
|
|
6
|
+
- Enter a custom story prompt and generate a short story using LLM.
|
|
7
|
+
- Generate AI image illustrations for your story with flexible options:
|
|
8
|
+
- Use the story as context and describe the image yourself
|
|
9
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
10
|
+
- Skip image generation if desired
|
|
11
|
+
- Save generated images to disk with creative, context-aware filenames.
|
|
12
|
+
- All interactions are handled in a modern, responsive terminal UI.
|
|
13
|
+
- Includes unit tests for core logic and easy setup with uv and pytest.
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
This project uses [uv](https://github.com/astral-sh/uv) for fast Python virtual environment and dependency management.
|
|
18
|
+
|
|
19
|
+
### 1. Create and activate a virtual environment
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
uv venv .venv
|
|
23
|
+
source .venv/bin/activate
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 2. Install all dependencies (including dev dependencies) and the package in editable mode
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install -e .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or, if you want to use uv:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
uv pip install .[dev]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Running the Unit Tests
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
pytest
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or, if not in an activated venv:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
.venv/bin/pytest
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Running the Program
|
|
51
|
+
|
|
52
|
+
After installing in editable mode, run the app with:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
storytime
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This command is available as long as your virtual environment is activated.
|
|
59
|
+
|
|
60
|
+
### CLI Usage
|
|
61
|
+
|
|
62
|
+
You can use the command-line interface directly with the unified entry point:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
storytime story "Tell me a story about a robot"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After generating a story, you will be prompted to choose how to generate illustrations:
|
|
69
|
+
- Use the story as context and describe the image yourself
|
|
70
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
71
|
+
- Skip image generation
|
|
72
|
+
|
|
73
|
+
You can also generate a standalone image:
|
|
74
|
+
```bash
|
|
75
|
+
storytime image "A beautiful sunset over mountains"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Or launch the interactive TUI:
|
|
79
|
+
```bash
|
|
80
|
+
storytime tui
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Tab Completion
|
|
84
|
+
|
|
85
|
+
StoryTime CLI supports tab completion for commands, options, and arguments.
|
|
86
|
+
|
|
87
|
+
### Quick Setup (Automatic)
|
|
88
|
+
|
|
89
|
+
Enable tab completion with:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
storytime --install-completion
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Note:** If you get an error about existing files, use the manual setup below.
|
|
96
|
+
|
|
97
|
+
### Manual Setup
|
|
98
|
+
|
|
99
|
+
If automatic installation doesn't work, you can set up completion manually for your shell:
|
|
100
|
+
|
|
101
|
+
**Bash** (add to `~/.bashrc`):
|
|
102
|
+
```bash
|
|
103
|
+
eval "$(storytime --show-completion)"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Zsh** (add to `~/.zshrc`):
|
|
107
|
+
```bash
|
|
108
|
+
eval "$(storytime --show-completion)"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Fish** (add to `~/.config/fish/config.fish`):
|
|
112
|
+
```bash
|
|
113
|
+
storytime --show-completion | source
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
After adding the line to your shell configuration, restart your terminal or run:
|
|
117
|
+
```bash
|
|
118
|
+
source ~/.bashrc # for bash
|
|
119
|
+
source ~/.zshrc # for zsh
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Using Tab Completion
|
|
123
|
+
|
|
124
|
+
Once enabled, you can use tab completion for:
|
|
125
|
+
|
|
126
|
+
- **Commands**: `storytime <TAB>` shows available commands (`story`, `image`, `tui`)
|
|
127
|
+
- **Options**: `storytime story --<TAB>` shows options like `--output-dir`, `--verbose`, etc.
|
|
128
|
+
- **Help**: Use `storytime <command> --help` to see all available options
|
|
129
|
+
|
|
130
|
+
## Editing and Debugging
|
|
131
|
+
|
|
132
|
+
- All source code is in the `storytime/` package. When editing or adding files, use package imports (e.g., `from storytime.gemini_backend import GeminiBackend`).
|
|
133
|
+
- To add a new backend, create a new file in `storytime/` and implement the `LLMBackend` interface.
|
|
134
|
+
- To debug, you can add print statements or use a debugger in any module in the `storytime/` package.
|
|
135
|
+
- After making changes, rerun the tests with `pytest` to ensure everything works.
|
|
136
|
+
|
|
137
|
+
## Adding New Dependencies
|
|
138
|
+
|
|
139
|
+
- To add a new main (runtime) dependency:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
uv pip install <package>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- To add a new dev (test/tooling) dependency:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
uv pip install --extra dev <package>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- After adding dependencies, uv will update your `pyproject.toml` and `uv.lock` automatically.
|
|
152
|
+
|
|
153
|
+
## Notes
|
|
154
|
+
- Make sure you have a valid `GEMINI_API_KEY` in your environment before running the program.
|
|
155
|
+
- The TUI requires a terminal that supports Textual applications.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: StoryForge
|
|
3
|
+
Version: 0.0.1b1
|
|
4
|
+
Summary: A cli app that generates short stories and AI images from prompts using a language model.
|
|
5
|
+
Author: wom
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: google-genai>=1.23.0
|
|
11
|
+
Requires-Dist: pillow>=11.2.1
|
|
12
|
+
Requires-Dist: textual[syntax]>=0.54.1
|
|
13
|
+
Requires-Dist: textual-dev>=0.00.1
|
|
14
|
+
Requires-Dist: typer>=0.9.0
|
|
15
|
+
Requires-Dist: rich>=13.0.0
|
|
16
|
+
Requires-Dist: platformdirs>=4.2.0
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=8.2.0; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff>=0.12.1; extra == "dev"
|
|
20
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pip>=25.1.1; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# StoryTime
|
|
26
|
+
|
|
27
|
+
StoryTime is a Textual-based terminal application that uses Google's Gemini API to generate short stories and AI-generated images from user prompts. The app provides a simple TUI (Text User Interface) for entering prompts, confirming actions, and viewing results. When a user submits a prompt, the app generates a story and a corresponding image, saving the image to disk with a descriptive filename. The project is designed for creative exploration, rapid prototyping, and as a demonstration of integrating LLMs and generative image models into a modern Python TUI.
|
|
28
|
+
|
|
29
|
+
**Features:**
|
|
30
|
+
- Enter a custom story prompt and generate a short story using LLM.
|
|
31
|
+
- Generate AI image illustrations for your story with flexible options:
|
|
32
|
+
- Use the story as context and describe the image yourself
|
|
33
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
34
|
+
- Skip image generation if desired
|
|
35
|
+
- Save generated images to disk with creative, context-aware filenames.
|
|
36
|
+
- All interactions are handled in a modern, responsive terminal UI.
|
|
37
|
+
- Includes unit tests for core logic and easy setup with uv and pytest.
|
|
38
|
+
|
|
39
|
+
## Setup
|
|
40
|
+
|
|
41
|
+
This project uses [uv](https://github.com/astral-sh/uv) for fast Python virtual environment and dependency management.
|
|
42
|
+
|
|
43
|
+
### 1. Create and activate a virtual environment
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
uv venv .venv
|
|
47
|
+
source .venv/bin/activate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Install all dependencies (including dev dependencies) and the package in editable mode
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or, if you want to use uv:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
uv pip install .[dev]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Running the Unit Tests
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pytest
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or, if not in an activated venv:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
.venv/bin/pytest
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Running the Program
|
|
75
|
+
|
|
76
|
+
After installing in editable mode, run the app with:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
storytime
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This command is available as long as your virtual environment is activated.
|
|
83
|
+
|
|
84
|
+
### CLI Usage
|
|
85
|
+
|
|
86
|
+
You can use the command-line interface directly with the unified entry point:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
storytime story "Tell me a story about a robot"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
After generating a story, you will be prompted to choose how to generate illustrations:
|
|
93
|
+
- Use the story as context and describe the image yourself
|
|
94
|
+
- Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
|
|
95
|
+
- Skip image generation
|
|
96
|
+
|
|
97
|
+
You can also generate a standalone image:
|
|
98
|
+
```bash
|
|
99
|
+
storytime image "A beautiful sunset over mountains"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or launch the interactive TUI:
|
|
103
|
+
```bash
|
|
104
|
+
storytime tui
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Tab Completion
|
|
108
|
+
|
|
109
|
+
StoryTime CLI supports tab completion for commands, options, and arguments.
|
|
110
|
+
|
|
111
|
+
### Quick Setup (Automatic)
|
|
112
|
+
|
|
113
|
+
Enable tab completion with:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
storytime --install-completion
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Note:** If you get an error about existing files, use the manual setup below.
|
|
120
|
+
|
|
121
|
+
### Manual Setup
|
|
122
|
+
|
|
123
|
+
If automatic installation doesn't work, you can set up completion manually for your shell:
|
|
124
|
+
|
|
125
|
+
**Bash** (add to `~/.bashrc`):
|
|
126
|
+
```bash
|
|
127
|
+
eval "$(storytime --show-completion)"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Zsh** (add to `~/.zshrc`):
|
|
131
|
+
```bash
|
|
132
|
+
eval "$(storytime --show-completion)"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Fish** (add to `~/.config/fish/config.fish`):
|
|
136
|
+
```bash
|
|
137
|
+
storytime --show-completion | source
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
After adding the line to your shell configuration, restart your terminal or run:
|
|
141
|
+
```bash
|
|
142
|
+
source ~/.bashrc # for bash
|
|
143
|
+
source ~/.zshrc # for zsh
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Using Tab Completion
|
|
147
|
+
|
|
148
|
+
Once enabled, you can use tab completion for:
|
|
149
|
+
|
|
150
|
+
- **Commands**: `storytime <TAB>` shows available commands (`story`, `image`, `tui`)
|
|
151
|
+
- **Options**: `storytime story --<TAB>` shows options like `--output-dir`, `--verbose`, etc.
|
|
152
|
+
- **Help**: Use `storytime <command> --help` to see all available options
|
|
153
|
+
|
|
154
|
+
## Editing and Debugging
|
|
155
|
+
|
|
156
|
+
- All source code is in the `storytime/` package. When editing or adding files, use package imports (e.g., `from storytime.gemini_backend import GeminiBackend`).
|
|
157
|
+
- To add a new backend, create a new file in `storytime/` and implement the `LLMBackend` interface.
|
|
158
|
+
- To debug, you can add print statements or use a debugger in any module in the `storytime/` package.
|
|
159
|
+
- After making changes, rerun the tests with `pytest` to ensure everything works.
|
|
160
|
+
|
|
161
|
+
## Adding New Dependencies
|
|
162
|
+
|
|
163
|
+
- To add a new main (runtime) dependency:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
uv pip install <package>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- To add a new dev (test/tooling) dependency:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
uv pip install --extra dev <package>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- After adding dependencies, uv will update your `pyproject.toml` and `uv.lock` automatically.
|
|
176
|
+
|
|
177
|
+
## Notes
|
|
178
|
+
- Make sure you have a valid `GEMINI_API_KEY` in your environment before running the program.
|
|
179
|
+
- The TUI requires a terminal that supports Textual applications.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
StoryForge.egg-info/PKG-INFO
|
|
5
|
+
StoryForge.egg-info/SOURCES.txt
|
|
6
|
+
StoryForge.egg-info/dependency_links.txt
|
|
7
|
+
StoryForge.egg-info/entry_points.txt
|
|
8
|
+
StoryForge.egg-info/requires.txt
|
|
9
|
+
StoryForge.egg-info/top_level.txt
|
|
10
|
+
storytime/StoryTime.py
|
|
11
|
+
storytime/__init__.py
|
|
12
|
+
storytime/context.py
|
|
13
|
+
storytime/gemini_backend.py
|
|
14
|
+
storytime/llm_backend.py
|
|
15
|
+
storytime/prompt.py
|
|
16
|
+
tests/test_StoryTime.py
|
|
17
|
+
tests/test_cli_integration.py
|
|
18
|
+
tests/test_context.py
|
|
19
|
+
tests/test_gemini_backend.py
|
|
20
|
+
tests/test_llm_backend.py
|
|
21
|
+
tests/test_prompt.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "StoryForge"
|
|
3
|
+
version = "0.0.1b1"
|
|
4
|
+
description = "A cli app that generates short stories and AI images from prompts using a language model."
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "wom" }
|
|
7
|
+
]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"google-genai>=1.23.0",
|
|
13
|
+
"pillow>=11.2.1",
|
|
14
|
+
"textual[syntax]>=0.54.1",
|
|
15
|
+
"textual-dev>=0.00.1",
|
|
16
|
+
"typer>=0.9.0",
|
|
17
|
+
"rich>=13.0.0",
|
|
18
|
+
"platformdirs>=4.2.0"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest>=8.2.0",
|
|
24
|
+
"ruff>=0.12.1",
|
|
25
|
+
"mypy>=1.8.0",
|
|
26
|
+
"pre-commit>=3.6.0",
|
|
27
|
+
"pip>=25.1.1"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
storytime = "storytime.StoryTime:app"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["setuptools>=45", "wheel"]
|
|
35
|
+
build-backend = "setuptools.build_meta"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
include = ["storytime*"]
|
|
39
|
+
exclude = ["data*", "tests*"]
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
target-version = "py312"
|
|
43
|
+
line-length = 88
|
|
44
|
+
|
|
45
|
+
[tool.ruff.lint]
|
|
46
|
+
select = [
|
|
47
|
+
"E", # pycodestyle errors
|
|
48
|
+
"W", # pycodestyle warnings
|
|
49
|
+
"F", # pyflakes
|
|
50
|
+
"I", # isort
|
|
51
|
+
"B", # flake8-bugbear
|
|
52
|
+
"C4", # flake8-comprehensions
|
|
53
|
+
"UP", # pyupgraDe
|
|
54
|
+
]
|
|
55
|
+
ignore = []
|
|
56
|
+
|
|
57
|
+
[tool.ruff.format]
|
|
58
|
+
quote-style = "double"
|
|
59
|
+
indent-style = "space"
|
|
60
|
+
skip-magic-trailing-comma = false
|
|
61
|
+
line-ending = "auto"
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
python_files = "test_*.py"
|
|
66
|
+
python_classes = "Test*"
|
|
67
|
+
python_functions = "test_*"
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
python_version = "3.12"
|
|
71
|
+
warn_return_any = true
|
|
72
|
+
warn_unused_configs = true
|
|
73
|
+
# Start with basic checks, can be made stricter later
|
|
74
|
+
disallow_untyped_defs = false
|
|
75
|
+
disallow_incomplete_defs = false
|
|
76
|
+
check_untyped_defs = true
|
|
77
|
+
disallow_untyped_decorators = false
|
|
78
|
+
no_implicit_optional = true
|
|
79
|
+
warn_redundant_casts = true
|
|
80
|
+
warn_unused_ignores = true
|
|
81
|
+
warn_no_return = true
|
|
82
|
+
warn_unreachable = true
|
|
83
|
+
strict_equality = true
|
|
84
|
+
show_error_codes = true
|
|
85
|
+
|
|
86
|
+
# Ignore third-party libraries without type stubs
|
|
87
|
+
[[tool.mypy.overrides]]
|
|
88
|
+
module = [
|
|
89
|
+
"google.*",
|
|
90
|
+
"textual.*",
|
|
91
|
+
"PIL.*",
|
|
92
|
+
]
|
|
93
|
+
ignore_missing_imports = true
|
|
94
|
+
|
|
95
|
+
# Allow gradual adoption for tests
|
|
96
|
+
[[tool.mypy.overrides]]
|
|
97
|
+
module = [
|
|
98
|
+
"tests.*",
|
|
99
|
+
]
|
|
100
|
+
disallow_untyped_defs = false
|
|
101
|
+
disallow_incomplete_defs = false
|
|
102
|
+
ignore_errors = true
|