Skip to content

Commit 46cd2d8

Browse files
committed
Fixed documentation error and removed unusued entry in toml scripts
1 parent 0256381 commit 46cd2d8

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
### Improvements
55
- Updated tutorials to use lancedb.
66
- Moved tutorial scripts out of shell scripts into their own files
7+
- Fixed issue with Docker container not including all optional installation components
8+
- Fixed string encoding issue with web page downloads
9+
- Updated documentation for plugins to fix error
10+
- Removed invalid script in pyproject.toml
711

812
## 0.9.2
913
### Improvements

docs/api-reference/talkpipe-plugin-manager.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Command-line tool for managing and inspecting TalkPipe plugins.
44

55
## Overview
66

7-
The `talkpipe_plugin_manager` command provides utilities to list, reload, and debug TalkPipe plugins that are installed via Python entry points.
7+
The `talkpipe_plugins` command provides utilities to list, reload, and debug TalkPipe plugins that are installed via Python entry points.
88

99
## Installation
1010

@@ -21,7 +21,7 @@ pip install talkpipe
2121
Display all discovered plugins and their status:
2222

2323
```bash
24-
talkpipe_plugin_manager --list
24+
talkpipe_plugins --list
2525
```
2626

2727
**Example output:**
@@ -40,15 +40,15 @@ Failed plugins (1):
4040
Reload a specific plugin by name (useful during development):
4141

4242
```bash
43-
talkpipe_plugin_manager --reload my-data-plugin
43+
talkpipe_plugins --reload my-data-plugin
4444
```
4545

4646
### Verbose Output
4747

4848
Show detailed information:
4949

5050
```bash
51-
talkpipe_plugin_manager --list --verbose
51+
talkpipe_plugins --list --verbose
5252
```
5353

5454
## Plugin Discovery
@@ -65,7 +65,7 @@ setup(
6565
name="my-talkpipe-plugin",
6666
entry_points={
6767
"talkpipe.plugins": [
68-
"my_plugin = my_plugin.plugin:NetworkPlugin",
68+
"my_plugin = my_plugin.plugin",
6969
]
7070
}
7171
)
@@ -74,21 +74,31 @@ setup(
7474
**pyproject.toml:**
7575
```toml
7676
[project.entry-points."talkpipe.plugins"]
77-
my_plugin = "my_plugin.plugin:NetworkPlugin"
77+
my_plugin = "my_plugin.plugin"
7878
```
7979

80+
The entry point should reference the **module** that contains your plugin code. Component registration happens automatically through decorators when the module is imported.
81+
8082
## How Plugin Loading Works
8183

8284
When TalkPipe discovers a plugin, it performs the following steps:
8385

84-
1. **Import the module**: The plugin loader imports the module specified by the entry point (e.g., `my_plugin.plugin`)
86+
1. **Load the entry point**: The plugin loader loads whatever the entry point references (typically a module or function)
8587
2. **Automatic registration**: During import, any sources and segments defined or imported by the module are automatically registered with TalkPipe's registry system through decorators like `@registry.register_segment()`
86-
3. **Optional initialization**: If the loaded class/module has an `initialize_plugin` function or method, it will be called for additional setup
88+
3. **Optional initialization**: If the loaded object has an `initialize_plugin` function attribute, it will be called for additional setup
8789

8890
The key insight is that **simply importing the plugin module triggers component registration**. This happens through TalkPipe's decorator-based registry system.
8991

92+
**Important**: The entry point should reference either:
93+
- A **module** (e.g., `my_plugin.plugin`) that can have a module-level `initialize_plugin()` function
94+
- A **function** directly (e.g., `my_plugin.plugin:setup_plugin`)
95+
96+
Entry points pointing to classes will have the `initialize_plugin` called on the **class itself** (not an instance), so it would need to be a static method or classmethod if using a class.
97+
9098
### Example Plugin Structure
9199

100+
**Recommended: Module-level pattern**
101+
92102
```python
93103
# my_plugin/plugin.py
94104
from talkpipe.chatterlang import registry
@@ -104,19 +114,22 @@ class JsonParseSegment(AbstractSegment):
104114
"""JSON parsing segment - registered automatically on import."""
105115
pass
106116

107-
class NetworkPlugin:
108-
"""Main plugin class referenced by entry point."""
109-
110-
def initialize_plugin(self):
111-
"""Optional: Called after module import for additional setup."""
112-
print("Network plugin initialized!")
113-
# Additional setup if needed
117+
def initialize_plugin():
118+
"""Optional: Called after module import for additional setup."""
119+
print("Network plugin initialized!")
120+
# Additional setup if needed
121+
```
122+
123+
**Entry point configuration** (points to the module):
124+
```toml
125+
[project.entry-points."talkpipe.plugins"]
126+
network_plugin = "my_plugin.plugin"
114127
```
115128

116-
When this module is imported:
129+
When this module is loaded:
117130
1. The `@registry.register_source("httpGet")` decorator runs, registering the `HttpGetSource`
118-
2. The `@registry.register_segment("jsonParse")` decorator runs, registering the `JsonParseSegment`
119-
3. The `NetworkPlugin.initialize_plugin()` method is called for any additional setup
131+
2. The `@registry.register_segment("jsonParse")` decorator runs, registering the `JsonParseSegment`
132+
3. The module-level `initialize_plugin()` function is called for any additional setup
120133

121134
### Alternative: Module-Level Registration
122135

@@ -157,10 +170,10 @@ During plugin development, you can reload plugins without restarting Python:
157170
```bash
158171
# Make changes to your plugin code
159172
# Then reload it
160-
talkpipe_plugin_manager --reload my-plugin
173+
talkpipe_plugins --reload my-plugin
161174

162175
# Verify it loaded successfully
163-
talkpipe_plugin_manager --list
176+
talkpipe_plugins --list
164177
```
165178

166179
## Integration with TalkPipe

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ all = [
7070
chatterlang_workbench = "talkpipe.app.chatterlang_workbench:main"
7171
chatterlang_script = "talkpipe.app.chatterlang_script:main"
7272
chatterlang_reference_generator = "talkpipe.app.chatterlang_reference_generator:go"
73-
talkpipe_genkeys = "talkpipe.operations.crypto:generate_keys_cli"
7473
chatterlang_serve = "talkpipe.app.chatterlang_serve:go"
7574
chatterlang_reference_browser = "talkpipe.app.chatterlang_reference_browser:main"
7675
talkpipe_plugins = "talkpipe.app.talkpipe_plugin_manager:main"

0 commit comments

Comments
 (0)