aifastdb 2.3.9 → 2.6.2
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/aifastdb.win32-x64-msvc.node +0 -0
- package/dist/llm-gateway.d.ts +129 -0
- package/dist/llm-gateway.d.ts.map +1 -0
- package/dist/llm-gateway.js +32 -0
- package/dist/llm-gateway.js.map +1 -0
- package/package.json +3 -3
|
Binary file
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Gateway TypeScript Wrapper (Phase-81: T81.4)
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe access to the LLM Gateway NAPI bindings with
|
|
5
|
+
* streaming chat support via AsyncIterator.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { LlmGateway } from 'aifastdb';
|
|
10
|
+
*
|
|
11
|
+
* const gw = new LlmGateway('/path/to/data');
|
|
12
|
+
* gw.registerProvider({
|
|
13
|
+
* id: 'openai', name: 'OpenAI', brand: 'openai',
|
|
14
|
+
* baseUrl: 'https://api.openai.com/v1', apiKey: 'sk-...',
|
|
15
|
+
* });
|
|
16
|
+
* gw.registerModel({ id: 'gpt-4', providerId: 'openai', name: 'gpt-4' });
|
|
17
|
+
* const conv = gw.createConversation({
|
|
18
|
+
* userId: 'user1', providerId: 'openai', modelId: 'gpt-4', modelName: 'GPT-4',
|
|
19
|
+
* });
|
|
20
|
+
* const reply = gw.chat(conv.id, 'user1', 'Hello!');
|
|
21
|
+
* console.log(reply.content);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface ProviderInfo {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
brand: string;
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
status: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ModelInfo {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
providerId: string;
|
|
36
|
+
isDefault: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ConversationInfo {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
providerId: string;
|
|
42
|
+
modelId: string;
|
|
43
|
+
modelName: string;
|
|
44
|
+
systemPrompt: string | null;
|
|
45
|
+
ownerId: string;
|
|
46
|
+
messageCount: number;
|
|
47
|
+
totalTokens: number;
|
|
48
|
+
totalCost: number;
|
|
49
|
+
isFavorite: boolean;
|
|
50
|
+
isArchived: boolean;
|
|
51
|
+
createdAt: number;
|
|
52
|
+
updatedAt: number;
|
|
53
|
+
}
|
|
54
|
+
export interface MessageInfo {
|
|
55
|
+
id: string;
|
|
56
|
+
conversationId: string;
|
|
57
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
58
|
+
content: string;
|
|
59
|
+
modelId: string | null;
|
|
60
|
+
status: string;
|
|
61
|
+
createdAt: number;
|
|
62
|
+
promptTokens: number | null;
|
|
63
|
+
completionTokens: number | null;
|
|
64
|
+
totalTokens: number | null;
|
|
65
|
+
durationMs: number | null;
|
|
66
|
+
}
|
|
67
|
+
export interface UsageStatsInfo {
|
|
68
|
+
totalPromptTokens: number;
|
|
69
|
+
totalCompletionTokens: number;
|
|
70
|
+
totalTokens: number;
|
|
71
|
+
totalCost: number;
|
|
72
|
+
messageCount: number;
|
|
73
|
+
conversationCount: number;
|
|
74
|
+
}
|
|
75
|
+
export interface PromptTemplateInfo {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
content: string;
|
|
79
|
+
description: string;
|
|
80
|
+
variables: string[];
|
|
81
|
+
category: string;
|
|
82
|
+
version: string;
|
|
83
|
+
isBuiltin: boolean;
|
|
84
|
+
isDefault: boolean;
|
|
85
|
+
createdAt: number;
|
|
86
|
+
updatedAt: number;
|
|
87
|
+
}
|
|
88
|
+
export interface GatewayInfo {
|
|
89
|
+
providerCount: number;
|
|
90
|
+
modelCount: number;
|
|
91
|
+
conversationCount: number;
|
|
92
|
+
messageCount: number;
|
|
93
|
+
templateCount: number;
|
|
94
|
+
}
|
|
95
|
+
export interface RegisterProviderOptions {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
brand: string;
|
|
99
|
+
baseUrl: string;
|
|
100
|
+
apiKey?: string;
|
|
101
|
+
protocol?: 'openai_compat' | 'anthropic' | 'gemini' | string;
|
|
102
|
+
}
|
|
103
|
+
export interface RegisterModelOptions {
|
|
104
|
+
id: string;
|
|
105
|
+
providerId: string;
|
|
106
|
+
name: string;
|
|
107
|
+
displayName?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface CreateConversationOptions {
|
|
110
|
+
userId: string;
|
|
111
|
+
providerId: string;
|
|
112
|
+
modelId: string;
|
|
113
|
+
modelName: string;
|
|
114
|
+
title?: string;
|
|
115
|
+
systemPrompt?: string;
|
|
116
|
+
}
|
|
117
|
+
export interface UpsertTemplateOptions {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
content: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
category?: string;
|
|
123
|
+
isDefault?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface StreamEvent {
|
|
126
|
+
type: 'content_delta' | 'thinking_delta' | 'tool_call' | 'usage' | 'error' | 'done' | 'start' | 'model_info';
|
|
127
|
+
data: string;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=llm-gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-gateway.d.ts","sourceRoot":"","sources":["../ts/llm-gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,M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AC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAMD,MAAM,WAAW,WAAW;IAC1B,IAAI,EACA,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,OAAO,GACP,MAAM,GACN,OAAO,GACP,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LLM Gateway TypeScript Wrapper (Phase-81: T81.4)
|
|
4
|
+
*
|
|
5
|
+
* Provides type-safe access to the LLM Gateway NAPI bindings with
|
|
6
|
+
* streaming chat support via AsyncIterator.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { LlmGateway } from 'aifastdb';
|
|
11
|
+
*
|
|
12
|
+
* const gw = new LlmGateway('/path/to/data');
|
|
13
|
+
* gw.registerProvider({
|
|
14
|
+
* id: 'openai', name: 'OpenAI', brand: 'openai',
|
|
15
|
+
* baseUrl: 'https://api.openai.com/v1', apiKey: 'sk-...',
|
|
16
|
+
* });
|
|
17
|
+
* gw.registerModel({ id: 'gpt-4', providerId: 'openai', name: 'gpt-4' });
|
|
18
|
+
* const conv = gw.createConversation({
|
|
19
|
+
* userId: 'user1', providerId: 'openai', modelId: 'gpt-4', modelName: 'GPT-4',
|
|
20
|
+
* });
|
|
21
|
+
* const reply = gw.chat(conv.id, 'user1', 'Hello!');
|
|
22
|
+
* console.log(reply.content);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Wrapper class — re-exports native binding with ergonomic TS API
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// The native binding is imported at the package level.
|
|
30
|
+
// This file provides the TypeScript types and optional ergonomic wrappers.
|
|
31
|
+
// The actual `LlmGateway` class is exported directly from the native module.
|
|
32
|
+
//# sourceMappingURL=llm-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-gateway.js","sourceRoot":"","sources":["../ts/llm-gateway.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AA2IH,+EAA+E;AAC/E,kEAAkE;AAClE,+EAA+E;AAE/E,uDAAuD;AACvD,2EAA2E;AAC3E,6EAA6E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aifastdb",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "AI-friendly database with vector search, semantic indexing, and agent memory",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"prebuild": "node prebuild-check.js",
|
|
29
|
-
"build": "napi build --platform --release && tsc",
|
|
29
|
+
"build": "napi build --platform --release --features candle && tsc",
|
|
30
30
|
"prebuild:debug": "node prebuild-check.js",
|
|
31
|
-
"build:debug": "napi build --platform && tsc",
|
|
31
|
+
"build:debug": "napi build --platform --features candle && tsc",
|
|
32
32
|
"test": "jest --passWithNoTests",
|
|
33
33
|
"typecheck": "tsc --noEmit",
|
|
34
34
|
"clean": "rimraf dist *.node"
|