@jabrod/sdk 1.0.8
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 +192 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +67 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/chat.d.ts +20 -0
- package/dist/resources/chat.d.ts.map +1 -0
- package/dist/resources/chat.js +34 -0
- package/dist/resources/chat.js.map +1 -0
- package/dist/resources/kb.d.ts +38 -0
- package/dist/resources/kb.d.ts.map +1 -0
- package/dist/resources/kb.js +62 -0
- package/dist/resources/kb.js.map +1 -0
- package/dist/resources/usage.d.ts +14 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +16 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/types.d.ts +115 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @jabrod/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for [Jabrod Cloud API](https://cloud.jabrod.com) - RAG as a Service.
|
|
4
|
+
|
|
5
|
+
Build AI-powered applications with knowledge bases in minutes. Upload documents, query them with semantic search, and get AI-generated responses.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @jabrod/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @jabrod/sdk
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @jabrod/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Jabrod } from '@jabrod/sdk';
|
|
21
|
+
|
|
22
|
+
// Initialize the client
|
|
23
|
+
const jclient = Jabrod({
|
|
24
|
+
apiKey: 'jb_your_api_key_here'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Create a knowledge base
|
|
28
|
+
const kb = await jclient.kb.create({
|
|
29
|
+
name: 'My Documents',
|
|
30
|
+
description: 'Product documentation'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Upload a document (browser)
|
|
34
|
+
const file = document.querySelector('input[type="file"]').files[0];
|
|
35
|
+
await jclient.kb.uploadFile({
|
|
36
|
+
kbId: kb.id,
|
|
37
|
+
file: file
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Or upload text content
|
|
41
|
+
await jclient.kb.uploadText({
|
|
42
|
+
kbId: kb.id,
|
|
43
|
+
content: 'Your text content here...',
|
|
44
|
+
name: 'notes.txt'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Chat with the knowledge base
|
|
48
|
+
const response = await jclient.chat.complete({
|
|
49
|
+
kbId: kb.id,
|
|
50
|
+
message: 'What is mentioned in my documents?'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log(response.message);
|
|
54
|
+
console.log('Sources:', response.sources);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## API Reference
|
|
58
|
+
|
|
59
|
+
### Initialization
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Jabrod } from '@jabrod/sdk';
|
|
63
|
+
|
|
64
|
+
const jclient = Jabrod({
|
|
65
|
+
apiKey: 'jb_xxx', // Required: Your API key
|
|
66
|
+
baseUrl: 'https://...' // Optional: Custom API URL
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Knowledge Bases
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// List all knowledge bases
|
|
74
|
+
const kbs = await jclient.kb.list();
|
|
75
|
+
|
|
76
|
+
// Create a knowledge base
|
|
77
|
+
const kb = await jclient.kb.create({
|
|
78
|
+
name: 'My KB',
|
|
79
|
+
description: 'Optional description'
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Get a specific knowledge base
|
|
83
|
+
const kb = await jclient.kb.get('kb-id');
|
|
84
|
+
|
|
85
|
+
// Delete a knowledge base
|
|
86
|
+
await jclient.kb.delete('kb-id');
|
|
87
|
+
|
|
88
|
+
// List documents in a knowledge base
|
|
89
|
+
const docs = await jclient.kb.listDocuments('kb-id');
|
|
90
|
+
|
|
91
|
+
// Upload a file
|
|
92
|
+
await jclient.kb.uploadFile({
|
|
93
|
+
kbId: 'kb-id',
|
|
94
|
+
file: fileOrBlob,
|
|
95
|
+
filename: 'document.pdf'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Upload text content
|
|
99
|
+
await jclient.kb.uploadText({
|
|
100
|
+
kbId: 'kb-id',
|
|
101
|
+
content: 'Your text here',
|
|
102
|
+
name: 'notes.txt'
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Query (Semantic Search)
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Query for relevant chunks without LLM processing
|
|
110
|
+
const results = await jclient.chat.query({
|
|
111
|
+
kbId: 'kb-id',
|
|
112
|
+
query: 'What is the return policy?',
|
|
113
|
+
topK: 5 // Optional: Number of results (default: 5)
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
console.log(results.chunks);
|
|
117
|
+
// [{ content: '...', score: 0.95, documentId: '...' }, ...]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Chat (RAG)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// Get AI-generated response based on KB content
|
|
124
|
+
const response = await jclient.chat.complete({
|
|
125
|
+
kbId: 'kb-id',
|
|
126
|
+
message: 'Summarize the key points',
|
|
127
|
+
model: 'mistralai/mistral-small-3.1-24b-instruct:free', // Optional
|
|
128
|
+
systemPrompt: 'You are a helpful assistant.', // Optional
|
|
129
|
+
topK: 5 // Optional: Number of context chunks
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
console.log(response.message);
|
|
133
|
+
console.log(response.sources); // Relevant document chunks
|
|
134
|
+
console.log(response.usage); // Token usage
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Usage Statistics
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Get usage for current billing period
|
|
141
|
+
const usage = await jclient.usage.get();
|
|
142
|
+
|
|
143
|
+
console.log(usage.queries);
|
|
144
|
+
console.log(usage.tokensUsed);
|
|
145
|
+
console.log(usage.limits);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Error Handling
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { Jabrod, JabrodError } from '@jabrod/sdk';
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const response = await jclient.chat.complete({ ... });
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error instanceof JabrodError) {
|
|
157
|
+
console.log(error.code); // 'INVALID_API_KEY', 'NOT_FOUND', etc.
|
|
158
|
+
console.log(error.message); // Human-readable message
|
|
159
|
+
console.log(error.status); // HTTP status code
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## TypeScript Support
|
|
165
|
+
|
|
166
|
+
Full TypeScript support with exported types:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import type {
|
|
170
|
+
KnowledgeBase,
|
|
171
|
+
Document,
|
|
172
|
+
ChatResult,
|
|
173
|
+
QueryResult,
|
|
174
|
+
UsageStats
|
|
175
|
+
} from '@jabrod/sdk';
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Get Your API Key
|
|
179
|
+
|
|
180
|
+
1. Sign up at [agent.jabrod.com](https://agent.jabrod.com)
|
|
181
|
+
2. Go to Dashboard > API Keys
|
|
182
|
+
3. Click "Create Key"
|
|
183
|
+
4. Copy your key (starts with `jb_`)
|
|
184
|
+
|
|
185
|
+
## Support
|
|
186
|
+
|
|
187
|
+
- Documentation: [docs.jabrod.com](https://docs.jabrod.com)
|
|
188
|
+
- Issues: [GitHub Issues](https://github.com/jabrod/sdk/issues)
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Client for Jabrod API
|
|
3
|
+
*/
|
|
4
|
+
export interface ClientConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class HttpClient {
|
|
9
|
+
private apiKey;
|
|
10
|
+
private baseUrl;
|
|
11
|
+
constructor(config: ClientConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Make an authenticated request to the API
|
|
14
|
+
*/
|
|
15
|
+
request<T>(method: string, path: string, options?: {
|
|
16
|
+
body?: unknown;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
formData?: FormData;
|
|
19
|
+
}): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* GET request
|
|
22
|
+
*/
|
|
23
|
+
get<T>(path: string): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* POST request with JSON body
|
|
26
|
+
*/
|
|
27
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* POST request with FormData
|
|
30
|
+
*/
|
|
31
|
+
postForm<T>(path: string, formData: FormData): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* DELETE request
|
|
34
|
+
*/
|
|
35
|
+
delete<T>(path: string): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* PATCH request
|
|
38
|
+
*/
|
|
39
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],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seUrl;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.apiKey = config.apiKey;
|
|
10
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Make an authenticated request to the API
|
|
14
|
+
*/
|
|
15
|
+
async request(method, path, options = {}) {
|
|
16
|
+
const url = `${this.baseUrl}${path}`;
|
|
17
|
+
const headers = {
|
|
18
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
19
|
+
...options.headers,
|
|
20
|
+
};
|
|
21
|
+
// Only set Content-Type for JSON body (not FormData)
|
|
22
|
+
if (options.body && !options.formData) {
|
|
23
|
+
headers['Content-Type'] = 'application/json';
|
|
24
|
+
}
|
|
25
|
+
const response = await fetch(url, {
|
|
26
|
+
method,
|
|
27
|
+
headers,
|
|
28
|
+
body: options.formData || (options.body ? JSON.stringify(options.body) : undefined),
|
|
29
|
+
});
|
|
30
|
+
const data = await response.json();
|
|
31
|
+
if (!response.ok || !data.success) {
|
|
32
|
+
throw new JabrodError(data.error?.code || 'UNKNOWN_ERROR', data.error?.message || 'An unknown error occurred', response.status, data.error?.details);
|
|
33
|
+
}
|
|
34
|
+
return data.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* GET request
|
|
38
|
+
*/
|
|
39
|
+
async get(path) {
|
|
40
|
+
return this.request('GET', path);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* POST request with JSON body
|
|
44
|
+
*/
|
|
45
|
+
async post(path, body) {
|
|
46
|
+
return this.request('POST', path, { body });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* POST request with FormData
|
|
50
|
+
*/
|
|
51
|
+
async postForm(path, formData) {
|
|
52
|
+
return this.request('POST', path, { formData });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* DELETE request
|
|
56
|
+
*/
|
|
57
|
+
async delete(path) {
|
|
58
|
+
return this.request('DELETE', path);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* PATCH request
|
|
62
|
+
*/
|
|
63
|
+
async patch(path, body) {
|
|
64
|
+
return this.request('PATCH', path, { body });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAe,WAAW,EAAE,MAAM,YAAY,CAAC;AAOtD,MAAM,OAAO,UAAU;IACX,MAAM,CAAS;IACf,OAAO,CAAS;IAExB,YAAY,MAAoB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;IAC9E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACT,MAAc,EACd,IAAY,EACZ,UAII,EAAE;QAEN,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAErC,MAAM,OAAO,GAA2B;YACpC,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACxC,GAAG,OAAO,CAAC,OAAO;SACrB,CAAC;QAEF,qDAAqD;QACrD,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QACjD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC9B,MAAM;YACN,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,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
+
/**
|
|
2
|
+
* Jabrod SDK - Official SDK for Jabrod Cloud API
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { Jabrod } from '@jabrod/sdk';
|
|
7
|
+
*
|
|
8
|
+
* const jclient = Jabrod({ apiKey: 'jb_xxx' });
|
|
9
|
+
*
|
|
10
|
+
* // Create a knowledge base
|
|
11
|
+
* const kb = await jclient.kb.create({ name: 'My KB' });
|
|
12
|
+
*
|
|
13
|
+
* // Upload a document
|
|
14
|
+
* await jclient.kb.uploadFile({ kbId: kb.id, file: myFile });
|
|
15
|
+
*
|
|
16
|
+
* // Chat with the KB
|
|
17
|
+
* const response = await jclient.chat.complete({
|
|
18
|
+
* kbId: kb.id,
|
|
19
|
+
* message: 'What is in my documents?'
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { KBResource } from './resources/kb.js';
|
|
24
|
+
import { ChatResource } from './resources/chat.js';
|
|
25
|
+
import { UsageResource } from './resources/usage.js';
|
|
26
|
+
import type { JabrodConfig } from './types.js';
|
|
27
|
+
export * from './types.js';
|
|
28
|
+
/**
|
|
29
|
+
* Jabrod SDK Client
|
|
30
|
+
*/
|
|
31
|
+
export interface JabrodClient {
|
|
32
|
+
/** Knowledge Base operations */
|
|
33
|
+
kb: KBResource;
|
|
34
|
+
/** Chat and Query operations */
|
|
35
|
+
chat: ChatResource;
|
|
36
|
+
/** Usage statistics */
|
|
37
|
+
usage: UsageResource;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a new Jabrod SDK client
|
|
41
|
+
*
|
|
42
|
+
* @param config - Configuration options
|
|
43
|
+
* @returns Jabrod client instance
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const jclient = Jabrod({ apiKey: 'jb_xxx' });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function Jabrod(config: JabrodConfig): JabrodClient;
|
|
51
|
+
export default Jabrod;
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,cAAc,YAAY,CAAC;AAK3B;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,gCAAgC;IAChC,EAAE,EAAE,UAAU,CAAC;IACf,gCAAgC;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,uBAAuB;IACvB,KAAK,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAmBzD;AAGD,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jabrod SDK - Official SDK for Jabrod Cloud API
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { Jabrod } from '@jabrod/sdk';
|
|
7
|
+
*
|
|
8
|
+
* const jclient = Jabrod({ apiKey: 'jb_xxx' });
|
|
9
|
+
*
|
|
10
|
+
* // Create a knowledge base
|
|
11
|
+
* const kb = await jclient.kb.create({ name: 'My KB' });
|
|
12
|
+
*
|
|
13
|
+
* // Upload a document
|
|
14
|
+
* await jclient.kb.uploadFile({ kbId: kb.id, file: myFile });
|
|
15
|
+
*
|
|
16
|
+
* // Chat with the KB
|
|
17
|
+
* const response = await jclient.chat.complete({
|
|
18
|
+
* kbId: kb.id,
|
|
19
|
+
* message: 'What is in my documents?'
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { HttpClient } from './client.js';
|
|
24
|
+
import { KBResource } from './resources/kb.js';
|
|
25
|
+
import { ChatResource } from './resources/chat.js';
|
|
26
|
+
import { UsageResource } from './resources/usage.js';
|
|
27
|
+
// Re-export types
|
|
28
|
+
export * from './types.js';
|
|
29
|
+
// Default API base URL
|
|
30
|
+
const DEFAULT_BASE_URL = 'https://cloud.jabrod.com';
|
|
31
|
+
/**
|
|
32
|
+
* Create a new Jabrod SDK client
|
|
33
|
+
*
|
|
34
|
+
* @param config - Configuration options
|
|
35
|
+
* @returns Jabrod client instance
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const jclient = Jabrod({ apiKey: 'jb_xxx' });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function Jabrod(config) {
|
|
43
|
+
if (!config.apiKey) {
|
|
44
|
+
throw new Error('API key is required. Get one at https://agent.jabrod.com/dashboard');
|
|
45
|
+
}
|
|
46
|
+
if (!config.apiKey.startsWith('jb_')) {
|
|
47
|
+
throw new Error('Invalid API key format. Keys should start with "jb_"');
|
|
48
|
+
}
|
|
49
|
+
const httpClient = new HttpClient({
|
|
50
|
+
apiKey: config.apiKey,
|
|
51
|
+
baseUrl: config.baseUrl || DEFAULT_BASE_URL,
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
kb: new KBResource(httpClient),
|
|
55
|
+
chat: new ChatResource(httpClient),
|
|
56
|
+
usage: new UsageResource(httpClient),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Default export
|
|
60
|
+
export default Jabrod;
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAE3B,uBAAuB;AACvB,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAcpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,MAAoB;IACvC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IAC1F,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,gBAAgB;KAC9C,CAAC,CAAC;IAEH,OAAO;QACH,EAAE,EAAE,IAAI,UAAU,CAAC,UAAU,CAAC;QAC9B,IAAI,EAAE,IAAI,YAAY,CAAC,UAAU,CAAC;QAClC,KAAK,EAAE,IAAI,aAAa,CAAC,UAAU,CAAC;KACvC,CAAC;AACN,CAAC;AAED,iBAAiB;AACjB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Resource
|
|
3
|
+
*/
|
|
4
|
+
import { HttpClient } from '../client.js';
|
|
5
|
+
import type { ChatOptions, ChatResult, QueryOptions, QueryResult } from '../types.js';
|
|
6
|
+
export declare class ChatResource {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Query a knowledge base for relevant chunks
|
|
11
|
+
* Returns raw chunks without LLM processing
|
|
12
|
+
*/
|
|
13
|
+
query(options: QueryOptions): Promise<QueryResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Chat with a knowledge base
|
|
16
|
+
* Uses RAG to generate AI responses based on KB content
|
|
17
|
+
*/
|
|
18
|
+
complete(options: ChatOptions): Promise<ChatResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/resources/chat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtF,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,UAAU;IAI9B;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAQxD;;;OAGG;IACG,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAS5D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Resource
|
|
3
|
+
*/
|
|
4
|
+
export class ChatResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Query a knowledge base for relevant chunks
|
|
11
|
+
* Returns raw chunks without LLM processing
|
|
12
|
+
*/
|
|
13
|
+
async query(options) {
|
|
14
|
+
return this.client.post('/v1/query', {
|
|
15
|
+
kbId: options.kbId,
|
|
16
|
+
query: options.query,
|
|
17
|
+
topK: options.topK ?? 5,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Chat with a knowledge base
|
|
22
|
+
* Uses RAG to generate AI responses based on KB content
|
|
23
|
+
*/
|
|
24
|
+
async complete(options) {
|
|
25
|
+
return this.client.post('/v1/chat', {
|
|
26
|
+
kbId: options.kbId,
|
|
27
|
+
message: options.message,
|
|
28
|
+
model: options.model,
|
|
29
|
+
systemPrompt: options.systemPrompt,
|
|
30
|
+
topK: options.topK ?? 5,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/resources/chat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,OAAO,YAAY;IACb,MAAM,CAAa;IAE3B,YAAY,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAc,WAAW,EAAE;YAC9C,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;SAC1B,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAoB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAa,UAAU,EAAE;YAC5C,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;SAC1B,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Base Resource
|
|
3
|
+
*/
|
|
4
|
+
import { HttpClient } from '../client.js';
|
|
5
|
+
import type { KnowledgeBase, CreateKBOptions, Document, UploadFileOptions, UploadTextOptions } from '../types.js';
|
|
6
|
+
export declare class KBResource {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* List all knowledge bases
|
|
11
|
+
*/
|
|
12
|
+
list(): Promise<KnowledgeBase[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new knowledge base
|
|
15
|
+
*/
|
|
16
|
+
create(options: CreateKBOptions): Promise<KnowledgeBase>;
|
|
17
|
+
/**
|
|
18
|
+
* Get a knowledge base by ID
|
|
19
|
+
*/
|
|
20
|
+
get(kbId: string): Promise<KnowledgeBase>;
|
|
21
|
+
/**
|
|
22
|
+
* Delete a knowledge base
|
|
23
|
+
*/
|
|
24
|
+
delete(kbId: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* List documents in a knowledge base
|
|
27
|
+
*/
|
|
28
|
+
listDocuments(kbId: string): Promise<Document[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Upload a file to a knowledge base
|
|
31
|
+
*/
|
|
32
|
+
uploadFile(options: UploadFileOptions): Promise<Document>;
|
|
33
|
+
/**
|
|
34
|
+
* Upload text content to a knowledge base
|
|
35
|
+
*/
|
|
36
|
+
uploadText(options: UploadTextOptions): Promise<Document>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=kb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb.d.ts","sourceRoot":"","sources":["../../src/resources/kb.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACpB,MAAM,aAAa,CAAC;AAErB,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,UAAU;IAI9B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAItC;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAI9D;;OAEG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI/C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC;;OAEG;IACG,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAItD;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY/D;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOlE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Base Resource
|
|
3
|
+
*/
|
|
4
|
+
export class KBResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List all knowledge bases
|
|
11
|
+
*/
|
|
12
|
+
async list() {
|
|
13
|
+
return this.client.get('/v1/kb');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a new knowledge base
|
|
17
|
+
*/
|
|
18
|
+
async create(options) {
|
|
19
|
+
return this.client.post('/v1/kb', options);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a knowledge base by ID
|
|
23
|
+
*/
|
|
24
|
+
async get(kbId) {
|
|
25
|
+
return this.client.get(`/v1/kb/${kbId}`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Delete a knowledge base
|
|
29
|
+
*/
|
|
30
|
+
async delete(kbId) {
|
|
31
|
+
await this.client.delete(`/v1/kb/${kbId}`);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List documents in a knowledge base
|
|
35
|
+
*/
|
|
36
|
+
async listDocuments(kbId) {
|
|
37
|
+
return this.client.get(`/v1/kb/${kbId}/documents`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Upload a file to a knowledge base
|
|
41
|
+
*/
|
|
42
|
+
async uploadFile(options) {
|
|
43
|
+
const formData = new FormData();
|
|
44
|
+
if (options.file instanceof File) {
|
|
45
|
+
formData.append('file', options.file);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
formData.append('file', options.file, options.filename || 'upload');
|
|
49
|
+
}
|
|
50
|
+
return this.client.postForm(`/v1/kb/${options.kbId}/documents`, formData);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Upload text content to a knowledge base
|
|
54
|
+
*/
|
|
55
|
+
async uploadText(options) {
|
|
56
|
+
const blob = new Blob([options.content], { type: 'text/plain' });
|
|
57
|
+
const formData = new FormData();
|
|
58
|
+
formData.append('file', blob, options.name || 'text.txt');
|
|
59
|
+
return this.client.postForm(`/v1/kb/${options.kbId}/documents`, formData);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=kb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb.js","sourceRoot":"","sources":["../../src/resources/kb.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,MAAM,OAAO,UAAU;IACX,MAAM,CAAa;IAE3B,YAAY,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAkB,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,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AE,CAAC;QAChC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAW,UAAU,OAAO,CAAC,IAAI,YAAY,EAAE,QAAQ,CAAC,CAAC;IACxF,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Resource
|
|
3
|
+
*/
|
|
4
|
+
import { HttpClient } from '../client.js';
|
|
5
|
+
import type { UsageStats } from '../types.js';
|
|
6
|
+
export declare class UsageResource {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Get usage statistics for the current billing period
|
|
11
|
+
*/
|
|
12
|
+
get(): Promise<UsageStats>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,UAAU;IAI9B;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;CAGnC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Resource
|
|
3
|
+
*/
|
|
4
|
+
export class UsageResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get usage statistics for the current billing period
|
|
11
|
+
*/
|
|
12
|
+
async get() {
|
|
13
|
+
return this.client.get('/v1/usage');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,OAAO,aAAa;IACd,MAAM,CAAa;IAE3B,YAAY,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAa,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Jabrod SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface JabrodConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface KnowledgeBase {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string | null;
|
|
12
|
+
status: 'active' | 'processing' | 'error' | 'archived';
|
|
13
|
+
documentCount: number;
|
|
14
|
+
totalSize: number;
|
|
15
|
+
vectorCount: number;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CreateKBOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Document {
|
|
24
|
+
id: string;
|
|
25
|
+
knowledgeBaseId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: 'file' | 'link' | 'text';
|
|
28
|
+
mimeType: string | null;
|
|
29
|
+
size: number;
|
|
30
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
31
|
+
chunkCount: number;
|
|
32
|
+
errorMessage: string | null;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
processedAt: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface UploadFileOptions {
|
|
37
|
+
kbId: string;
|
|
38
|
+
file: File | Blob;
|
|
39
|
+
filename?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface UploadTextOptions {
|
|
42
|
+
kbId: string;
|
|
43
|
+
content: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface QueryOptions {
|
|
47
|
+
kbId: string;
|
|
48
|
+
query: string;
|
|
49
|
+
topK?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface QueryResult {
|
|
52
|
+
chunks: {
|
|
53
|
+
content: string;
|
|
54
|
+
score: number;
|
|
55
|
+
documentId: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}[];
|
|
58
|
+
query: string;
|
|
59
|
+
latencyMs: number;
|
|
60
|
+
}
|
|
61
|
+
export interface ChatOptions {
|
|
62
|
+
kbId: string;
|
|
63
|
+
message: string;
|
|
64
|
+
model?: string;
|
|
65
|
+
systemPrompt?: string;
|
|
66
|
+
topK?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface ChatResult {
|
|
69
|
+
message: string;
|
|
70
|
+
sources: {
|
|
71
|
+
documentId: string;
|
|
72
|
+
content: string;
|
|
73
|
+
score: number;
|
|
74
|
+
}[];
|
|
75
|
+
model: string;
|
|
76
|
+
latencyMs: number;
|
|
77
|
+
usage?: {
|
|
78
|
+
promptTokens: number;
|
|
79
|
+
completionTokens: number;
|
|
80
|
+
totalTokens: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface UsageStats {
|
|
84
|
+
period: {
|
|
85
|
+
start: string;
|
|
86
|
+
end: string;
|
|
87
|
+
};
|
|
88
|
+
queries: number;
|
|
89
|
+
chats: number;
|
|
90
|
+
documentsProcessed: number;
|
|
91
|
+
tokensUsed: number;
|
|
92
|
+
storageUsedBytes: number;
|
|
93
|
+
tier: string;
|
|
94
|
+
limits: {
|
|
95
|
+
queriesPerMonth: number;
|
|
96
|
+
chatsPerMonth: number;
|
|
97
|
+
storageBytes: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface ApiResponse<T> {
|
|
101
|
+
success: boolean;
|
|
102
|
+
data?: T;
|
|
103
|
+
error?: {
|
|
104
|
+
code: string;
|
|
105
|
+
message: string;
|
|
106
|
+
details?: unknown;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export declare class JabrodError extends Error {
|
|
110
|
+
code: string;
|
|
111
|
+
status: number;
|
|
112
|
+
details?: unknown;
|
|
113
|
+
constructor(code: string, message: string, status?: number, details?: unknown);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,GA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ED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Jabrod SDK
|
|
3
|
+
*/
|
|
4
|
+
// Error
|
|
5
|
+
export class JabrodError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
status;
|
|
8
|
+
details;
|
|
9
|
+
constructor(code, message, status = 400, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'JabrodError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8HH,QAAQ;AACR,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClC,IAAI,CAAS;IACb,MAAM,CAAS;IACf,OAAO,CAAW;IAElB,YAAY,IAAY,EAAE,OAAe,EAAE,SAAiB,GAAG,EAAE,OAAiB;QAC9E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jabrod/sdk",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Official SDK for Jabrod Cloud API - RAG as a Service",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"test": "echo \"No tests yet\""
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"jabrod",
|
|
27
|
+
"rag",
|
|
28
|
+
"ai",
|
|
29
|
+
"knowledge-base",
|
|
30
|
+
"embeddings",
|
|
31
|
+
"llm",
|
|
32
|
+
"openai",
|
|
33
|
+
"vector-database"
|
|
34
|
+
],
|
|
35
|
+
"author": "Jabrod",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/jabrod/sdk"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://docs.jabrod.com",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"typescript": "^5.3.3"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"typescript": ">=4.7"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"typescript": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18"
|
|
55
|
+
}
|
|
56
|
+
}
|