@adminforth/text-complete 2.0.14 → 2.0.16

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.
@@ -0,0 +1,15 @@
1
+ import { IAdminForth, IHttpServer, AdminForthPlugin, AdminForthResource, AdminForthDataTypes, RateLimiter } from "adminforth";
2
+ import { PluginOptions } from './types.js';
3
+ export default class TextCompletePlugin extends AdminForthPlugin {
4
+ options: PluginOptions;
5
+ resourceConfig: AdminForthResource;
6
+ columnType: AdminForthDataTypes;
7
+ adminforth: IAdminForth;
8
+ rateLimiter?: RateLimiter;
9
+ constructor(options: PluginOptions);
10
+ instanceUniqueRepresentation(pluginOptions: any): string;
11
+ validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
12
+ generateRecordContext(record: any, maxFields: number, inputFieldLimit: number, partsCount: number): string;
13
+ setupEndpoints(server: IHttpServer): void;
14
+ modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): Promise<void>;
15
+ }
@@ -0,0 +1,76 @@
1
+ import { CompletionAdapter } from "adminforth";
2
+ import { type PluginsCommonOptions } from "adminforth";
3
+ export interface PluginOptions extends PluginsCommonOptions {
4
+ /**
5
+ * Field where plugin will auto-complete text. Should be string or text field.
6
+ */
7
+ fieldName: string;
8
+ /**
9
+ * Initial prompt request when field is empty. Mustache syntax for record context fields is supported.
10
+ * E.g.
11
+ * 'I need to introduce "{{ name }}" technology to my software development company website, I need short but very attractive description if it.'
12
+ *
13
+ * Where `name` is a field name which contains technology name e.g. Vue.js
14
+ */
15
+ initialPrompt?: string;
16
+ /**
17
+ * Expert settings
18
+ */
19
+ expert?: {
20
+ /**
21
+ * Maximum number of last characters which will be used for completion for target field. Default is 500.
22
+ * Higher value will give better context but will cost more.
23
+ */
24
+ promptInputLimit?: number;
25
+ /**
26
+ * Debounce time in ms. Default is 300. Time after user stopped typing before request will be sent.
27
+ */
28
+ debounceTime?: number;
29
+ /**
30
+ * When completion is made, this plugin passes non-empty fields of the record to the LLM model for record context understanding.
31
+ */
32
+ recordContext?: {
33
+ /**
34
+ * Using this field you can limit number of fields passed to the model.
35
+ * Default is 5.
36
+ * Completion field is not included in this limit.
37
+ * Set to 0 to disable context passing at all.
38
+ * If count of fields exceeds this number, longest fields will be selected.
39
+ * If some of values will exceed maxFieldLength, it will be smartly truncated by splitting ito splitParts, taking their
40
+ * starting substring and joining back with '...'.
41
+ */
42
+ maxFields?: number;
43
+ /**
44
+ * Limit of input field value. Default is 300. If field is longer, it will be truncated.
45
+ */
46
+ maxFieldLength?: number;
47
+ /**
48
+ * How many parts to split field value if it exceeds maxFieldLength. Default is 5.
49
+ */
50
+ splitParts?: number;
51
+ };
52
+ /**
53
+ * Number of tokens to generate. Default is 50. 1 token ~= ¾ words
54
+ */
55
+ maxTokens?: number;
56
+ };
57
+ /**
58
+ * Since AI generation can be expensive, we can limit the number of requests per IP.
59
+ * Completion will simply stop working when limit is reached so user will not be bothered with error messages.
60
+ */
61
+ rateLimit?: {
62
+ /**
63
+ * E.g. 5/1d - 5 requests per day
64
+ * 3/1h - 3 requests per hour
65
+ */
66
+ limit: string;
67
+ /**
68
+ * Message shown to user when rate limit is reached
69
+ */
70
+ errorMessage: string;
71
+ };
72
+ /**
73
+ * Adapter for completion
74
+ */
75
+ adapter: CompletionAdapter;
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.10.7",
27
- "adminforth": "2.70.0",
27
+ "adminforth": "2.71.1",
28
28
  "semantic-release": "^24.2.1",
29
29
  "semantic-release-slack-bot": "^4.0.2",
30
30
  "typescript": "^5.7.3"
@@ -55,6 +55,6 @@
55
55
  ]
56
56
  },
57
57
  "peerDependencies": {
58
- "adminforth": "^2.70.0"
58
+ "adminforth": "2.71.1"
59
59
  }
60
60
  }
package/tsconfig.json CHANGED
@@ -51,7 +51,7 @@
51
51
  // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
52
52
 
53
53
  /* Emit */
54
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
54
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
55
55
  // "declarationMap": true, /* Create sourcemaps for d.ts files. */
56
56
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
57
57
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */