@quilltap/plugin-utils 1.7.0 → 1.7.1
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.
- package/README.md +43 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -205,6 +205,49 @@ export const plugin = createRoleplayTemplatePlugin({
|
|
|
205
205
|
| `validateTemplateConfig(template)` | Validate an individual template configuration |
|
|
206
206
|
| `validateRoleplayTemplatePlugin(plugin)` | Validate a complete roleplay template plugin |
|
|
207
207
|
|
|
208
|
+
### System Prompt Plugin Utilities
|
|
209
|
+
|
|
210
|
+
Create system prompt plugins that provide character prompt templates from `.md` files:
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { createSystemPromptPlugin } from '@quilltap/plugin-utils';
|
|
214
|
+
import type { SystemPromptData } from '@quilltap/plugin-types';
|
|
215
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
216
|
+
import { join, dirname } from 'node:path';
|
|
217
|
+
|
|
218
|
+
function loadPrompts(): SystemPromptData[] {
|
|
219
|
+
const promptsDir = join(dirname(__filename), 'prompts');
|
|
220
|
+
return readdirSync(promptsDir)
|
|
221
|
+
.filter(f => f.endsWith('.md'))
|
|
222
|
+
.map(file => {
|
|
223
|
+
const name = file.replace(/\.md$/i, '');
|
|
224
|
+
const parts = name.split('_');
|
|
225
|
+
const category = parts.pop()!;
|
|
226
|
+
const modelHint = parts.join('_');
|
|
227
|
+
return {
|
|
228
|
+
name,
|
|
229
|
+
content: readFileSync(join(promptsDir, file), 'utf-8'),
|
|
230
|
+
modelHint,
|
|
231
|
+
category,
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const plugin = createSystemPromptPlugin({
|
|
237
|
+
metadata: {
|
|
238
|
+
pluginId: 'my-prompts',
|
|
239
|
+
displayName: 'My System Prompts',
|
|
240
|
+
version: '1.0.0',
|
|
241
|
+
},
|
|
242
|
+
prompts: loadPrompts(),
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
| Function | Description |
|
|
247
|
+
|----------|-------------|
|
|
248
|
+
| `createSystemPromptPlugin(options)` | Create a system prompt plugin with validation |
|
|
249
|
+
| `validateSystemPromptPlugin(plugin)` | Validate a complete system prompt plugin |
|
|
250
|
+
|
|
208
251
|
## Example: Complete Plugin Provider
|
|
209
252
|
|
|
210
253
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quilltap/plugin-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Utility functions for Quilltap plugin development",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"openai": "^6.
|
|
71
|
+
"openai": "^6.33.0",
|
|
72
72
|
"tsup": "^8.5.1",
|
|
73
73
|
"typescript": "^5.9.3"
|
|
74
74
|
},
|