convoviz 0.2.14__tar.gz → 0.3.0__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.
Files changed (61) hide show
  1. {convoviz-0.2.14 → convoviz-0.3.0}/PKG-INFO +22 -24
  2. {convoviz-0.2.14 → convoviz-0.3.0}/README.md +21 -23
  3. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/cli.py +9 -1
  4. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/config.py +13 -0
  5. convoviz-0.3.0/convoviz/interactive.py +255 -0
  6. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/pipeline.py +68 -71
  7. {convoviz-0.2.14 → convoviz-0.3.0}/pyproject.toml +1 -1
  8. convoviz-0.2.14/convoviz/interactive.py +0 -232
  9. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/__init__.py +0 -0
  10. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/__main__.py +0 -0
  11. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/analysis/__init__.py +0 -0
  12. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/analysis/graphs.py +0 -0
  13. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/analysis/wordcloud.py +0 -0
  14. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/colormaps.txt +0 -0
  15. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/AmaticSC-Regular.ttf +0 -0
  16. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/ArchitectsDaughter-Regular.ttf +0 -0
  17. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/BebasNeue-Regular.ttf +0 -0
  18. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Borel-Regular.ttf +0 -0
  19. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Courgette-Regular.ttf +0 -0
  20. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/CroissantOne-Regular.ttf +0 -0
  21. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Handjet-Regular.ttf +0 -0
  22. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/IndieFlower-Regular.ttf +0 -0
  23. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Kalam-Regular.ttf +0 -0
  24. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Lobster-Regular.ttf +0 -0
  25. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/MartianMono-Regular.ttf +0 -0
  26. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/MartianMono-Thin.ttf +0 -0
  27. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Montserrat-Regular.ttf +0 -0
  28. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Mooli-Regular.ttf +0 -0
  29. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Pacifico-Regular.ttf +0 -0
  30. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/PlayfairDisplay-Regular.ttf +0 -0
  31. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Raleway-Regular.ttf +0 -0
  32. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/RobotoMono-Regular.ttf +0 -0
  33. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/RobotoMono-Thin.ttf +0 -0
  34. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/RobotoSlab-Regular.ttf +0 -0
  35. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/RobotoSlab-Thin.ttf +0 -0
  36. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Ruwudu-Regular.ttf +0 -0
  37. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Sacramento-Regular.ttf +0 -0
  38. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/SedgwickAveDisplay-Regular.ttf +0 -0
  39. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/ShadowsIntoLight-Regular.ttf +0 -0
  40. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/TitilliumWeb-Regular.ttf +0 -0
  41. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Yellowtail-Regular.ttf +0 -0
  42. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/YsabeauOffice-Regular.ttf +0 -0
  43. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/YsabeauSC-Regular.ttf +0 -0
  44. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/YsabeauSC-Thin.ttf +0 -0
  45. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/fonts/Zeyada-Regular.ttf +0 -0
  46. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/assets/stopwords.txt +0 -0
  47. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/exceptions.py +0 -0
  48. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/io/__init__.py +0 -0
  49. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/io/assets.py +0 -0
  50. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/io/loaders.py +0 -0
  51. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/io/writers.py +0 -0
  52. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/models/__init__.py +0 -0
  53. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/models/collection.py +0 -0
  54. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/models/conversation.py +0 -0
  55. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/models/message.py +0 -0
  56. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/models/node.py +0 -0
  57. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/py.typed +0 -0
  58. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/renderers/__init__.py +0 -0
  59. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/renderers/markdown.py +0 -0
  60. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/renderers/yaml.py +0 -0
  61. {convoviz-0.2.14 → convoviz-0.3.0}/convoviz/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: convoviz
3
- Version: 0.2.14
3
+ Version: 0.3.0
4
4
  Summary: Get analytics and visualizations on your ChatGPT data!
5
5
  Keywords: markdown,chatgpt,openai,visualization,analytics,json,export,data-analysis,obsidian
6
6
  Author: Mohamed Cheikh Sidiya
@@ -82,9 +82,28 @@ You can provide arguments directly to skip the prompts:
82
82
  convoviz --input path/to/your/export.zip --output path/to/output/folder
