@loopstack/ai-module 0.15.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/LICENSE +19 -0
- package/README.md +2 -0
- package/dist/ai.module.d.ts +2 -0
- package/dist/ai.module.js +50 -0
- package/dist/ai.module.js.map +1 -0
- package/dist/documents/ai-message-document.d.ts +3 -0
- package/dist/documents/ai-message-document.js +38 -0
- package/dist/documents/ai-message-document.js.map +1 -0
- package/dist/documents/ai-message-document.yaml +5 -0
- package/dist/documents/index.d.ts +1 -0
- package/dist/documents/index.js +18 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/anthropic.provider.d.ts +5 -0
- package/dist/providers/anthropic.provider.js +29 -0
- package/dist/providers/anthropic.provider.js.map +1 -0
- package/dist/providers/openai.provider.d.ts +5 -0
- package/dist/providers/openai.provider.js +29 -0
- package/dist/providers/openai.provider.js.map +1 -0
- package/dist/schemas/ai-generate-tool-base.schema.d.ts +57 -0
- package/dist/schemas/ai-generate-tool-base.schema.js +23 -0
- package/dist/schemas/ai-generate-tool-base.schema.js.map +1 -0
- package/dist/services/ai-messages-helper.service.d.ts +9 -0
- package/dist/services/ai-messages-helper.service.js +30 -0
- package/dist/services/ai-messages-helper.service.js.map +1 -0
- package/dist/services/ai-provider-model-helper.service.d.ts +15 -0
- package/dist/services/ai-provider-model-helper.service.js +57 -0
- package/dist/services/ai-provider-model-helper.service.js.map +1 -0
- package/dist/services/ai-provider-registry.service.d.ts +15 -0
- package/dist/services/ai-provider-registry.service.js +73 -0
- package/dist/services/ai-provider-registry.service.js.map +1 -0
- package/dist/services/ai-tools-helper.service.d.ts +4 -0
- package/dist/services/ai-tools-helper.service.js +34 -0
- package/dist/services/ai-tools-helper.service.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +21 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tools/ai-generate-document.tool.d.ts +10 -0
- package/dist/tools/ai-generate-document.tool.js +50 -0
- package/dist/tools/ai-generate-document.tool.js.map +1 -0
- package/dist/tools/ai-generate-object.tool.d.ts +89 -0
- package/dist/tools/ai-generate-object.tool.js +85 -0
- package/dist/tools/ai-generate-object.tool.js.map +1 -0
- package/dist/tools/ai-generate-text.tool.d.ts +77 -0
- package/dist/tools/ai-generate-text.tool.js +112 -0
- package/dist/tools/ai-generate-text.tool.js.map +1 -0
- package/dist/tools/delegate-tool-call.tool.d.ts +16 -0
- package/dist/tools/delegate-tool-call.tool.js +57 -0
- package/dist/tools/delegate-tool-call.tool.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +21 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai-messages-helper.service"), exports);
|
|
18
|
+
__exportStar(require("./ai-provider-model-helper.service"), exports);
|
|
19
|
+
__exportStar(require("./ai-messages-helper.service"), exports);
|
|
20
|
+
__exportStar(require("./ai-tools-helper.service"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,qEAAmD;AACnD,+DAA6C;AAC7C,4DAA0C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToolResult } from '@loopstack/common';
|
|
2
|
+
import { Block, ToolBase } from '@loopstack/core';
|
|
3
|
+
import { AiGenerateObject, AiGenerateObjectArgsType } from './ai-generate-object.tool';
|
|
4
|
+
import { WorkflowExecution } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-execution.interface';
|
|
5
|
+
import { CreateDocument } from '@loopstack/core-ui-module';
|
|
6
|
+
export declare class AiGenerateDocument extends ToolBase<AiGenerateObjectArgsType> {
|
|
7
|
+
aiGenerateObject: AiGenerateObject;
|
|
8
|
+
createDocument: CreateDocument;
|
|
9
|
+
execute(args: AiGenerateObjectArgsType, ctx: WorkflowExecution, parent: Block): Promise<ToolResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AiGenerateDocument = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const common_2 = require("@loopstack/common");
|
|
15
|
+
const core_1 = require("@loopstack/core");
|
|
16
|
+
const ai_generate_object_tool_1 = require("./ai-generate-object.tool");
|
|
17
|
+
const core_ui_module_1 = require("@loopstack/core-ui-module");
|
|
18
|
+
let AiGenerateDocument = class AiGenerateDocument extends core_1.ToolBase {
|
|
19
|
+
aiGenerateObject;
|
|
20
|
+
createDocument;
|
|
21
|
+
async execute(args, ctx, parent) {
|
|
22
|
+
const result = await this.getTool('aiGenerateObject').execute(args, ctx, parent);
|
|
23
|
+
return this.getTool('createDocument').execute({
|
|
24
|
+
id: args.response.id,
|
|
25
|
+
document: args.response.document,
|
|
26
|
+
update: {
|
|
27
|
+
content: result.data,
|
|
28
|
+
},
|
|
29
|
+
}, ctx, parent);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.AiGenerateDocument = AiGenerateDocument;
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, common_2.Tool)(),
|
|
35
|
+
__metadata("design:type", ai_generate_object_tool_1.AiGenerateObject)
|
|
36
|
+
], AiGenerateDocument.prototype, "aiGenerateObject", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, common_2.Tool)(),
|
|
39
|
+
__metadata("design:type", core_ui_module_1.CreateDocument)
|
|
40
|
+
], AiGenerateDocument.prototype, "createDocument", void 0);
|
|
41
|
+
exports.AiGenerateDocument = AiGenerateDocument = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
(0, common_2.BlockConfig)({
|
|
44
|
+
config: {
|
|
45
|
+
description: 'Generates a structured object using a LLM and creates it as document',
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
(0, common_2.WithArguments)(ai_generate_object_tool_1.AiGenerateObjectSchema)
|
|
49
|
+
], AiGenerateDocument);
|
|
50
|
+
//# sourceMappingURL=ai-generate-document.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-generate-document.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-document.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,8CAK2B;AAC3B,0CAAkD;AAClD,uEAImC;AAEnC,8DAA2D;AAUpD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,eAAkC;IAChE,gBAAgB,CAAmB;IACnC,cAAc,CAAiB;IAEvC,KAAK,CAAC,OAAO,CACX,IAA8B,EAC9B,GAAsB,EACtB,MAAa;QAEb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAC3C;YACE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAChC,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM,CAAC,IAAI;aACrB;SACF,EACD,GAAG,EACH,MAAM,CACP,CAAC;IACJ,CAAC;CACF,CAAA;AAtBY,gDAAkB;AACrB;IAAP,IAAA,aAAI,GAAE;8BAAmB,0CAAgB;4DAAC;AACnC;IAAP,IAAA,aAAI,GAAE;8BAAiB,+BAAc;0DAAC;6BAF5B,kBAAkB;IAR9B,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EACT,sEAAsE;SACzE;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gDAAsB,CAAC;GACzB,kBAAkB,CAsB9B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ToolResult } from '@loopstack/common';
|
|
3
|
+
import { ToolBase, WorkflowBase } from '@loopstack/core';
|
|
4
|
+
import { AiMessagesHelperService } from '../services';
|
|
5
|
+
import { AiProviderModelHelperService } from '../services';
|
|
6
|
+
import { WorkflowExecution } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-execution.interface';
|
|
7
|
+
export declare const AiGenerateObjectSchema: z.ZodObject<{
|
|
8
|
+
llm: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
model: z.ZodOptional<z.ZodString>;
|
|
10
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
11
|
+
envApiKey: z.ZodOptional<z.ZodString>;
|
|
12
|
+
cacheResponse: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
model?: string;
|
|
15
|
+
provider?: string;
|
|
16
|
+
envApiKey?: string;
|
|
17
|
+
cacheResponse?: boolean;
|
|
18
|
+
}, {
|
|
19
|
+
model?: string;
|
|
20
|
+
provider?: string;
|
|
21
|
+
envApiKey?: string;
|
|
22
|
+
cacheResponse?: boolean;
|
|
23
|
+
}>>;
|
|
24
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
role: z.ZodEnum<["system", "assistant", "user", "tool"]>;
|
|
26
|
+
content: z.ZodAny;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
29
|
+
content?: any;
|
|
30
|
+
}, {
|
|
31
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
32
|
+
content?: any;
|
|
33
|
+
}>, "many">>;
|
|
34
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
35
|
+
messagesSearchTag: z.ZodOptional<z.ZodString>;
|
|
36
|
+
} & {
|
|
37
|
+
response: z.ZodObject<{
|
|
38
|
+
id: z.ZodOptional<z.ZodString>;
|
|
39
|
+
document: z.ZodString;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
id?: string;
|
|
42
|
+
document?: string;
|
|
43
|
+
}, {
|
|
44
|
+
id?: string;
|
|
45
|
+
document?: string;
|
|
46
|
+
}>;
|
|
47
|
+
}, "strict", z.ZodTypeAny, {
|
|
48
|
+
llm?: {
|
|
49
|
+
model?: string;
|
|
50
|
+
provider?: string;
|
|
51
|
+
envApiKey?: string;
|
|
52
|
+
cacheResponse?: boolean;
|
|
53
|
+
};
|
|
54
|
+
messages?: {
|
|
55
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
56
|
+
content?: any;
|
|
57
|
+
}[];
|
|
58
|
+
prompt?: string;
|
|
59
|
+
messagesSearchTag?: string;
|
|
60
|
+
response?: {
|
|
61
|
+
id?: string;
|
|
62
|
+
document?: string;
|
|
63
|
+
};
|
|
64
|
+
}, {
|
|
65
|
+
llm?: {
|
|
66
|
+
model?: string;
|
|
67
|
+
provider?: string;
|
|
68
|
+
envApiKey?: string;
|
|
69
|
+
cacheResponse?: boolean;
|
|
70
|
+
};
|
|
71
|
+
messages?: {
|
|
72
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
73
|
+
content?: any;
|
|
74
|
+
}[];
|
|
75
|
+
prompt?: string;
|
|
76
|
+
messagesSearchTag?: string;
|
|
77
|
+
response?: {
|
|
78
|
+
id?: string;
|
|
79
|
+
document?: string;
|
|
80
|
+
};
|
|
81
|
+
}>;
|
|
82
|
+
export type AiGenerateObjectArgsType = z.infer<typeof AiGenerateObjectSchema>;
|
|
83
|
+
export declare class AiGenerateObject extends ToolBase<AiGenerateObjectArgsType> {
|
|
84
|
+
private readonly aiMessagesHelperService;
|
|
85
|
+
private readonly aiProviderModelHelperService;
|
|
86
|
+
constructor(aiMessagesHelperService: AiMessagesHelperService, aiProviderModelHelperService: AiProviderModelHelperService);
|
|
87
|
+
execute(args: AiGenerateObjectArgsType, ctx: WorkflowExecution, parent: WorkflowBase): Promise<ToolResult>;
|
|
88
|
+
private handleGenerateObject;
|
|
89
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AiGenerateObject = exports.AiGenerateObjectSchema = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const lodash_1 = require("lodash");
|
|
16
|
+
const ai_1 = require("ai");
|
|
17
|
+
const core_1 = require("@loopstack/core");
|
|
18
|
+
const services_1 = require("../services");
|
|
19
|
+
const services_2 = require("../services");
|
|
20
|
+
const ai_generate_tool_base_schema_1 = require("../schemas/ai-generate-tool-base.schema");
|
|
21
|
+
exports.AiGenerateObjectSchema = ai_generate_tool_base_schema_1.AiGenerateToolBaseSchema.extend({
|
|
22
|
+
response: zod_1.z.object({
|
|
23
|
+
id: zod_1.z.string().optional(),
|
|
24
|
+
document: zod_1.z.string(),
|
|
25
|
+
}),
|
|
26
|
+
}).strict();
|
|
27
|
+
let AiGenerateObject = class AiGenerateObject extends core_1.ToolBase {
|
|
28
|
+
aiMessagesHelperService;
|
|
29
|
+
aiProviderModelHelperService;
|
|
30
|
+
constructor(aiMessagesHelperService, aiProviderModelHelperService) {
|
|
31
|
+
super();
|
|
32
|
+
this.aiMessagesHelperService = aiMessagesHelperService;
|
|
33
|
+
this.aiProviderModelHelperService = aiProviderModelHelperService;
|
|
34
|
+
}
|
|
35
|
+
async execute(args, ctx, parent) {
|
|
36
|
+
const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
|
|
37
|
+
const options = {};
|
|
38
|
+
if (args.prompt) {
|
|
39
|
+
options.prompt = args.prompt;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), (0, lodash_1.pick)(args, ['prompt', 'messages', 'messagesSearchTag']));
|
|
43
|
+
options.messages = (0, ai_1.convertToModelMessages)(messages);
|
|
44
|
+
}
|
|
45
|
+
const document = parent.getDocument(args.response.document);
|
|
46
|
+
if (!document) {
|
|
47
|
+
throw new Error(`Document with name "${args.response.document}" not found in tool execution context.`);
|
|
48
|
+
}
|
|
49
|
+
const responseSchema = document.argsSchema;
|
|
50
|
+
if (!responseSchema) {
|
|
51
|
+
throw new Error(`AI object generation source document must have a schema.`);
|
|
52
|
+
}
|
|
53
|
+
options.schema = responseSchema;
|
|
54
|
+
const response = await this.handleGenerateObject(model, options);
|
|
55
|
+
return {
|
|
56
|
+
data: response.object,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async handleGenerateObject(model, options) {
|
|
60
|
+
const startTime = performance.now();
|
|
61
|
+
try {
|
|
62
|
+
return (0, ai_1.generateObject)({
|
|
63
|
+
model,
|
|
64
|
+
...options,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const errorResponseTime = performance.now() - startTime;
|
|
69
|
+
console.error(`Request failed after ${errorResponseTime}ms:`, error);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.AiGenerateObject = AiGenerateObject;
|
|
75
|
+
exports.AiGenerateObject = AiGenerateObject = __decorate([
|
|
76
|
+
(0, common_1.BlockConfig)({
|
|
77
|
+
config: {
|
|
78
|
+
description: 'Generates a structured object using a LLM',
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
(0, common_1.WithArguments)(exports.AiGenerateObjectSchema),
|
|
82
|
+
__metadata("design:paramtypes", [services_1.AiMessagesHelperService,
|
|
83
|
+
services_2.AiProviderModelHelperService])
|
|
84
|
+
], AiGenerateObject);
|
|
85
|
+
//# sourceMappingURL=ai-generate-object.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-generate-object.tool.js","sourceRoot":"","sources":["../../src/tools/ai-generate-object.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAA2E;AAC3E,mCAA8B;AAC9B,2BAIY;AACZ,0CAAyD;AACzD,0CAAsD;AACtD,0CAA2D;AAG3D,0FAAmF;AAEtE,QAAA,sBAAsB,GAAG,uDAAwB,CAAC,MAAM,CAAC;IACpE,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC;QACjB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACzB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;KACrB,CAAC;CACH,CAAC,CAAC,MAAM,EAAE,CAAC;AAUL,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,eAAkC;IAEnD;IACA;IAFnB,YACmB,uBAAgD,EAChD,4BAA0D;QAE3E,KAAK,EAAE,CAAC;QAHS,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,iCAA4B,GAA5B,4BAA4B,CAA8B;IAG7E,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA8B,EAC9B,GAAsB,EACtB,MAAoB;QAEpB,MAAM,KAAK,GAAG,IAAI,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3E,MAAM,OAAO,GAAQ,EAAE,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AAE,CAAC;YACf,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,wBAAwB,iBAAiB,KAAK,EAAE,KAAK,CAAC,CAAC;YACrE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAlEY,4CAAgB;2BAAhB,gBAAgB;IAN5B,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,2CAA2C;SACzD;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,8BAAsB,CAAC;qCAGQ,kCAAuB;QAClB,uCAA4B;GAHlE,gBAAgB,CAkE5B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ToolResult } from '@loopstack/common';
|
|
3
|
+
import { ToolBase, WorkflowBase } from '@loopstack/core';
|
|
4
|
+
import { AiMessagesHelperService } from '../services';
|
|
5
|
+
import { AiProviderModelHelperService } from '../services';
|
|
6
|
+
import { AiToolsHelperService } from '../services';
|
|
7
|
+
import { WorkflowExecution } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-execution.interface';
|
|
8
|
+
export declare const AiGenerateTextSchema: z.ZodObject<{
|
|
9
|
+
llm: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
model: z.ZodOptional<z.ZodString>;
|
|
11
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
12
|
+
envApiKey: z.ZodOptional<z.ZodString>;
|
|
13
|
+
cacheResponse: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
model?: string;
|
|
16
|
+
provider?: string;
|
|
17
|
+
envApiKey?: string;
|
|
18
|
+
cacheResponse?: boolean;
|
|
19
|
+
}, {
|
|
20
|
+
model?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
envApiKey?: string;
|
|
23
|
+
cacheResponse?: boolean;
|
|
24
|
+
}>>;
|
|
25
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
26
|
+
role: z.ZodEnum<["system", "assistant", "user", "tool"]>;
|
|
27
|
+
content: z.ZodAny;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
30
|
+
content?: any;
|
|
31
|
+
}, {
|
|
32
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
33
|
+
content?: any;
|
|
34
|
+
}>, "many">>;
|
|
35
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
36
|
+
messagesSearchTag: z.ZodOptional<z.ZodString>;
|
|
37
|
+
} & {
|
|
38
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
llm?: {
|
|
41
|
+
model?: string;
|
|
42
|
+
provider?: string;
|
|
43
|
+
envApiKey?: string;
|
|
44
|
+
cacheResponse?: boolean;
|
|
45
|
+
};
|
|
46
|
+
messages?: {
|
|
47
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
48
|
+
content?: any;
|
|
49
|
+
}[];
|
|
50
|
+
prompt?: string;
|
|
51
|
+
messagesSearchTag?: string;
|
|
52
|
+
tools?: string[];
|
|
53
|
+
}, {
|
|
54
|
+
llm?: {
|
|
55
|
+
model?: string;
|
|
56
|
+
provider?: string;
|
|
57
|
+
envApiKey?: string;
|
|
58
|
+
cacheResponse?: boolean;
|
|
59
|
+
};
|
|
60
|
+
messages?: {
|
|
61
|
+
role?: "system" | "assistant" | "user" | "tool";
|
|
62
|
+
content?: any;
|
|
63
|
+
}[];
|
|
64
|
+
prompt?: string;
|
|
65
|
+
messagesSearchTag?: string;
|
|
66
|
+
tools?: string[];
|
|
67
|
+
}>;
|
|
68
|
+
type AiGenerateTextArgsType = z.infer<typeof AiGenerateTextSchema>;
|
|
69
|
+
export declare class AiGenerateText extends ToolBase<AiGenerateTextArgsType> {
|
|
70
|
+
private readonly aiMessagesHelperService;
|
|
71
|
+
private readonly aiToolsHelperService;
|
|
72
|
+
private readonly aiProviderModelHelperService;
|
|
73
|
+
constructor(aiMessagesHelperService: AiMessagesHelperService, aiToolsHelperService: AiToolsHelperService, aiProviderModelHelperService: AiProviderModelHelperService);
|
|
74
|
+
execute(args: AiGenerateTextArgsType, ctx: WorkflowExecution, parent: WorkflowBase): Promise<ToolResult>;
|
|
75
|
+
private handleGenerateText;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AiGenerateText = exports.AiGenerateTextSchema = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const lodash_1 = require("lodash");
|
|
16
|
+
const core_1 = require("@loopstack/core");
|
|
17
|
+
const services_1 = require("../services");
|
|
18
|
+
const services_2 = require("../services");
|
|
19
|
+
const services_3 = require("../services");
|
|
20
|
+
const ai_1 = require("ai");
|
|
21
|
+
const ai_generate_tool_base_schema_1 = require("../schemas/ai-generate-tool-base.schema");
|
|
22
|
+
exports.AiGenerateTextSchema = ai_generate_tool_base_schema_1.AiGenerateToolBaseSchema.extend({
|
|
23
|
+
tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
24
|
+
}).strict();
|
|
25
|
+
let AiGenerateText = class AiGenerateText extends core_1.ToolBase {
|
|
26
|
+
aiMessagesHelperService;
|
|
27
|
+
aiToolsHelperService;
|
|
28
|
+
aiProviderModelHelperService;
|
|
29
|
+
constructor(aiMessagesHelperService, aiToolsHelperService, aiProviderModelHelperService) {
|
|
30
|
+
super();
|
|
31
|
+
this.aiMessagesHelperService = aiMessagesHelperService;
|
|
32
|
+
this.aiToolsHelperService = aiToolsHelperService;
|
|
33
|
+
this.aiProviderModelHelperService = aiProviderModelHelperService;
|
|
34
|
+
}
|
|
35
|
+
async execute(args, ctx, parent) {
|
|
36
|
+
const model = this.aiProviderModelHelperService.getProviderModel(args.llm);
|
|
37
|
+
const options = {};
|
|
38
|
+
options.tools = args.tools
|
|
39
|
+
? this.aiToolsHelperService.getTools(args.tools, parent)
|
|
40
|
+
: undefined;
|
|
41
|
+
if (args.prompt) {
|
|
42
|
+
options.prompt = args.prompt;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const messages = this.aiMessagesHelperService.getMessages(ctx.state.getMetadata('documents'), (0, lodash_1.pick)(args, ['prompt', 'messages', 'messagesSearchTag']));
|
|
46
|
+
options.messages = (0, ai_1.convertToModelMessages)(messages, {
|
|
47
|
+
tools: options.tools,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const uiMessage = await this.handleGenerateText(model, options);
|
|
51
|
+
return {
|
|
52
|
+
data: uiMessage,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async handleGenerateText(model, options) {
|
|
56
|
+
const startTime = performance.now();
|
|
57
|
+
try {
|
|
58
|
+
const result = (0, ai_1.streamText)({
|
|
59
|
+
model,
|
|
60
|
+
...options,
|
|
61
|
+
});
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const stream = (0, ai_1.createUIMessageStream)({
|
|
64
|
+
execute({ writer }) {
|
|
65
|
+
writer.merge(result.toUIMessageStream({
|
|
66
|
+
sendReasoning: true,
|
|
67
|
+
}));
|
|
68
|
+
},
|
|
69
|
+
onFinish: async (data) => {
|
|
70
|
+
try {
|
|
71
|
+
resolve(data.responseMessage);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
reject(error);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
(async () => {
|
|
79
|
+
try {
|
|
80
|
+
const reader = stream.getReader();
|
|
81
|
+
while (true) {
|
|
82
|
+
const { done } = await reader.read();
|
|
83
|
+
if (done)
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
reject(error);
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const errorResponseTime = performance.now() - startTime;
|
|
95
|
+
console.error(`Request failed after ${errorResponseTime}ms:`, error);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.AiGenerateText = AiGenerateText;
|
|
101
|
+
exports.AiGenerateText = AiGenerateText = __decorate([
|
|
102
|
+
(0, common_1.BlockConfig)({
|
|
103
|
+
config: {
|
|
104
|
+
description: 'Generates text using a LLM',
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
(0, common_1.WithArguments)(exports.AiGenerateTextSchema),
|
|
108
|
+
__metadata("design:paramtypes", [services_1.AiMessagesHelperService,
|
|
109
|
+
services_3.AiToolsHelperService,
|
|
110
|
+
services_2.AiProviderModelHelperService])
|
|
111
|
+
], AiGenerateText);
|
|
112
|
+
//# sourceMappingURL=ai-generate-text.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-generate-text.tool.js","sourceRoot":"","s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AAE,CAAC;4BACZ,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;4BACrC,IAAI,IAAI;gCAAE,MAAM;wBAClB,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,CAAC,KAAK,CAAC,CAAC;oBAChB,CAAC;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,wBAAwB,iBAAiB,KAAK,EAAE,KAAK,CAAC,CAAC;YACrE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAzFY,wCAAc;yBAAd,cAAc;IAN1B,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,4BAA4B;SAC1C;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,4BAAoB,CAAC;qCAGU,kCAAuB;QAC1B,+BAAoB;QACZ,uCAA4B;GAJlE,cAAc,CAyF1B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ToolResult } from '@loopstack/common';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ToolBase, WorkflowBase } from '@loopstack/core';
|
|
4
|
+
import { WorkflowExecution } from '@loopstack/core/dist/workflow-processor/interfaces/workflow-execution.interface';
|
|
5
|
+
declare const DelegateToolCallsToolSchema: z.ZodObject<{
|
|
6
|
+
message: z.ZodAny;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
message?: any;
|
|
9
|
+
}, {
|
|
10
|
+
message?: any;
|
|
11
|
+
}>;
|
|
12
|
+
type DelegateToolCallsToolArgs = z.infer<typeof DelegateToolCallsToolSchema>;
|
|
13
|
+
export declare class DelegateToolCall extends ToolBase<DelegateToolCallsToolArgs> {
|
|
14
|
+
execute(args: DelegateToolCallsToolArgs, ctx: WorkflowExecution, parent: WorkflowBase): Promise<ToolResult>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DelegateToolCall = void 0;
|
|
10
|
+
const common_1 = require("@loopstack/common");
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const core_1 = require("@loopstack/core");
|
|
13
|
+
const DelegateToolCallsToolSchema = zod_1.z.object({
|
|
14
|
+
message: zod_1.z.any(),
|
|
15
|
+
});
|
|
16
|
+
let DelegateToolCall = class DelegateToolCall extends core_1.ToolBase {
|
|
17
|
+
async execute(args, ctx, parent) {
|
|
18
|
+
const parts = args.message.parts;
|
|
19
|
+
const resultParts = [];
|
|
20
|
+
for (const part of parts) {
|
|
21
|
+
if (!part.type.startsWith('tool-')) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const toolName = part.type.replace(/^tool-/, '');
|
|
25
|
+
const tool = parent.getTool(toolName);
|
|
26
|
+
const result = await tool.execute(part.input, ctx, parent);
|
|
27
|
+
resultParts.push({
|
|
28
|
+
type: part.type,
|
|
29
|
+
toolCallId: part.toolCallId,
|
|
30
|
+
output: {
|
|
31
|
+
type: result.type || 'text',
|
|
32
|
+
value: result.data,
|
|
33
|
+
},
|
|
34
|
+
input: part.input,
|
|
35
|
+
state: 'output-available',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const resultMessage = {
|
|
39
|
+
id: args.message.id,
|
|
40
|
+
role: 'assistant',
|
|
41
|
+
parts: resultParts,
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
data: resultMessage,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.DelegateToolCall = DelegateToolCall;
|
|
49
|
+
exports.DelegateToolCall = DelegateToolCall = __decorate([
|
|
50
|
+
(0, common_1.BlockConfig)({
|
|
51
|
+
config: {
|
|
52
|
+
description: 'Delegate a tool call.',
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
(0, common_1.WithArguments)(DelegateToolCallsToolSchema)
|
|
56
|
+
], DelegateToolCall);
|
|
57
|
+
//# sourceMappingURL=delegate-tool-call.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-tool-call.tool.js","sourceRoot":"","sources":["../../src/tools/delegate-tool-call.tool.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA2E;AAC3E,6BAAwB;AACxB,0CAAyD;AAIzD,MAAM,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,GAAG,EAAE;CACjB,CAAC,CAAC;AAUI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,eAAmC;IACvE,KAAK,CAAC,OAAO,CACX,IAA+B,EAC/B,GAAsB,EACtB,MAAoB;QAEpB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACjC,MAAM,WAAW,GAAiB,EAAE,CAAC;QAErC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAEjD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YAE3D,WAAW,CAAC,IAAI,CAAC;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,MAAM,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM;oBAC3B,KAAK,EAAE,MAAM,CAAC,IAAI;iBACnB;gBACD,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,kBAAkB;aACL,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,aAAa,GAAG;YACpB,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YACnB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,WAAW;SACC,CAAC;QAEtB,OAAO;YACL,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAzCY,4CAAgB;2BAAhB,gBAAgB;IAN5B,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,uBAAuB;SACrC;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,2BAA2B,CAAC;GAC9B,gBAAgB,CAyC5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai-generate-document.tool"), exports);
|
|
18
|
+
__exportStar(require("./ai-generate-text.tool"), exports);
|
|
19
|
+
__exportStar(require("./ai-generate-object.tool"), exports);
|
|
20
|
+
__exportStar(require("./delegate-tool-call.tool"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,0DAAwC;AACxC,4DAA0C;AAC1C,4DAA0C"}
|