graphile-llm 0.11.5 → 0.12.0
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/__tests__/graphile-llm.test.js +318 -37
- package/__tests__/unified-search-embedding.test.d.ts +10 -0
- package/__tests__/unified-search-embedding.test.js +176 -0
- package/embedder.d.ts +24 -4
- package/embedder.js +36 -7
- package/env.d.ts +6 -28
- package/env.js +10 -47
- package/esm/__tests__/graphile-llm.test.js +319 -38
- package/esm/__tests__/unified-search-embedding.test.d.ts +10 -0
- package/esm/__tests__/unified-search-embedding.test.js +174 -0
- package/esm/embedder.d.ts +24 -4
- package/esm/embedder.js +35 -7
- package/esm/env.d.ts +6 -28
- package/esm/env.js +5 -46
- package/esm/index.d.ts +5 -4
- package/esm/index.js +3 -4
- package/esm/metering.d.ts +1 -3
- package/esm/metering.js +48 -108
- package/esm/plugins/llm-module-plugin.d.ts +9 -4
- package/esm/plugins/llm-module-plugin.js +9 -4
- package/esm/plugins/rag-plugin.js +30 -20
- package/esm/plugins/text-mutation-plugin.js +15 -2
- package/esm/plugins/text-search-plugin.d.ts +15 -3
- package/esm/plugins/text-search-plugin.js +94 -23
- package/esm/preset.d.ts +13 -2
- package/esm/preset.js +15 -4
- package/esm/types.d.ts +13 -0
- package/index.d.ts +5 -4
- package/index.js +6 -2
- package/metering.d.ts +1 -3
- package/metering.js +48 -108
- package/package.json +6 -4
- package/plugins/llm-module-plugin.d.ts +9 -4
- package/plugins/llm-module-plugin.js +9 -4
- package/plugins/rag-plugin.js +30 -20
- package/plugins/text-mutation-plugin.js +15 -2
- package/plugins/text-search-plugin.d.ts +15 -3
- package/plugins/text-search-plugin.js +95 -23
- package/preset.d.ts +13 -2
- package/preset.js +15 -4
- package/types.d.ts +13 -0
package/preset.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - Adds `{column}Text: String` companion fields on mutation inputs for vector columns
|
|
12
12
|
* - Optionally enables billing/metering via the LlmMeteringPlugin
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Included in ConstructivePreset when `enableLlm` is true (the default).
|
|
15
|
+
* Can also be used standalone by adding it directly to your preset's `extends` array.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
@@ -54,6 +54,17 @@
|
|
|
54
54
|
* })
|
|
55
55
|
* ```
|
|
56
56
|
*
|
|
57
|
+
* @example With strict quota enforcement (fail if embedding unavailable):
|
|
58
|
+
* ```typescript
|
|
59
|
+
* GraphileLlmPreset({
|
|
60
|
+
* defaultEmbedder: { provider: 'openai', model: 'text-embedding-3-small' },
|
|
61
|
+
* metering: true,
|
|
62
|
+
* onQuotaExceeded: 'throw',
|
|
63
|
+
* // → if billing quota is exceeded, queries with unifiedSearch throw an error
|
|
64
|
+
* // → without this, queries silently fall back to text-only search
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
57
68
|
* @example With custom entity_id resolution (bill per-database):
|
|
58
69
|
* ```typescript
|
|
59
70
|
* GraphileLlmPreset({
|
|
@@ -78,7 +89,7 @@ const text_search_plugin_1 = require("./plugins/text-search-plugin");
|
|
|
78
89
|
* @returns A GraphileConfig.Preset to add to your extends array
|
|
79
90
|
*/
|
|
80
91
|
function GraphileLlmPreset(options = {}) {
|
|
81
|
-
const { enableTextSearch = true, enableTextMutations = true, enableRag = false, ragDefaults, metering } = options;
|
|
92
|
+
const { enableTextSearch = true, enableTextMutations = true, enableRag = false, onQuotaExceeded, ragDefaults, metering } = options;
|
|
82
93
|
const plugins = [
|
|
83
94
|
(0, llm_module_plugin_1.createLlmModulePlugin)(options)
|
|
84
95
|
];
|
|
@@ -89,7 +100,7 @@ function GraphileLlmPreset(options = {}) {
|
|
|
89
100
|
plugins.push((0, metering_plugin_1.createLlmMeteringPlugin)(meteringConfig));
|
|
90
101
|
}
|
|
91
102
|
if (enableTextSearch) {
|
|
92
|
-
plugins.push((0, text_search_plugin_1.createLlmTextSearchPlugin)());
|
|
103
|
+
plugins.push((0, text_search_plugin_1.createLlmTextSearchPlugin)({ onQuotaExceeded }));
|
|
93
104
|
}
|
|
94
105
|
if (enableTextMutations) {
|
|
95
106
|
plugins.push((0, text_mutation_plugin_1.createLlmTextMutationPlugin)());
|
package/types.d.ts
CHANGED
|
@@ -216,6 +216,19 @@ export interface GraphileLlmOptions {
|
|
|
216
216
|
* @default true
|
|
217
217
|
*/
|
|
218
218
|
enableTextSearch?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Controls behavior when the embedder returns null (e.g. billing quota exceeded).
|
|
221
|
+
*
|
|
222
|
+
* - `'degrade'` (default): Skip the vector search silently and fall back to
|
|
223
|
+
* text-only adapters (tsvector, BM25, trgm). If no text adapters are
|
|
224
|
+
* available, throws an error regardless of this setting.
|
|
225
|
+
* - `'throw'`: Always throw an error when the embedder fails, even if
|
|
226
|
+
* text adapters could handle the query. Use this when semantic search
|
|
227
|
+
* is critical and keyword-only results are unacceptable.
|
|
228
|
+
*
|
|
229
|
+
* @default 'degrade'
|
|
230
|
+
*/
|
|
231
|
+
onQuotaExceeded?: 'degrade' | 'throw';
|
|
219
232
|
/**
|
|
220
233
|
* Whether to add `*Text` companion fields on mutation inputs for vector columns.
|
|
221
234
|
* @default true
|