83
83
  ```
84
84
 
85
- Notes:
85
+ ##### Selective Output Generation
86
+
87
+ By default, Convoviz generates all outputs (Markdown files, graphs, and word clouds). You can select specific outputs using the `--outputs` flag:
88
+
89
+ ```bash
90
+ # Generate only Markdown files (fastest)
91
+ convoviz --input export.zip --outputs markdown
92
+
93
+ # Generate Markdown and graphs (no word clouds)
94
+ convoviz --input export.zip --outputs markdown --outputs graphs
95
+
96
+ # Generate all outputs (default behavior)
97
+ convoviz --input export.zip --outputs markdown --outputs graphs --outputs wordclouds
98
+ ```
99
+
100
+ In interactive mode, you'll be prompted to select which outputs to generate.
101
+
102
+ ##### Other Notes
103
+
86
104
  - `--zip` / `-z` is kept as an alias for `--input` for convenience.
87
105
  - You can force non-interactive mode with `--no-interactive`.
106
+ - Use `--flat` to put all Markdown files in a single folder instead of organizing by date.
88
107
 
89
108
  For more options, run:
90
109
 
@@ -96,31 +115,13 @@ convoviz --help
96
115
 
97
116
  And that's it! After running the script, head over to the output folder to see your neatly formatted Markdown files and visualizations.
98
117
 
99
- The main outputs are:
100
-
101
- - **`Markdown/`**: one `.md` file per conversation
102
- - **`Graphs/`**: a small set of high-signal plots, including:
103
- - `overview.png` (dashboard)
104
- - `activity_heatmap.png` (weekday × hour)
105
- - `daily_activity.png` / `monthly_activity.png`
106
- - `model_usage.png`, `conversation_lengths.png`
107
- - `weekday_pattern.png`, `hourly_pattern.png`, `conversation_lifetimes.png`
108
- - **`Word-Clouds/`**: weekly/monthly/yearly word clouds
109
- - **`custom_instructions.json`**: extracted custom instructions
110
-
111
118
  ![wordcloud example](demo/wordcloud-example.png)
112
119
 
113
120
  ## Share Your Feedback! 💌
114
121
 
115
122
  I hope you find this tool useful. I'm continuously looking to improve on this, but I need your help for that.
116
123
 
117
- Whether you're a tech wizard or you're new to all this, I'd love to hear about your journey with the tool. Found a quirk? Have a suggestion? Or just want to send some good vibes? I'm all ears!
118
-
119
- **Here's how you can share your thoughts:**
120
-
121
- 1. **GitHub Issues**: For more specific feedback or if you've stumbled upon a bug, please open an [issue](https://github.com/mohamed-chs/chatgpt-history-export-to-md/issues). This helps me track and address them effectively.
122
-
123
- 2. **GitHub Discussions**: If you just want to share your general experience, have a suggestion, or maybe a cool idea for a new feature, jump into the [discussions](https://github.com/mohamed-chs/chatgpt-history-export-to-md/discussions) page. It's a more casual space where we can chat.
124
+ Whether you're a tech wizard or you're new to all this, I'd love to hear about your journey with the tool. Found a quirk? Have a suggestion? Or just want to send some good vibes? I'm all ears! (see [issues](https://github.com/mohamed-chs/chatgpt-history-export-to-md/issues))
124
125
 
125
126
  And if you've had a great experience, consider giving the project a star ⭐. It keeps me motivated and helps others discover it!
126
127
 
@@ -128,9 +129,6 @@ And if you've had a great experience, consider giving the project a star ⭐. It
128
129
 
129
130
  This is just a small thing I coded to help me see my convos in beautiful markdown. It was originally built with [Obsidian](https://obsidian.md/) (my go-to note-taking app) in mind, but the default output is standard Markdown.
130
131
 
131
- You can choose obsidian flavored md in the cli to get extra features like:
132
- - model reasoning (`reasoning_recap`, `thoughts`) rendered as collapsible `> [!NOTE]-` callouts instead of being hidden.
133
-
134
132
  I wasn't a fan of the clunky, and sometimes paid, browser extensions.
135
133
 
136
134
  It was also a great opportunity to learn more about Python and type annotations. I had mypy, pyright, and ruff all on strict mode, 'twas fun.
@@ -56,9 +56,28 @@ You can provide arguments directly to skip the prompts:
56
56
  convoviz --input path/to/your/export.zip --output path/to/output/folder
57
57
  ```
58
58
 
59
- Notes:
59
+ ##### Selective Output Generation
60
+
61
+ By default, Convoviz generates all outputs (Markdown files, graphs, and word clouds). You can select specific outputs using the `--outputs` flag:
62
+
63
+ ```bash
64
+ # Generate only Markdown files (fastest)
65
+ convoviz --input export.zip --outputs markdown
66
+
67
+ # Generate Markdown and graphs (no word clouds)
68
+ convoviz --input export.zip --outputs markdown --outputs graphs
69
+
70
+ # Generate all outputs (default behavior)
71
+ convoviz --input export.zip --outputs markdown --outputs graphs --outputs wordclouds
72
+ ```
73
+
74
+ In interactive mode, you'll be prompted to select which outputs to generate.
75
+
76
+ ##### Other Notes
77
+
60
78
  - `--zip` / `-z` is kept as an alias for `--input` for convenience.
61
79
  - You can force non-interactive mode with `--no-interactive`.
80
+ - Use `--flat` to put all Markdown files in a single folder instead of organizing by date.
62
81
 
63
82
  For more options, run:
64
83
 
@@ -70,31 +89,13 @@ convoviz --help
70
89
 
71
90
  And that's it! After running the script, head over to the output folder to see your neatly formatted Markdown files and visualizations.
72
91
 
73
- The main outputs are:
74
-
75
- - **`Markdown/`**: one `.md` file per conversation
76
- - **`Graphs/`**: a small set of high-signal plots, including:
77
- - `overview.png` (dashboard)
78
- - `activity_heatmap.png` (weekday × hour)
79
- - `daily_activity.png` / `monthly_activity.png`
80
- - `model_usage.png`, `conversation_lengths.png`
81
- - `weekday_pattern.png`, `hourly_pattern.png`, `conversation_lifetimes.png`
82
- - **`Word-Clouds/`**: weekly/monthly/yearly word clouds
83
- - **`custom_instructions.json`**: extracted custom instructions
84
-
85
92
  ![wordcloud example](demo/wordcloud-example.png)
86
93
 
87
94
  ## Share Your Feedback! 💌
88
95
 
89
96
  I hope you find this tool useful. I'm continuously looking to improve on this, but I need your help for that.
90
97
 
91
- Whether you're a tech wizard or you're new to all this, I'd love to hear about your journey with the tool. Found a quirk? Have a suggestion? Or just want to send some good vibes? I'm all ears!
92
-
93
- **Here's how you can share your thoughts:**
94
-
95
- 1. **GitHub Issues**: For more specific feedback or if you've stumbled upon a bug, please open an [issue](https://github.com/mohamed-chs/chatgpt-history-export-to-md/issues). This helps me track and address them effectively.
96
-
97
- 2. **GitHub Discussions**: If you just want to share your general experience, have a suggestion, or maybe a cool idea for a new feature, jump into the [discussions](https://github.com/mohamed-chs/chatgpt-history-export-to-md/discussions) page. It's a more casual space where we can chat.
98
+ Whether you're a tech wizard or you're new to all this, I'd love to hear about your journey with the tool. Found a quirk? Have a suggestion? Or just want to send some good vibes? I'm all ears! (see [issues](https://github.com/mohamed-chs/chatgpt-history-export-to-md/issues))
98
99
 
99
100
  And if you've had a great experience, consider giving the project a star ⭐. It keeps me motivated and helps others discover it!
100
101
 
@@ -102,9 +103,6 @@ And if you've had a great experience, consider giving the project a star ⭐. It
102
103
 
103
104
  This is just a small thing I coded to help me see my convos in beautiful markdown. It was originally built with [Obsidian](https://obsidian.md/) (my go-to note-taking app) in mind, but the default output is standard Markdown.
104
105
 
105
- You can choose obsidian flavored md in the cli to get extra features like:
106
- - model reasoning (`reasoning_recap`, `thoughts`) rendered as collapsible `> [!NOTE]-` callouts instead of being hidden.
107
-
108
106
  I wasn't a fan of the clunky, and sometimes paid, browser extensions.
109
107
 
110
108
  It was also a great opportunity to learn more about Python and type annotations. I had mypy, pyright, and ruff all on strict mode, 'twas fun.
@@ -5,7 +5,7 @@ from pathlib import Path
5
5
  import typer
6
6
  from rich.console import Console
7
7
 
8
- from convoviz.config import FolderOrganization, get_default_config
8
+ from convoviz.config import FolderOrganization, OutputKind, get_default_config
9
9
  from convoviz.exceptions import ConfigurationError, InvalidZipError
10
10
  from convoviz.interactive import run_interactive_config
11
11
  from convoviz.io.loaders import find_latest_zip
@@ -38,6 +38,12 @@ def run(
38
38
  "-o",
39
39
  help="Path to the output directory.",
40
40
  ),
41
+ outputs: list[OutputKind] | None = typer.Option(
42
+ None,
43
+ "--outputs",
44
+ help="Output types to generate (repeatable). Options: markdown, graphs, wordclouds. "
45
+ "If not specified, all outputs are generated.",
46
+ ),
41
47
  flat: bool = typer.Option(
42
48
  False,
43
49
  "--flat",
@@ -63,6 +69,8 @@ def run(
63
69
  config.input_path = input_path
64
70
  if output_dir:
65
71
  config.output_folder = output_dir
72
+ if outputs:
73
+ config.outputs = set(outputs)
66
74
  if flat:
67
75
  config.folder_organization = FolderOrganization.FLAT
68
76
 
@@ -14,6 +14,18 @@ class FolderOrganization(str, Enum):
14
14
  DATE = "date" # Nested by year/month (default)
15
15
 
16
16
 
17
+ class OutputKind(str, Enum):
18
+ """Types of outputs that can be generated."""
19
+
20
+ MARKDOWN = "markdown" # Conversation markdown files
21
+ GRAPHS = "graphs" # Usage analytics graphs
22
+ WORDCLOUDS = "wordclouds" # Word cloud visualizations
23
+
24
+
25
+ # Default: generate all outputs
26
+ ALL_OUTPUTS: frozenset[OutputKind] = frozenset(OutputKind)
27
+
28
+
17
29
  class AuthorHeaders(BaseModel):
18
30
  """Headers for different message authors in markdown output."""
19
31
 
@@ -93,6 +105,7 @@ class ConvovizConfig(BaseModel):
93
105
  input_path: Path | None = None
94
106
  output_folder: Path = Field(default_factory=lambda: Path.home() / "Documents" / "ChatGPT-Data")
95
107
  folder_organization: FolderOrganization = FolderOrganization.DATE
108
+ outputs: set[OutputKind] = Field(default_factory=lambda: set(ALL_OUTPUTS))
96
109
  message: MessageConfig = Field(default_factory=MessageConfig)
97
110
  conversation: ConversationConfig = Field(default_factory=ConversationConfig)
98
111
  wordcloud: WordCloudConfig = Field(default_factory=WordCloudConfig)
@@ -0,0 +1,255 @@
1
+ """Interactive configuration prompts using questionary."""
2
+
3
+ from pathlib import Path
4
+ from typing import Literal, Protocol, cast
5
+
6
+ from questionary import Choice, Style, checkbox, select
7
+ from questionary import path as qst_path
8
+ from questionary import text as qst_text
9
+
10
+ from convoviz.config import ConvovizConfig, OutputKind, get_default_config
11
+ from convoviz.io.loaders import find_latest_zip, validate_zip
12
+ from convoviz.utils import colormaps, default_font_path, font_names, font_path, validate_header
13
+
14
+ CUSTOM_STYLE = Style(
15
+ [
16
+ ("qmark", "fg:#34eb9b bold"),
17
+ ("question", "bold fg:#e0e0e0"),
18
+ ("answer", "fg:#34ebeb bold"),
19
+ ("pointer", "fg:#e834eb bold"),
20
+ ("highlighted", "fg:#349ceb bold"),
21
+ ("selected", "fg:#34ebeb"),
22
+ ("separator", "fg:#eb3434"),
23
+ ("instruction", "fg:#eb9434"),
24
+ ("text", "fg:#b2eb34"),
25
+ ("disabled", "fg:#858585 italic"),
26
+ ]
27
+ )
28
+
29
+
30
+ class _QuestionaryPrompt[T](Protocol):
31
+ def ask(self) -> T | None: ...
32
+
33
+
34
+ def _ask_or_cancel[T](prompt: _QuestionaryPrompt[T]) -> T:
35
+ """Ask a questionary prompt; treat Ctrl+C/Ctrl+D as cancelling the run.
36
+
37
+ questionary's `.ask()` returns `None` on cancellation (Ctrl+C / Ctrl+D). We
38
+ convert that to `KeyboardInterrupt` so callers can abort the whole
39
+ interactive session with a single Ctrl+C.
40
+ """
41
+
42
+ result = prompt.ask()
43
+ if result is None:
44
+ raise KeyboardInterrupt
45
+ return result
46
+
47
+
48
+ def _validate_input_path(raw: str) -> bool | str:
49
+ path = Path(raw)
50
+ if not path.exists():
51
+ return "Path must exist"
52
+
53
+ if path.is_dir():
54
+ if (path / "conversations.json").exists():
55
+ return True
56
+ return "Directory must contain conversations.json"
57
+
58
+ if path.suffix.lower() == ".json":
59
+ return True
60
+
61
+ if path.suffix.lower() == ".zip":
62
+ return True if validate_zip(path) else "ZIP must contain conversations.json"
63
+
64
+ return "Input must be a .zip, a .json, or a directory containing conversations.json"
65
+
66
+
67
+ def run_interactive_config(initial_config: ConvovizConfig | None = None) -> ConvovizConfig:
68
+ """Run interactive prompts to configure convoviz.
69
+
70
+ Args:
71
+ initial_config: Optional starting configuration (uses defaults if None)
72
+
73
+ Returns:
74
+ Updated configuration based on user input
75
+ """
76
+ config = initial_config or get_default_config()
77
+
78
+ # Set sensible defaults if not already set
79
+ if not config.input_path:
80
+ latest = find_latest_zip()
81
+ if latest:
82
+ config.input_path = latest
83
+
84
+ if not config.wordcloud.font_path:
85
+ config.wordcloud.font_path = default_font_path()
86
+
87
+ # Prompt for input path
88
+ input_default = str(config.input_path) if config.input_path else ""
89
+ input_result: str = _ask_or_cancel(
90
+ qst_path(
91
+ "Enter the path to the export ZIP, conversations JSON, or extracted directory:",
92
+ default=input_default,
93
+ validate=_validate_input_path,
94
+ style=CUSTOM_STYLE,
95
+ )
96
+ )
97
+
98
+ if input_result:
99
+ config.input_path = Path(input_result)
100
+
101
+ # Prompt for output folder
102
+ output_result: str = _ask_or_cancel(
103
+ qst_path(
104
+ "Enter the path to the output folder:",
105
+ default=str(config.output_folder),
106
+ style=CUSTOM_STYLE,
107
+ )
108
+ )
109
+
110
+ if output_result:
111
+ config.output_folder = Path(output_result)
112
+
113
+ # Prompt for outputs to generate
114
+ output_choices = [
115
+ Choice(title="Markdown conversations", value=OutputKind.MARKDOWN, checked=True),
116
+ Choice(title="Graphs (usage analytics)", value=OutputKind.GRAPHS, checked=True),
117
+ Choice(title="Word clouds", value=OutputKind.WORDCLOUDS, checked=True),
118
+ ]
119
+
120
+ selected_outputs: list[OutputKind] = _ask_or_cancel(
121
+ checkbox(
122
+ "Select outputs to generate:",
123
+ choices=output_choices,
124
+ style=CUSTOM_STYLE,
125
+ )
126
+ )
127
+
128
+ config.outputs = set(selected_outputs) if selected_outputs else set()
129
+
130
+ # Prompt for markdown settings (only if markdown output is selected)
131
+ if OutputKind.MARKDOWN in config.outputs:
132
+ # Prompt for author headers
133
+ headers = config.message.author_headers
134
+ for role in ["user", "assistant"]:
135
+ current = getattr(headers, role)
136
+ result: str = _ask_or_cancel(
137
+ qst_text(
138
+ f"Enter the message header for '{role}':",
139
+ default=current,
140
+ validate=lambda t: validate_header(t)
141
+ or "Must be a valid markdown header (e.g., # Title)",
142
+ style=CUSTOM_STYLE,
143
+ )
144
+ )
145
+ if result:
146
+ setattr(headers, role, result)
147
+
148
+ # Prompt for markdown flavor
149
+ flavor_result = cast(
150
+ Literal["standard", "obsidian"],
151
+ _ask_or_cancel(
152
+ select(
153
+ "Select the markdown flavor:",
154
+ choices=["standard", "obsidian"],
155
+ default=config.conversation.markdown.flavor,
156
+ style=CUSTOM_STYLE,
157
+ )
158
+ ),
159
+ )
160
+
161
+ if flavor_result:
162
+ config.conversation.markdown.flavor = flavor_result
163
+
164
+ # Prompt for YAML headers
165
+ yaml_config = config.conversation.yaml
166
+ yaml_choices = [
167
+ Choice(title=field, checked=getattr(yaml_config, field))
168
+ for field in [
169
+ "title",
170
+ "tags",
171
+ "chat_link",
172
+ "create_time",
173
+ "update_time",
174
+ "model",
175
+ "used_plugins",
176
+ "message_count",
177
+ "content_types",
178
+ "custom_instructions",
179
+ ]
180
+ ]
181
+
182
+ selected: list[str] = _ask_or_cancel(
183
+ checkbox(
184
+ "Select YAML metadata headers to include:",
185
+ choices=yaml_choices,
186
+ style=CUSTOM_STYLE,
187
+ )
188
+ )
189
+
190
+ selected_set = set(selected)
191
+ for field_name in [
192
+ "title",
193
+ "tags",
194
+ "chat_link",
195
+ "create_time",
196
+ "update_time",
197
+ "model",
198
+ "used_plugins",
199
+ "message_count",
200
+ "content_types",
201
+ "custom_instructions",
202
+ ]:
203
+ setattr(yaml_config, field_name, field_name in selected_set)
204
+
205
+ # Prompt for wordcloud settings (only if wordclouds output is selected)
206
+ if OutputKind.WORDCLOUDS in config.outputs:
207
+ # Prompt for font
208
+ available_fonts = font_names()
209
+ if available_fonts:
210
+ current_font = (
211
+ config.wordcloud.font_path.stem
212
+ if config.wordcloud.font_path
213
+ else available_fonts[0]
214
+ )
215
+ font_result: str = _ask_or_cancel(
216
+ select(
217
+ "Select the font for word clouds:",
218
+ choices=available_fonts,
219
+ default=current_font if current_font in available_fonts else available_fonts[0],
220
+ style=CUSTOM_STYLE,
221
+ )
222
+ )
223
+
224
+ if font_result:
225
+ config.wordcloud.font_path = font_path(font_result)
226
+
227
+ # Prompt for colormap
228
+ available_colormaps = colormaps()
229
+ if available_colormaps:
230
+ colormap_result: str = _ask_or_cancel(
231
+ select(
232
+ "Select the color theme for word clouds:",
233
+ choices=available_colormaps,
234
+ default=config.wordcloud.colormap
235
+ if config.wordcloud.colormap in available_colormaps
236
+ else available_colormaps[0],
237
+ style=CUSTOM_STYLE,
238
+ )
239
+ )
240
+
241
+ if colormap_result:
242
+ config.wordcloud.colormap = colormap_result
243
+
244
+ # Prompt for custom stopwords
245
+ stopwords_result: str = _ask_or_cancel(
246
+ qst_text(
247
+ "Enter custom stopwords (comma-separated):",
248
+ default=config.wordcloud.custom_stopwords,
249
+ style=CUSTOM_STYLE,
250
+ )
251
+ )
252
+
253
+ config.wordcloud.custom_stopwords = stopwords_result
254
+
255
+ return config
@@ -5,16 +5,14 @@ from shutil import rmtree
5
5
 
6
6
  from rich.console import Console
7
7
 
8
- from convoviz.analysis.graphs import generate_graphs
9
- from convoviz.analysis.wordcloud import generate_wordclouds
10
- from convoviz.config import ConvovizConfig
8
+ from convoviz.config import ConvovizConfig, OutputKind
11
9
  from convoviz.exceptions import InvalidZipError
12
10
  from convoviz.io.loaders import (
13
11
  find_latest_bookmarklet_json,
14
12
  load_collection_from_json,
15
13
  load_collection_from_zip,
16
14
  )
17
- from convoviz.io.writers import save_collection, save_custom_instructions
15
+ from convoviz.io.writers import save_collection
18
16
 
19
17
  console = Console()
20
18
 
@@ -80,10 +78,21 @@ def run_pipeline(config: ConvovizConfig) -> None:
80
78
  output_folder = config.output_folder
81
79
  output_folder.mkdir(parents=True, exist_ok=True)
82
80
 
83
- # Clean only specific sub-directories we manage
84
- managed_dirs = ["Markdown", "Graphs", "Word-Clouds"]
85
- for d in managed_dirs:
86
- sub_dir = output_folder / d
81
+ # Determine which outputs are selected
82
+ selected_outputs = config.outputs
83
+
84
+ # Build mapping of output kind -> directory name
85
+ output_dir_map: dict[OutputKind, str] = {
86
+ OutputKind.MARKDOWN: "Markdown",
87
+ OutputKind.GRAPHS: "Graphs",
88
+ OutputKind.WORDCLOUDS: "Word-Clouds",
89
+ }
90
+
91
+ # Clean only specific sub-directories we manage (only for selected outputs)
92
+ for output_kind, dir_name in output_dir_map.items():
93
+ if output_kind not in selected_outputs:
94
+ continue
95
+ sub_dir = output_folder / dir_name
87
96
  if sub_dir.exists():
88
97
  # Never follow symlinks; just unlink them.
89
98
  if sub_dir.is_symlink():
@@ -94,69 +103,57 @@ def run_pipeline(config: ConvovizConfig) -> None:
94
103
  sub_dir.unlink()
95
104
  sub_dir.mkdir(exist_ok=True)
96
105
 
97
- # Clean specific files we manage
98
- managed_files = ["custom_instructions.json"]
99
- for f in managed_files:
100
- managed_file = output_folder / f
101
- if managed_file.exists():
102
- if managed_file.is_symlink() or managed_file.is_file():
103
- managed_file.unlink()
104
- elif managed_file.is_dir():
105
- rmtree(managed_file)
106
- else:
107
- managed_file.unlink()
108
-
109
- # Save markdown files
110
- markdown_folder = output_folder / "Markdown"
111
- save_collection(
112
- collection,
113
- markdown_folder,
114
- config.conversation,
115
- config.message.author_headers,
116
- folder_organization=config.folder_organization,
117
- progress_bar=True,
118
- )
119
- console.print(
120
- f"\nDone [bold green]✅[/bold green] ! "
121
- f"Check the output [bold blue]📄[/bold blue] here: {_safe_uri(markdown_folder)} 🔗\n"
122
- )
123
-
124
- # Generate graphs
125
- graph_folder = output_folder / "Graphs"
126
- graph_folder.mkdir(parents=True, exist_ok=True)
127
- generate_graphs(
128
- collection,
129
- graph_folder,
130
- config.graph,
131
- progress_bar=True,
132
- )
133
- console.print(
134
- f"\nDone [bold green]✅[/bold green] ! "
135
- f"Check the output [bold blue]📈[/bold blue] here: {_safe_uri(graph_folder)} 🔗\n"
136
- )
137
-
138
- # Generate word clouds
139
- wordcloud_folder = output_folder / "Word-Clouds"
140
- wordcloud_folder.mkdir(parents=True, exist_ok=True)
141
- generate_wordclouds(
142
- collection,
143
- wordcloud_folder,
144
- config.wordcloud,
145
- progress_bar=True,
146
- )
147
- console.print(
148
- f"\nDone [bold green]✅[/bold green] ! "
149
- f"Check the output [bold blue]🔡☁️[/bold blue] here: {_safe_uri(wordcloud_folder)} 🔗\n"
150
- )
151
-
152
- # Save custom instructions
153
- console.print("Writing custom instructions [bold blue]📝[/bold blue] ...\n")
154
- instructions_path = output_folder / "custom_instructions.json"
155
- save_custom_instructions(collection, instructions_path)
156
- console.print(
157
- f"\nDone [bold green]✅[/bold green] ! "
158
- f"Check the output [bold blue]📝[/bold blue] here: {_safe_uri(instructions_path)} 🔗\n"
159
- )
106
+ # Save markdown files (if selected)
107
+ if OutputKind.MARKDOWN in selected_outputs:
108
+ markdown_folder = output_folder / "Markdown"
109
+ save_collection(
110
+ collection,
111
+ markdown_folder,
112
+ config.conversation,
113
+ config.message.author_headers,
114
+ folder_organization=config.folder_organization,
115
+ progress_bar=True,
116
+ )
117
+ console.print(
118
+ f"\nDone [bold green]✅[/bold green] ! "
119
+ f"Check the output [bold blue]📄[/bold blue] here: {_safe_uri(markdown_folder)} 🔗\n"
120
+ )
121
+
122
+ # Generate graphs (if selected)
123
+ if OutputKind.GRAPHS in selected_outputs:
124
+ # Lazy import to allow markdown-only usage without matplotlib
125
+ from convoviz.analysis.graphs import generate_graphs
126
+
127
+ graph_folder = output_folder / "Graphs"
128
+ graph_folder.mkdir(parents=True, exist_ok=True)
129
+ generate_graphs(
130
+ collection,
131
+ graph_folder,
132
+ config.graph,
133
+ progress_bar=True,
134
+ )
135
+ console.print(
136
+ f"\nDone [bold green]✅[/bold green] ! "
137
+ f"Check the output [bold blue]📈[/bold blue] here: {_safe_uri(graph_folder)} 🔗\n"
138
+ )
139
+
140
+ # Generate word clouds (if selected)
141
+ if OutputKind.WORDCLOUDS in selected_outputs:
142
+ # Lazy import to allow markdown-only usage without wordcloud/nltk
143
+ from convoviz.analysis.wordcloud import generate_wordclouds
144
+
145
+ wordcloud_folder = output_folder / "Word-Clouds"
146
+ wordcloud_folder.mkdir(parents=True, exist_ok=True)
147
+ generate_wordclouds(
148
+ collection,
149
+ wordcloud_folder,
150
+ config.wordcloud,
151
+ progress_bar=True,
152
+ )
153
+ console.print(
154
+ f"\nDone [bold green]✅[/bold green] ! "
155
+ f"Check the output [bold blue]🔡☁️[/bold blue] here: {_safe_uri(wordcloud_folder)} 🔗\n"
156
+ )
160
157
 
161
158
  console.print(
162
159
  "ALL DONE [bold green]🎉🎉🎉[/bold green] !\n\n"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "convoviz"
3
- version = "0.2.14"
3
+ version = "0.3.0"
4
4
  description = "Get analytics and visualizations on your ChatGPT data!"
5
5
  license = "MIT"
6
6
  keywords = [
@@ -1,232 +0,0 @@
1
- """Interactive configuration prompts using questionary."""
2
-
3
- from pathlib import Path
4
- from typing import Literal, Protocol, cast
5
-
6
- from questionary import Choice, Style, checkbox, select
7
- from questionary import path as qst_path
8
- from questionary import text as qst_text
9
-
10
- from convoviz.config import ConvovizConfig, get_default_config
11
- from convoviz.io.loaders import find_latest_zip, validate_zip
12
- from convoviz.utils import colormaps, default_font_path, font_names, font_path, validate_header
13
-
14
- CUSTOM_STYLE = Style(
15
- [
16
- ("qmark", "fg:#34eb9b bold"),
17
- ("question", "bold fg:#e0e0e0"),
18
- ("answer", "fg:#34ebeb bold"),
19
- ("pointer", "fg:#e834eb bold"),
20
- ("highlighted", "fg:#349ceb bold"),
21
- ("selected", "fg:#34ebeb"),
22
- ("separator", "fg:#eb3434"),
23
- ("instruction", "fg:#eb9434"),
24
- ("text", "fg:#b2eb34"),
25
- ("disabled", "fg:#858585 italic"),
26
- ]
27
- )
28
-
29
-
30
- class _QuestionaryPrompt[T](Protocol):
31
- def ask(self) -> T | None: ...
32
-
33
-
34
- def _ask_or_cancel[T](prompt: _QuestionaryPrompt[T]) -> T:
35
- """Ask a questionary prompt; treat Ctrl+C/Ctrl+D as cancelling the run.
36
-
37
- questionary's `.ask()` returns `None` on cancellation (Ctrl+C / Ctrl+D). We
38
- convert that to `KeyboardInterrupt` so callers can abort the whole
39
- interactive session with a single Ctrl+C.
40
- """
41
-
42
- result = prompt.ask()
43
- if result is None:
44
- raise KeyboardInterrupt
45
- return result
46
-
47
-
48
- def _validate_input_path(raw: str) -> bool | str:
49
- path = Path(raw)
50
- if not path.exists():
51
- return "Path must exist"
52
-
53
- if path.is_dir():
54
- if (path / "conversations.json").exists():
55
- return True
56
- return "Directory must contain conversations.json"
57
-
58
- if path.suffix.lower() == ".json":
59
- return True
60
-
61
- if path.suffix.lower() == ".zip":
62
- return True if validate_zip(path) else "ZIP must contain conversations.json"
63
-
64
- return "Input must be a .zip, a .json, or a directory containing conversations.json"
65
-
66
-
67
- def run_interactive_config(initial_config: ConvovizConfig | None = None) -> ConvovizConfig:
68
- """Run interactive prompts to configure convoviz.
69
-
70
- Args:
71
- initial_config: Optional starting configuration (uses defaults if None)
72
-
73
- Returns:
74
- Updated configuration based on user input
75
- """
76
- config = initial_config or get_default_config()
77
-
78
- # Set sensible defaults if not already set
79
- if not config.input_path:
80
- latest = find_latest_zip()
81
- if latest:
82
- config.input_path = latest
83
-
84
- if not config.wordcloud.font_path:
85
- config.wordcloud.font_path = default_font_path()
86
-
87
- # Prompt for input path
88
- input_default = str(config.input_path) if config.input_path else ""
89
- input_result: str = _ask_or_cancel(
90
- qst_path(
91
- "Enter the path to the export ZIP, conversations JSON, or extracted directory:",
92
- default=input_default,
93
- validate=_validate_input_path,
94
- style=CUSTOM_STYLE,
95
- )
96
- )
97
-
98
- if input_result:
99
- config.input_path = Path(input_result)
100
-
101
- # Prompt for output folder
102
- output_result: str = _ask_or_cancel(
103
- qst_path(
104
- "Enter the path to the output folder:",
105
- default=str(config.output_folder),
106
- style=CUSTOM_STYLE,
107
- )
108
- )
109
-
110
- if output_result:
111
- config.output_folder = Path(output_result)
112
-
113
- # Prompt for author headers
114
- headers = config.message.author_headers
115
- for role in ["user", "assistant"]:
116
- current = getattr(headers, role)
117
- result: str = _ask_or_cancel(
118
- qst_text(
119
- f"Enter the message header for '{role}':",
120
- default=current,
121
- validate=lambda t: validate_header(t)
122
- or "Must be a valid markdown header (e.g., # Title)",
123
- style=CUSTOM_STYLE,
124
- )
125
- )
126
- if result:
127
- setattr(headers, role, result)
128
-
129
- # Prompt for markdown flavor
130
- flavor_result = cast(
131
- Literal["standard", "obsidian"],
132
- _ask_or_cancel(
133
- select(
134
- "Select the markdown flavor:",
135
- choices=["standard", "obsidian"],
136
- default=config.conversation.markdown.flavor,
137
- style=CUSTOM_STYLE,
138
- )
139
- ),
140
- )
141
-
142
- if flavor_result:
143
- config.conversation.markdown.flavor = flavor_result
144
-
145
- # Prompt for YAML headers
146
- yaml_config = config.conversation.yaml
147
- yaml_choices = [
148
- Choice(title=field, checked=getattr(yaml_config, field))
149
- for field in [
150
- "title",
151
- "tags",
152
- "chat_link",
153
- "create_time",
154
- "update_time",
155
- "model",
156
- "used_plugins",
157
- "message_count",
158
- "content_types",
159
- "custom_instructions",
160
- ]
161
- ]
162
-
163
- selected: list[str] = _ask_or_cancel(
164
- checkbox(
165
- "Select YAML metadata headers to include:",
166
- choices=yaml_choices,
167
- style=CUSTOM_STYLE,
168
- )
169
- )
170
-
171
- selected_set = set(selected)
172
- for field_name in [
173
- "title",
174
- "tags",
175
- "chat_link",
176
- "create_time",
177
- "update_time",
178
- "model",
179
- "used_plugins",
180
- "message_count",
181
- "content_types",
182
- "custom_instructions",
183
- ]:
184
- setattr(yaml_config, field_name, field_name in selected_set)
185
-
186
- # Prompt for font
187
- available_fonts = font_names()
188
- if available_fonts:
189
- current_font = (
190
- config.wordcloud.font_path.stem if config.wordcloud.font_path else available_fonts[0]
191
- )
192
- font_result: str = _ask_or_cancel(
193
- select(
194
- "Select the font for word clouds:",
195
- choices=available_fonts,
196
- default=current_font if current_font in available_fonts else available_fonts[0],
197
- style=CUSTOM_STYLE,
198
- )
199
- )
200
-
201
- if font_result:
202
- config.wordcloud.font_path = font_path(font_result)
203
-
204
- # Prompt for colormap
205
- available_colormaps = colormaps()
206
- if available_colormaps:
207
- colormap_result: str = _ask_or_cancel(
208
- select(
209
- "Select the color theme for word clouds:",
210
- choices=available_colormaps,
211
- default=config.wordcloud.colormap
212
- if config.wordcloud.colormap in available_colormaps
213
- else available_colormaps[0],
214
- style=CUSTOM_STYLE,
215
- )
216
- )
217
-
218
- if colormap_result:
219
- config.wordcloud.colormap = colormap_result
220
-
221
- # Prompt for custom stopwords
222
- stopwords_result: str = _ask_or_cancel(
223
- qst_text(
224
- "Enter custom stopwords (comma-separated):",
225
- default=config.wordcloud.custom_stopwords,
226
- style=CUSTOM_STYLE,
227
- )
228
- )
229
-
230
- config.wordcloud.custom_stopwords = stopwords_result
231
-
232
- return config
File without changes
File without changes
File without changes
File without changes