swiftbase-admin-sdk 1.0.3 → 1.0.4
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/dist/index.cjs +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -378,21 +378,56 @@ declare class Storage {
|
|
|
378
378
|
deleteObject(key: string): Promise<void>;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
interface AIToolCall {
|
|
382
|
+
id: string;
|
|
383
|
+
type: "function";
|
|
384
|
+
function: {
|
|
385
|
+
name: string;
|
|
386
|
+
arguments: string;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
interface AITool {
|
|
390
|
+
type: "function";
|
|
391
|
+
function: {
|
|
392
|
+
name: string;
|
|
393
|
+
description?: string;
|
|
394
|
+
parameters?: Record<string, any>;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
381
397
|
interface AIChatMessage {
|
|
382
|
-
role: "system" | "user" | "assistant";
|
|
383
|
-
content
|
|
398
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
399
|
+
content?: string | null;
|
|
400
|
+
name?: string;
|
|
401
|
+
tool_call_id?: string;
|
|
402
|
+
tool_calls?: AIToolCall[];
|
|
384
403
|
}
|
|
385
404
|
interface AIChatCompletionOptions {
|
|
386
405
|
model?: string;
|
|
387
406
|
messages: AIChatMessage[];
|
|
407
|
+
tools?: AITool[];
|
|
408
|
+
tool_choice?: any;
|
|
409
|
+
temperature?: number;
|
|
410
|
+
max_tokens?: number;
|
|
388
411
|
}
|
|
389
412
|
interface AIChatCompletionResponse {
|
|
413
|
+
id?: string;
|
|
414
|
+
object?: string;
|
|
415
|
+
created?: number;
|
|
416
|
+
model?: string;
|
|
390
417
|
choices: Array<{
|
|
418
|
+
index?: number;
|
|
391
419
|
message: {
|
|
392
420
|
role: string;
|
|
393
|
-
content: string;
|
|
421
|
+
content: string | null;
|
|
422
|
+
tool_calls?: AIToolCall[];
|
|
394
423
|
};
|
|
424
|
+
finish_reason?: string;
|
|
395
425
|
}>;
|
|
426
|
+
usage?: {
|
|
427
|
+
prompt_tokens: number;
|
|
428
|
+
completion_tokens: number;
|
|
429
|
+
total_tokens: number;
|
|
430
|
+
};
|
|
396
431
|
}
|
|
397
432
|
/**
|
|
398
433
|
* Generate completion using the AI service.
|
package/dist/index.d.ts
CHANGED
|
@@ -378,21 +378,56 @@ declare class Storage {
|
|
|
378
378
|
deleteObject(key: string): Promise<void>;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
interface AIToolCall {
|
|
382
|
+
id: string;
|
|
383
|
+
type: "function";
|
|
384
|
+
function: {
|
|
385
|
+
name: string;
|
|
386
|
+
arguments: string;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
interface AITool {
|
|
390
|
+
type: "function";
|
|
391
|
+
function: {
|
|
392
|
+
name: string;
|
|
393
|
+
description?: string;
|
|
394
|
+
parameters?: Record<string, any>;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
381
397
|
interface AIChatMessage {
|
|
382
|
-
role: "system" | "user" | "assistant";
|
|
383
|
-
content
|
|
398
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
399
|
+
content?: string | null;
|
|
400
|
+
name?: string;
|
|
401
|
+
tool_call_id?: string;
|
|
402
|
+
tool_calls?: AIToolCall[];
|
|
384
403
|
}
|
|
385
404
|
interface AIChatCompletionOptions {
|
|
386
405
|
model?: string;
|
|
387
406
|
messages: AIChatMessage[];
|
|
407
|
+
tools?: AITool[];
|
|
408
|
+
tool_choice?: any;
|
|
409
|
+
temperature?: number;
|
|
410
|
+
max_tokens?: number;
|
|
388
411
|
}
|
|
389
412
|
interface AIChatCompletionResponse {
|
|
413
|
+
id?: string;
|
|
414
|
+
object?: string;
|
|
415
|
+
created?: number;
|
|
416
|
+
model?: string;
|
|
390
417
|
choices: Array<{
|
|
418
|
+
index?: number;
|
|
391
419
|
message: {
|
|
392
420
|
role: string;
|
|
393
|
-
content: string;
|
|
421
|
+
content: string | null;
|
|
422
|
+
tool_calls?: AIToolCall[];
|
|
394
423
|
};
|
|
424
|
+
finish_reason?: string;
|
|
395
425
|
}>;
|
|
426
|
+
usage?: {
|
|
427
|
+
prompt_tokens: number;
|
|
428
|
+
completion_tokens: number;
|
|
429
|
+
total_tokens: number;
|
|
430
|
+
};
|
|
396
431
|
}
|
|
397
432
|
/**
|
|
398
433
|
* Generate completion using the AI service.
|
package/dist/index.js
CHANGED
|
@@ -4581,13 +4581,39 @@ function parseListBuckets(xml) {
|
|
|
4581
4581
|
}
|
|
4582
4582
|
return buckets;
|
|
4583
4583
|
}
|
|
4584
|
-
function parseListObjects(
|
|
4585
|
-
const
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4584
|
+
function parseListObjects(text) {
|
|
4585
|
+
const trimmed = text.trim();
|
|
4586
|
+
if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
|
|
4587
|
+
try {
|
|
4588
|
+
const parsed = JSON.parse(trimmed);
|
|
4589
|
+
const items = Array.isArray(parsed) ? parsed : parsed.contents || [];
|
|
4590
|
+
const contents2 = items.map((item) => {
|
|
4591
|
+
const pathPrefix = item.path && item.path !== "/" ? item.path.replace(/\/$/, "") + "/" : "";
|
|
4592
|
+
const key = item.key || (item.name ? `${pathPrefix}${item.name}` : "");
|
|
4593
|
+
return {
|
|
4594
|
+
key,
|
|
4595
|
+
lastModified: item.modified || item.lastModified,
|
|
4596
|
+
etag: item.etag,
|
|
4597
|
+
size: item.size || 0
|
|
4598
|
+
};
|
|
4599
|
+
});
|
|
4600
|
+
return {
|
|
4601
|
+
name: "",
|
|
4602
|
+
prefix: "",
|
|
4603
|
+
maxKeys: contents2.length,
|
|
4604
|
+
isTruncated: false,
|
|
4605
|
+
contents: contents2,
|
|
4606
|
+
commonPrefixes: []
|
|
4607
|
+
};
|
|
4608
|
+
} catch (e) {
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4611
|
+
const nameMatch = text.match(/<Name>(.*?)<\/Name>/);
|
|
4612
|
+
const prefixMatch = text.match(/<Prefix>(.*?)<\/Prefix>/);
|
|
4613
|
+
const maxKeysMatch = text.match(/<MaxKeys>(.*?)<\/MaxKeys>/);
|
|
4614
|
+
const isTruncatedMatch = text.match(/<IsTruncated>(.*?)<\/IsTruncated>/);
|
|
4589
4615
|
const contents = [];
|
|
4590
|
-
const contentMatches =
|
|
4616
|
+
const contentMatches = text.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g);
|
|
4591
4617
|
for (const match of contentMatches) {
|
|
4592
4618
|
const content = match[1];
|
|
4593
4619
|
const keyMatch = content.match(/<Key>(.*?)<\/Key>/);
|
|
@@ -4604,11 +4630,11 @@ function parseListObjects(xml) {
|
|
|
4604
4630
|
}
|
|
4605
4631
|
}
|
|
4606
4632
|
const commonPrefixes = [];
|
|
4607
|
-
const cpMatches =
|
|
4633
|
+
const cpMatches = text.matchAll(/<CommonPrefixes>([\s\S]*?)<\/CommonPrefixes>/g);
|
|
4608
4634
|
for (const match of cpMatches) {
|
|
4609
|
-
const
|
|
4610
|
-
if (
|
|
4611
|
-
commonPrefixes.push(
|
|
4635
|
+
const pMatch = match[1].match(/<Prefix>(.*?)<\/Prefix>/);
|
|
4636
|
+
if (pMatch) {
|
|
4637
|
+
commonPrefixes.push(pMatch[1]);
|
|
4612
4638
|
}
|
|
4613
4639
|
}
|
|
4614
4640
|
return {
|
|
@@ -4777,7 +4803,11 @@ var ai = {
|
|
|
4777
4803
|
create: (options) => __async(null, null, function* () {
|
|
4778
4804
|
return yield makeRequest("post" /* POST */, "/api/ai/chat/completions", void 0, {
|
|
4779
4805
|
model: options.model || "gemini-3.5-flash",
|
|
4780
|
-
messages: options.messages
|
|
4806
|
+
messages: options.messages,
|
|
4807
|
+
tools: options.tools,
|
|
4808
|
+
tool_choice: options.tool_choice,
|
|
4809
|
+
temperature: options.temperature,
|
|
4810
|
+
max_tokens: options.max_tokens
|
|
4781
4811
|
});
|
|
4782
4812
|
})
|
|
4783
4813
|
}
|