You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-reference/talkpipe-plugin-manager.md
+33-20Lines changed: 33 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Command-line tool for managing and inspecting TalkPipe plugins.
4
4
5
5
## Overview
6
6
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.
8
8
9
9
## Installation
10
10
@@ -21,7 +21,7 @@ pip install talkpipe
21
21
Display all discovered plugins and their status:
22
22
23
23
```bash
24
-
talkpipe_plugin_manager --list
24
+
talkpipe_plugins --list
25
25
```
26
26
27
27
**Example output:**
@@ -40,15 +40,15 @@ Failed plugins (1):
40
40
Reload a specific plugin by name (useful during development):
41
41
42
42
```bash
43
-
talkpipe_plugin_manager --reload my-data-plugin
43
+
talkpipe_plugins --reload my-data-plugin
44
44
```
45
45
46
46
### Verbose Output
47
47
48
48
Show detailed information:
49
49
50
50
```bash
51
-
talkpipe_plugin_manager --list --verbose
51
+
talkpipe_plugins --list --verbose
52
52
```
53
53
54
54
## Plugin Discovery
@@ -65,7 +65,7 @@ setup(
65
65
name="my-talkpipe-plugin",
66
66
entry_points={
67
67
"talkpipe.plugins": [
68
-
"my_plugin = my_plugin.plugin:NetworkPlugin",
68
+
"my_plugin = my_plugin.plugin",
69
69
]
70
70
}
71
71
)
@@ -74,21 +74,31 @@ setup(
74
74
**pyproject.toml:**
75
75
```toml
76
76
[project.entry-points."talkpipe.plugins"]
77
-
my_plugin = "my_plugin.plugin:NetworkPlugin"
77
+
my_plugin = "my_plugin.plugin"
78
78
```
79
79
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
+
80
82
## How Plugin Loading Works
81
83
82
84
When TalkPipe discovers a plugin, it performs the following steps:
83
85
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)
85
87
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
87
89
88
90
The key insight is that **simply importing the plugin module triggers component registration**. This happens through TalkPipe's decorator-based registry system.
89
91
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
+
90
98
### Example Plugin Structure
91
99
100
+
**Recommended: Module-level pattern**
101
+
92
102
```python
93
103
# my_plugin/plugin.py
94
104
from talkpipe.chatterlang import registry
@@ -104,19 +114,22 @@ class JsonParseSegment(AbstractSegment):
104
114
"""JSON parsing segment - registered automatically on import."""
105
115
pass
106
116
107
-
classNetworkPlugin:
108
-
"""Main plugin class referenced by entry point."""
109
-
110
-
definitialize_plugin(self):
111
-
"""Optional: Called after module import for additional setup."""
112
-
print("Network plugin initialized!")
113
-
# Additional setup if needed
117
+
definitialize_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"
114
127
```
115
128
116
-
When this module is imported:
129
+
When this module is loaded:
117
130
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
120
133
121
134
### Alternative: Module-Level Registration
122
135
@@ -157,10 +170,10 @@ During plugin development, you can reload plugins without restarting Python:
0 commit comments