@brownandroot/api 2.0.0 → 2.0.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 +7 -0
- package/dist/businessUnits.remote.d.ts +3 -5
- package/dist/businessUnits.remote.js +3 -8
- package/dist/cache.js +23 -23
- package/dist/costcodes.remote.d.ts +3 -5
- package/dist/costcodes.remote.js +3 -8
- package/dist/employees.remote.d.ts +15 -17
- package/dist/employees.remote.js +7 -16
- package/dist/index.d.ts +31 -3
- package/dist/index.js +25 -4
- package/dist/jobtypejobsteps.remote.d.ts +3 -5
- package/dist/jobtypejobsteps.remote.js +3 -8
- package/dist/llm.remote.d.ts +13 -14
- package/dist/llm.remote.js +3 -6
- package/dist/paytypes.remote.d.ts +3 -5
- package/dist/paytypes.remote.js +3 -8
- package/dist/rag.remote.d.ts +11 -13
- package/dist/rag.remote.js +4 -10
- package/dist/workorders.remote.d.ts +3 -5
- package/dist/workorders.remote.js +3 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,12 +132,19 @@ const chat = await llm.chat({
|
|
|
132
132
|
messages: [{ role: 'user', content: 'Summarize this document.' }],
|
|
133
133
|
source: 'my-app',
|
|
134
134
|
user: 'jane.doe',
|
|
135
|
+
enableRag: true,
|
|
135
136
|
})
|
|
136
137
|
|
|
137
138
|
const docs = await rag.list()
|
|
138
139
|
const results = await rag.search({ query: 'overtime policy', topK: 5 })
|
|
139
140
|
```
|
|
140
141
|
|
|
142
|
+
`llm.chat` RAG flags:
|
|
143
|
+
|
|
144
|
+
- `enableRag: true` tells the backend to enrich the chat prompt with retrieved document context before generating a response.
|
|
145
|
+
- `enableRag: false` (or omitted) sends a normal chat request without forcing retrieval augmentation.
|
|
146
|
+
- `enableRag` is the single supported parameter for toggling default tools/RAG retrieval.
|
|
147
|
+
|
|
141
148
|
## Cache Management
|
|
142
149
|
|
|
143
150
|
```ts
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit | null>;
|
|
5
|
-
};
|
|
1
|
+
export declare const getBusinessUnits: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").BusinessUnit[]>;
|
|
2
|
+
export declare const getBusinessUnitsDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getBusinessUnit: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit | null>;
|
|
@@ -16,11 +16,6 @@ async function asNullable(fetcher) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
export const businessUnits = {
|
|
23
|
-
getAll,
|
|
24
|
-
dropdown,
|
|
25
|
-
get,
|
|
26
|
-
};
|
|
19
|
+
export const getBusinessUnits = query(async () => getClient().getBusinessUnits());
|
|
20
|
+
export const getBusinessUnitsDropdown = query(async () => getClient().getBusinessUnitsDropdown());
|
|
21
|
+
export const getBusinessUnit = query(z.string(), async (id) => asNullable(() => getClient().getBusinessUnit(id)));
|
package/dist/cache.js
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { idbGet, idbSet, idbClear } from './idb.js';
|
|
11
11
|
// Remote functions — called as HTTP on the client, directly on the server (SSR)
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { getEmployees as _getEmployees, getEmployee as _getEmployee, getEmployeePrivileged as _getEmployeePrivileged, getJdeFromEmail as _getJdeFromEmail, getSupervisorChain as _getSupervisorChain, verifyIdentity as _verifyIdentity, } from './employees.remote.js';
|
|
13
|
+
import { getBusinessUnits as _getBusinessUnits, getBusinessUnit as _getBusinessUnit } from './businessUnits.remote.js';
|
|
14
|
+
import { getCostcodes as _getCostcodes, getCostcode as _getCostcode } from './costcodes.remote.js';
|
|
15
|
+
import { getPaytypes as _getPaytypes, getPaytype as _getPaytype } from './paytypes.remote.js';
|
|
16
|
+
import { getWorkorders as _getWorkorders, getWorkorder as _getWorkorder } from './workorders.remote.js';
|
|
17
|
+
import { getJobtypejobsteps as _getJobtypejobsteps, getJobtypejobstep as _getJobtypejobstep, } from './jobtypejobsteps.remote.js';
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
// Internal: stale-while-revalidate fetch helpers
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
@@ -185,7 +185,7 @@ async function applyCostcodeFilters(data, f) {
|
|
|
185
185
|
// Resolve payTypeCode → objectAccount
|
|
186
186
|
let payTypeObjectAccount;
|
|
187
187
|
if (f.payTypeCode !== undefined) {
|
|
188
|
-
const allPaytypes = await loadCached('paytypes', () =>
|
|
188
|
+
const allPaytypes = await loadCached('paytypes', () => _getPaytypes());
|
|
189
189
|
payTypeObjectAccount = allPaytypes.find((p) => p.id === f.payTypeCode)?.objectAccount;
|
|
190
190
|
}
|
|
191
191
|
return data.filter((c) => {
|
|
@@ -216,7 +216,7 @@ async function applyCostcodeFilters(data, f) {
|
|
|
216
216
|
async function getEmployees(filters) {
|
|
217
217
|
let all;
|
|
218
218
|
try {
|
|
219
|
-
all = await loadCached('employees', () =>
|
|
219
|
+
all = await loadCached('employees', () => _getEmployees());
|
|
220
220
|
}
|
|
221
221
|
catch (error) {
|
|
222
222
|
logReadFailure('employees.getAll', error);
|
|
@@ -231,7 +231,7 @@ async function getEmployeesDropdown(filters) {
|
|
|
231
231
|
/** Single employee by ID — always fetches fresh (no IndexedDB). */
|
|
232
232
|
async function getEmployee(employeeId) {
|
|
233
233
|
try {
|
|
234
|
-
return await
|
|
234
|
+
return await _getEmployee(employeeId);
|
|
235
235
|
}
|
|
236
236
|
catch (error) {
|
|
237
237
|
logReadFailure('employees.get', error);
|
|
@@ -240,12 +240,12 @@ async function getEmployee(employeeId) {
|
|
|
240
240
|
}
|
|
241
241
|
/** Single employee by ID including compensation fields — always fetches fresh (no IndexedDB). */
|
|
242
242
|
async function getEmployeePrivileged(employeeId) {
|
|
243
|
-
return
|
|
243
|
+
return _getEmployeePrivileged(employeeId);
|
|
244
244
|
}
|
|
245
245
|
/** Full supervisor chain above an employee — always fetches fresh. */
|
|
246
246
|
async function getSupervisorChain(employeeId) {
|
|
247
247
|
try {
|
|
248
|
-
return await
|
|
248
|
+
return await _getSupervisorChain(employeeId);
|
|
249
249
|
}
|
|
250
250
|
catch (error) {
|
|
251
251
|
logReadFailure('employees.getSupervisorChain', error);
|
|
@@ -255,7 +255,7 @@ async function getSupervisorChain(employeeId) {
|
|
|
255
255
|
/** Look up JDE number and employee from email — always fetches fresh. */
|
|
256
256
|
async function getJdeFromEmail(email) {
|
|
257
257
|
try {
|
|
258
|
-
return await
|
|
258
|
+
return await _getJdeFromEmail(email);
|
|
259
259
|
}
|
|
260
260
|
catch (error) {
|
|
261
261
|
logReadFailure('employees.getJdeFromEmail', error);
|
|
@@ -264,7 +264,7 @@ async function getJdeFromEmail(email) {
|
|
|
264
264
|
}
|
|
265
265
|
/** Verify employee identity — always fetches fresh. */
|
|
266
266
|
async function verifyIdentity(inputs) {
|
|
267
|
-
return
|
|
267
|
+
return _verifyIdentity(inputs);
|
|
268
268
|
}
|
|
269
269
|
// ---------------------------------------------------------------------------
|
|
270
270
|
// Public API — Workorders
|
|
@@ -272,7 +272,7 @@ async function verifyIdentity(inputs) {
|
|
|
272
272
|
async function getWorkorders(filters) {
|
|
273
273
|
let all;
|
|
274
274
|
try {
|
|
275
|
-
all = await loadCached('workorders', () =>
|
|
275
|
+
all = await loadCached('workorders', () => _getWorkorders());
|
|
276
276
|
}
|
|
277
277
|
catch (error) {
|
|
278
278
|
logReadFailure('workorders.getAll', error);
|
|
@@ -287,7 +287,7 @@ async function getWorkordersDropdown(filters) {
|
|
|
287
287
|
/** Single workorder by ID — always fetches fresh (no IndexedDB). */
|
|
288
288
|
async function getWorkorder(id) {
|
|
289
289
|
try {
|
|
290
|
-
return await
|
|
290
|
+
return await _getWorkorder(id);
|
|
291
291
|
}
|
|
292
292
|
catch (error) {
|
|
293
293
|
logReadFailure('workorders.get', error);
|
|
@@ -300,7 +300,7 @@ async function getWorkorder(id) {
|
|
|
300
300
|
async function getCostcodes(filters) {
|
|
301
301
|
let all;
|
|
302
302
|
try {
|
|
303
|
-
all = await loadCached('costcodes', () =>
|
|
303
|
+
all = await loadCached('costcodes', () => _getCostcodes());
|
|
304
304
|
}
|
|
305
305
|
catch (error) {
|
|
306
306
|
logReadFailure('costcodes.getAll', error);
|
|
@@ -322,7 +322,7 @@ async function getCostcodesDropdown(filters) {
|
|
|
322
322
|
/** Single cost code by ID — always fetches fresh (no IndexedDB). */
|
|
323
323
|
async function getCostcode(id) {
|
|
324
324
|
try {
|
|
325
|
-
return await
|
|
325
|
+
return await _getCostcode(id);
|
|
326
326
|
}
|
|
327
327
|
catch (error) {
|
|
328
328
|
logReadFailure('costcodes.get', error);
|
|
@@ -335,7 +335,7 @@ async function getCostcode(id) {
|
|
|
335
335
|
async function getPaytypes(filters) {
|
|
336
336
|
let all;
|
|
337
337
|
try {
|
|
338
|
-
all = await loadCached('paytypes', () =>
|
|
338
|
+
all = await loadCached('paytypes', () => _getPaytypes());
|
|
339
339
|
}
|
|
340
340
|
catch (error) {
|
|
341
341
|
logReadFailure('paytypes.getAll', error);
|
|
@@ -351,7 +351,7 @@ async function getPaytypesDropdown(filters) {
|
|
|
351
351
|
/** Single pay type by ID — always fetches fresh (no IndexedDB). */
|
|
352
352
|
async function getPaytype(id) {
|
|
353
353
|
try {
|
|
354
|
-
return await
|
|
354
|
+
return await _getPaytype(id);
|
|
355
355
|
}
|
|
356
356
|
catch (error) {
|
|
357
357
|
logReadFailure('paytypes.get', error);
|
|
@@ -364,7 +364,7 @@ async function getPaytype(id) {
|
|
|
364
364
|
async function getBusinessUnits(filters) {
|
|
365
365
|
let all;
|
|
366
366
|
try {
|
|
367
|
-
all = await loadCached('businessUnits', () =>
|
|
367
|
+
all = await loadCached('businessUnits', () => _getBusinessUnits());
|
|
368
368
|
}
|
|
369
369
|
catch (error) {
|
|
370
370
|
logReadFailure('businessUnits.getAll', error);
|
|
@@ -380,7 +380,7 @@ async function getBusinessUnitsDropdown(filters) {
|
|
|
380
380
|
/** Single business unit by ID — always fetches fresh (no IndexedDB). */
|
|
381
381
|
async function getBusinessUnit(id) {
|
|
382
382
|
try {
|
|
383
|
-
return await
|
|
383
|
+
return await _getBusinessUnit(id);
|
|
384
384
|
}
|
|
385
385
|
catch (error) {
|
|
386
386
|
logReadFailure('businessUnits.get', error);
|
|
@@ -393,7 +393,7 @@ async function getBusinessUnit(id) {
|
|
|
393
393
|
async function getJobtypejobsteps(filters) {
|
|
394
394
|
let all;
|
|
395
395
|
try {
|
|
396
|
-
all = await loadCached('jobtypejobsteps', () =>
|
|
396
|
+
all = await loadCached('jobtypejobsteps', () => _getJobtypejobsteps());
|
|
397
397
|
}
|
|
398
398
|
catch (error) {
|
|
399
399
|
logReadFailure('jobtypejobsteps.getAll', error);
|
|
@@ -412,7 +412,7 @@ async function getJobtypejobstepsDropdown(filters) {
|
|
|
412
412
|
/** Single job type/job step by ID — always fetches fresh (no IndexedDB). */
|
|
413
413
|
async function getJobtypejobstep(id) {
|
|
414
414
|
try {
|
|
415
|
-
return await
|
|
415
|
+
return await _getJobtypejobstep(id);
|
|
416
416
|
}
|
|
417
417
|
catch (error) {
|
|
418
418
|
logReadFailure('jobtypejobsteps.get', error);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode | null>;
|
|
5
|
-
};
|
|
1
|
+
export declare const getCostcodes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Costcode[]>;
|
|
2
|
+
export declare const getCostcodesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getCostcode: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode | null>;
|
package/dist/costcodes.remote.js
CHANGED
|
@@ -16,11 +16,6 @@ async function asNullable(fetcher) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
export const costcodes = {
|
|
23
|
-
getAll,
|
|
24
|
-
dropdown,
|
|
25
|
-
get,
|
|
26
|
-
};
|
|
19
|
+
export const getCostcodes = query(async () => getClient().getCostcodes());
|
|
20
|
+
export const getCostcodesDropdown = query(async () => getClient().getCostcodesDropdown());
|
|
21
|
+
export const getCostcode = query(z.string(), async (id) => asNullable(() => getClient().getCostcode(id)));
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, Promise<import("./index.js").Employee | null>>;
|
|
17
|
-
};
|
|
1
|
+
export declare const getEmployees: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Employee[]>;
|
|
2
|
+
export declare const getEmployeesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getEmployee: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee | null>;
|
|
4
|
+
export declare const getEmployeePrivileged: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").EmployeePrivileged>;
|
|
5
|
+
export declare const getSupervisorChain: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
6
|
+
export declare const getJdeFromEmail: import("@sveltejs/kit").RemoteQueryFunction<string, {
|
|
7
|
+
jde: string | null;
|
|
8
|
+
employee: import("./index.js").Employee | null;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const verifyIdentity: import("@sveltejs/kit").RemoteCommand<{
|
|
11
|
+
first3FirstName: string;
|
|
12
|
+
first3LastName: string;
|
|
13
|
+
dob: string;
|
|
14
|
+
ssn4: string;
|
|
15
|
+
}, Promise<import("./index.js").Employee | null>>;
|
package/dist/employees.remote.js
CHANGED
|
@@ -23,19 +23,10 @@ const verifyIdentitySchema = z.object({
|
|
|
23
23
|
dob: z.string(),
|
|
24
24
|
ssn4: z.string(),
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
31
|
-
const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
|
32
|
-
const verifyIdentity = command(verifyIdentitySchema, async (inputs) => getClient().verifyIdentity(inputs));
|
|
33
|
-
export const employees = {
|
|
34
|
-
getAll,
|
|
35
|
-
dropdown,
|
|
36
|
-
get,
|
|
37
|
-
getPrivileged,
|
|
38
|
-
getSupervisorChain,
|
|
39
|
-
getJdeFromEmail,
|
|
40
|
-
verifyIdentity,
|
|
41
|
-
};
|
|
26
|
+
export const getEmployees = query(async () => getClient().getEmployees());
|
|
27
|
+
export const getEmployeesDropdown = query(async () => getClient().getEmployeesDropdown());
|
|
28
|
+
export const getEmployee = query(employeeIdSchema, async (employeeId) => asNullable(() => getClient().getEmployee(employeeId)));
|
|
29
|
+
export const getEmployeePrivileged = query(employeeIdSchema, async (employeeId) => getClient().getEmployeePrivileged(employeeId));
|
|
30
|
+
export const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
31
|
+
export const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
|
32
|
+
export const verifyIdentity = command(verifyIdentitySchema, async (inputs) => getClient().verifyIdentity(inputs));
|
package/dist/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ export interface ChatRequest {
|
|
|
112
112
|
function?: string;
|
|
113
113
|
temperature?: number;
|
|
114
114
|
maxTokens?: number;
|
|
115
|
+
/** Flag to enable RAG context enrichment in chat responses. */
|
|
116
|
+
enableRag?: boolean;
|
|
115
117
|
}
|
|
116
118
|
export interface ChatResponse {
|
|
117
119
|
message: ChatMessage;
|
|
@@ -149,7 +151,7 @@ export interface StreamChatRequest {
|
|
|
149
151
|
content: string;
|
|
150
152
|
}[];
|
|
151
153
|
userContext?: StreamChatUserContext;
|
|
152
|
-
|
|
154
|
+
enableRag?: boolean;
|
|
153
155
|
tools?: string[];
|
|
154
156
|
source?: string;
|
|
155
157
|
}
|
|
@@ -319,6 +321,32 @@ export declare class ApiHubClient {
|
|
|
319
321
|
getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
|
320
322
|
}
|
|
321
323
|
export { employees, workorders, costcodes, paytypes, businessUnits, jobtypejobsteps, clearCache } from './cache.js';
|
|
322
|
-
export
|
|
323
|
-
|
|
324
|
+
export declare const llm: {
|
|
325
|
+
getLogs: import("@sveltejs/kit").RemoteQueryFunction<void, LlmLog[]>;
|
|
326
|
+
chat: import("@sveltejs/kit").RemoteCommand<{
|
|
327
|
+
user: string;
|
|
328
|
+
messages: {
|
|
329
|
+
role: "system" | "user" | "assistant";
|
|
330
|
+
content: string;
|
|
331
|
+
}[];
|
|
332
|
+
source: string;
|
|
333
|
+
function?: string | undefined;
|
|
334
|
+
temperature?: number | undefined;
|
|
335
|
+
maxTokens?: number | undefined;
|
|
336
|
+
enableRag?: boolean | undefined;
|
|
337
|
+
}, Promise<ChatResponse>>;
|
|
338
|
+
};
|
|
339
|
+
export declare const rag: {
|
|
340
|
+
list: import("@sveltejs/kit").RemoteQueryFunction<void, DocumentRecord[]>;
|
|
341
|
+
upload: import("@sveltejs/kit").RemoteCommand<{
|
|
342
|
+
fileName: string;
|
|
343
|
+
base64Content: string;
|
|
344
|
+
uploadedBy: string;
|
|
345
|
+
}, Promise<DocumentRecord>>;
|
|
346
|
+
delete: import("@sveltejs/kit").RemoteCommand<number, Promise<void>>;
|
|
347
|
+
search: import("@sveltejs/kit").RemoteCommand<{
|
|
348
|
+
query: string;
|
|
349
|
+
topK?: number | undefined;
|
|
350
|
+
}, Promise<SearchResult[]>>;
|
|
351
|
+
};
|
|
324
352
|
export type { EmployeeFilters, WorkorderFilters, CostcodeFilters, PaytypeFilters, BusinessUnitFilters, JobtypejobstepFilters, } from './cache.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getLlmLogs, chat as llmChat } from './llm.remote.js';
|
|
2
|
+
import { listDocuments, uploadDocument, deleteDocument, searchDocuments } from './rag.remote.js';
|
|
1
3
|
export class ApiHubError extends Error {
|
|
2
4
|
status;
|
|
3
5
|
path;
|
|
@@ -220,6 +222,11 @@ export class ApiHubClient {
|
|
|
220
222
|
}
|
|
221
223
|
/** Send a chat completion request to the LLM */
|
|
222
224
|
async chat(request) {
|
|
225
|
+
const { enableRag, ...rest } = request;
|
|
226
|
+
const payload = { ...rest };
|
|
227
|
+
if (enableRag !== undefined) {
|
|
228
|
+
payload.enableRag = enableRag;
|
|
229
|
+
}
|
|
223
230
|
let res;
|
|
224
231
|
try {
|
|
225
232
|
res = await fetch(`${this.baseUrl}/llm/chat`, {
|
|
@@ -228,7 +235,7 @@ export class ApiHubClient {
|
|
|
228
235
|
'x-api-key': this.apiKey,
|
|
229
236
|
'Content-Type': 'application/json',
|
|
230
237
|
},
|
|
231
|
-
body: JSON.stringify(
|
|
238
|
+
body: JSON.stringify(payload),
|
|
232
239
|
});
|
|
233
240
|
}
|
|
234
241
|
catch {
|
|
@@ -247,6 +254,12 @@ export class ApiHubClient {
|
|
|
247
254
|
// -----------------------------------------------------------------------
|
|
248
255
|
/** Start a streaming chat session — returns the raw SSE Response for proxying */
|
|
249
256
|
async chatStream(request) {
|
|
257
|
+
const { enableRag, ...rest } = request;
|
|
258
|
+
const payload = { ...rest };
|
|
259
|
+
if (enableRag !== undefined) {
|
|
260
|
+
// Streaming endpoint currently expects useRag in payload.
|
|
261
|
+
payload.useRag = enableRag;
|
|
262
|
+
}
|
|
250
263
|
let res;
|
|
251
264
|
try {
|
|
252
265
|
res = await fetch(`${this.baseUrl}/ai/chat/stream`, {
|
|
@@ -255,7 +268,7 @@ export class ApiHubClient {
|
|
|
255
268
|
'x-api-key': this.apiKey,
|
|
256
269
|
'Content-Type': 'application/json',
|
|
257
270
|
},
|
|
258
|
-
body: JSON.stringify(
|
|
271
|
+
body: JSON.stringify(payload),
|
|
259
272
|
});
|
|
260
273
|
}
|
|
261
274
|
catch {
|
|
@@ -429,5 +442,13 @@ export class ApiHubClient {
|
|
|
429
442
|
}
|
|
430
443
|
}
|
|
431
444
|
export { employees, workorders, costcodes, paytypes, businessUnits, jobtypejobsteps, clearCache } from './cache.js';
|
|
432
|
-
export
|
|
433
|
-
|
|
445
|
+
export const llm = {
|
|
446
|
+
getLogs: getLlmLogs,
|
|
447
|
+
chat: llmChat,
|
|
448
|
+
};
|
|
449
|
+
export const rag = {
|
|
450
|
+
list: listDocuments,
|
|
451
|
+
upload: uploadDocument,
|
|
452
|
+
delete: deleteDocument,
|
|
453
|
+
search: searchDocuments,
|
|
454
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Jobtypejobstep | null>;
|
|
5
|
-
};
|
|
1
|
+
export declare const getJobtypejobsteps: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Jobtypejobstep[]>;
|
|
2
|
+
export declare const getJobtypejobstepsDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getJobtypejobstep: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Jobtypejobstep | null>;
|
|
@@ -16,11 +16,6 @@ async function asNullable(fetcher) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
export const jobtypejobsteps = {
|
|
23
|
-
getAll,
|
|
24
|
-
dropdown,
|
|
25
|
-
get,
|
|
26
|
-
};
|
|
19
|
+
export const getJobtypejobsteps = query(async () => getClient().getJobtypejobsteps());
|
|
20
|
+
export const getJobtypejobstepsDropdown = query(async () => getClient().getJobtypejobstepsDropdown());
|
|
21
|
+
export const getJobtypejobstep = query(z.string(), async (id) => asNullable(() => getClient().getJobtypejobstep(id)));
|
package/dist/llm.remote.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
1
|
+
export declare const getLlmLogs: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").LlmLog[]>;
|
|
2
|
+
export declare const chat: import("@sveltejs/kit").RemoteCommand<{
|
|
3
|
+
user: string;
|
|
4
|
+
messages: {
|
|
5
|
+
role: "system" | "user" | "assistant";
|
|
6
|
+
content: string;
|
|
7
|
+
}[];
|
|
8
|
+
source: string;
|
|
9
|
+
function?: string | undefined;
|
|
10
|
+
temperature?: number | undefined;
|
|
11
|
+
maxTokens?: number | undefined;
|
|
12
|
+
enableRag?: boolean | undefined;
|
|
13
|
+
}, Promise<import("./index.js").ChatResponse>>;
|
package/dist/llm.remote.js
CHANGED
|
@@ -12,10 +12,7 @@ const chatRequestSchema = z.object({
|
|
|
12
12
|
function: z.string().optional(),
|
|
13
13
|
temperature: z.number().min(0).max(2).optional(),
|
|
14
14
|
maxTokens: z.number().int().positive().optional(),
|
|
15
|
+
enableRag: z.boolean().optional(),
|
|
15
16
|
});
|
|
16
|
-
const
|
|
17
|
-
const chat = command(chatRequestSchema, async (request) => getClient().chat(request));
|
|
18
|
-
export const llm = {
|
|
19
|
-
getLogs,
|
|
20
|
-
chat,
|
|
21
|
-
};
|
|
17
|
+
export const getLlmLogs = query(async () => getClient().getLlmLogs());
|
|
18
|
+
export const chat = command(chatRequestSchema, async (request) => getClient().chat(request));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype | null>;
|
|
5
|
-
};
|
|
1
|
+
export declare const getPaytypes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Paytype[]>;
|
|
2
|
+
export declare const getPaytypesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").PaytypeDropdownOption[]>;
|
|
3
|
+
export declare const getPaytype: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype | null>;
|
package/dist/paytypes.remote.js
CHANGED
|
@@ -16,11 +16,6 @@ async function asNullable(fetcher) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
export const paytypes = {
|
|
23
|
-
getAll,
|
|
24
|
-
dropdown,
|
|
25
|
-
get,
|
|
26
|
-
};
|
|
19
|
+
export const getPaytypes = query(async () => getClient().getPaytypes());
|
|
20
|
+
export const getPaytypesDropdown = query(async () => getClient().getPaytypesDropdown());
|
|
21
|
+
export const getPaytype = query(z.string(), async (id) => asNullable(() => getClient().getPaytype(id)));
|
package/dist/rag.remote.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, Promise<import("./index.js").SearchResult[]>>;
|
|
13
|
-
};
|
|
1
|
+
export declare const listDocuments: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DocumentRecord[]>;
|
|
2
|
+
export declare const uploadDocument: import("@sveltejs/kit").RemoteCommand<{
|
|
3
|
+
fileName: string;
|
|
4
|
+
base64Content: string;
|
|
5
|
+
uploadedBy: string;
|
|
6
|
+
}, Promise<import("./index.js").DocumentRecord>>;
|
|
7
|
+
export declare const deleteDocument: import("@sveltejs/kit").RemoteCommand<number, Promise<void>>;
|
|
8
|
+
export declare const searchDocuments: import("@sveltejs/kit").RemoteCommand<{
|
|
9
|
+
query: string;
|
|
10
|
+
topK?: number | undefined;
|
|
11
|
+
}, Promise<import("./index.js").SearchResult[]>>;
|
package/dist/rag.remote.js
CHANGED
|
@@ -10,13 +10,7 @@ const searchDocumentsSchema = z.object({
|
|
|
10
10
|
query: z.string().min(1),
|
|
11
11
|
topK: z.number().int().positive().optional(),
|
|
12
12
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
export const rag = {
|
|
18
|
-
list,
|
|
19
|
-
upload,
|
|
20
|
-
delete: remove,
|
|
21
|
-
search,
|
|
22
|
-
};
|
|
13
|
+
export const listDocuments = query(async () => getClient().listDocuments());
|
|
14
|
+
export const uploadDocument = command(uploadDocumentSchema, async ({ fileName, base64Content, uploadedBy }) => getClient().uploadDocument(fileName, base64Content, uploadedBy));
|
|
15
|
+
export const deleteDocument = command(z.number().int().positive(), async (id) => getClient().deleteDocument(id));
|
|
16
|
+
export const searchDocuments = command(searchDocumentsSchema, async ({ query: q, topK }) => getClient().searchDocuments(q, topK));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder | null>;
|
|
5
|
-
};
|
|
1
|
+
export declare const getWorkorders: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Workorder[]>;
|
|
2
|
+
export declare const getWorkordersDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
+
export declare const getWorkorder: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder | null>;
|
|
@@ -16,11 +16,6 @@ async function asNullable(fetcher) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
export const workorders = {
|
|
23
|
-
getAll,
|
|
24
|
-
dropdown,
|
|
25
|
-
get,
|
|
26
|
-
};
|
|
19
|
+
export const getWorkorders = query(async () => getClient().getWorkorders());
|
|
20
|
+
export const getWorkordersDropdown = query(async () => getClient().getWorkordersDropdown());
|
|
21
|
+
export const getWorkorder = query(z.string(), async (id) => asNullable(() => getClient().getWorkorder(id)));
|