@nx-ddd/common 17.5.0 → 17.6.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/infrastructure/externals/agent/agent.d.ts +10 -1
- package/infrastructure/externals/agent/agent.js +71 -5
- package/infrastructure/externals/agent/agent.js.map +1 -1
- package/infrastructure/externals/agent/index.d.ts +1 -0
- package/infrastructure/externals/agent/index.js +1 -0
- package/infrastructure/externals/agent/index.js.map +1 -1
- package/infrastructure/externals/agent/json-schema.d.ts +2 -0
- package/infrastructure/externals/agent/json-schema.js +42 -0
- package/infrastructure/externals/agent/json-schema.js.map +1 -0
- package/infrastructure/externals/openai/open-ai.service.impl.js +1 -1
- package/infrastructure/externals/openai/open-ai.service.impl.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAiServiceImpl } from '../openai/open-ai.service.impl';
|
|
2
|
-
import { ChatCompletionMessageParam } from "openai/resources";
|
|
2
|
+
import { ChatCompletionMessageParam, FunctionParameters } from "openai/resources";
|
|
3
3
|
import { FunctionTool } from "openai/resources/beta/assistants";
|
|
4
4
|
import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions";
|
|
5
5
|
export declare function addTool(obj: object, tool: object): object;
|
|
@@ -34,6 +34,14 @@ export declare class AiToolsAgent {
|
|
|
34
34
|
export declare class AnyFunction {
|
|
35
35
|
private openai;
|
|
36
36
|
constructor(openai: OpenAiServiceImpl);
|
|
37
|
+
jsonSchema(_input: any, jsonSchema: FunctionParameters, { instructions, model, specs, }?: {
|
|
38
|
+
instructions?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
specs?: {
|
|
41
|
+
input: any;
|
|
42
|
+
output: any;
|
|
43
|
+
}[];
|
|
44
|
+
}): Promise<any>;
|
|
37
45
|
call<I, T>(_input: I, args: {
|
|
38
46
|
new (): T;
|
|
39
47
|
}, { instructions, model, specs, }?: {
|
|
@@ -45,6 +53,7 @@ export declare class AnyFunction {
|
|
|
45
53
|
}[];
|
|
46
54
|
}): Promise<T>;
|
|
47
55
|
private convertToChatMessages;
|
|
56
|
+
sort<T>(items: T[], accessor: (item: T) => string, target: string): Promise<T[]>;
|
|
48
57
|
private parseInput;
|
|
49
58
|
}
|
|
50
59
|
export declare function injectAnyFunction(): AnyFunction;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.injectAnyFunction = exports.AnyFunction = exports.AiToolsAgent = exports.AiSystem = exports.getAiSystemConfig = exports.setAiSystemConfig = exports.AiFunction = exports.buildToolFromSchema = exports.getTools = exports.addTool = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const class_validator_jsonschema_1 = require("class-validator-jsonschema");
|
|
6
5
|
const openai_1 = require("../openai");
|
|
6
|
+
const json_schema_1 = require("./json-schema");
|
|
7
7
|
const AI_TOOLS = '[ai-tools]';
|
|
8
8
|
const AI_SYSTEM = '[ai-system]';
|
|
9
9
|
function addTool(obj, tool) {
|
|
@@ -29,7 +29,7 @@ function buildFunctionTool(params) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
function buildToolFromSchema(name, description, schema) {
|
|
32
|
-
const parameters = (0,
|
|
32
|
+
const parameters = (0, json_schema_1.targetConstructorToSchema)(schema);
|
|
33
33
|
return buildFunctionTool({ name, description, parameters });
|
|
34
34
|
}
|
|
35
35
|
exports.buildToolFromSchema = buildToolFromSchema;
|
|
@@ -84,7 +84,6 @@ class AiToolsAgent {
|
|
|
84
84
|
});
|
|
85
85
|
for (const call of (_d = (_c = (_b = (_a = message.choices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.tool_calls) !== null && _d !== void 0 ? _d : []) {
|
|
86
86
|
if (call.type === 'function') {
|
|
87
|
-
console.debug('call.function.name:', call.function.name);
|
|
88
87
|
const result = (_e = this[call.function.name]) === null || _e === void 0 ? void 0 : _e.call(this, JSON.parse(call.function.arguments));
|
|
89
88
|
this.results.push(result);
|
|
90
89
|
}
|
|
@@ -100,11 +99,49 @@ class AiToolsAgent {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
exports.AiToolsAgent = AiToolsAgent;
|
|
102
|
+
const PRICE_TABLE = {
|
|
103
|
+
'gpt-3.5-turbo-0125': {
|
|
104
|
+
input: 0.5 / 1000000,
|
|
105
|
+
output: 1.5 / 1000000,
|
|
106
|
+
},
|
|
107
|
+
'gpt-4o': {
|
|
108
|
+
input: 5 / 1000000,
|
|
109
|
+
output: 15 / 1000000,
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function debugPrice(model, usage) {
|
|
113
|
+
// 価格を計算
|
|
114
|
+
const price = PRICE_TABLE[model];
|
|
115
|
+
const inputPrice = usage.prompt_tokens * price.input;
|
|
116
|
+
const outputPrice = usage.completion_tokens * price.output;
|
|
117
|
+
// k桁で丸める
|
|
118
|
+
const round = (num, k) => Math.round(num * Math.pow(10, k)) / Math.pow(10, k);
|
|
119
|
+
console.table([
|
|
120
|
+
{
|
|
121
|
+
name: 'input',
|
|
122
|
+
'price(us)': `$${round(inputPrice, 4)}`,
|
|
123
|
+
'price(jp)': `¥${round(inputPrice * 150, 4)}`,
|
|
124
|
+
token: usage.prompt_tokens
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'output',
|
|
128
|
+
'price(us)': `$${round(outputPrice, 4)}`,
|
|
129
|
+
'price(jp)': `¥${round(outputPrice * 150, 4)}`,
|
|
130
|
+
token: usage.completion_tokens,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'total',
|
|
134
|
+
'price(us)': `$${round((inputPrice + outputPrice), 4)}`,
|
|
135
|
+
'price(jp)': `¥${round((inputPrice + outputPrice) * 150, 4)}`,
|
|
136
|
+
token: usage.total_tokens,
|
|
137
|
+
},
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
103
140
|
class AnyFunction {
|
|
104
141
|
constructor(openai) {
|
|
105
142
|
this.openai = openai;
|
|
106
143
|
}
|
|
107
|
-
|
|
144
|
+
jsonSchema(_input, jsonSchema, { instructions = '', model = 'gpt-4o', specs = [], } = {}) {
|
|
108
145
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
146
|
const messages = [
|
|
110
147
|
{ role: 'system', content: instructions !== null && instructions !== void 0 ? instructions : '' },
|
|
@@ -115,7 +152,7 @@ class AnyFunction {
|
|
|
115
152
|
model,
|
|
116
153
|
messages,
|
|
117
154
|
tools: [
|
|
118
|
-
|
|
155
|
+
buildFunctionTool({ name: 'function', description: '', parameters: jsonSchema }),
|
|
119
156
|
],
|
|
120
157
|
tool_choice: {
|
|
121
158
|
type: 'function',
|
|
@@ -123,10 +160,17 @@ class AnyFunction {
|
|
|
123
160
|
name: 'function'
|
|
124
161
|
}
|
|
125
162
|
},
|
|
163
|
+
temperature: 0,
|
|
126
164
|
});
|
|
165
|
+
// debugPrice(model, res.usage);
|
|
127
166
|
return JSON.parse(res.choices[0].message.tool_calls[0].function.arguments);
|
|
128
167
|
});
|
|
129
168
|
}
|
|
169
|
+
call(_input, args, { instructions = '', model = 'gpt-4o', specs = [], } = {}) {
|
|
170
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
return this.jsonSchema(_input, (0, json_schema_1.targetConstructorToSchema)(args), { instructions, model, specs });
|
|
172
|
+
});
|
|
173
|
+
}
|
|
130
174
|
convertToChatMessages(specs) {
|
|
131
175
|
return specs.map(({ input, output }) => {
|
|
132
176
|
return [
|
|
@@ -135,6 +179,28 @@ class AnyFunction {
|
|
|
135
179
|
];
|
|
136
180
|
}).flat();
|
|
137
181
|
}
|
|
182
|
+
sort(items, accessor, target) {
|
|
183
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
const getEmbeddings = (item) => {
|
|
185
|
+
return this.openai.embeddings.create({
|
|
186
|
+
model: 'text-embedding-3-small',
|
|
187
|
+
input: accessor(item),
|
|
188
|
+
}).then(res => res.data[0].embedding);
|
|
189
|
+
};
|
|
190
|
+
const dist = (a, b) => Math.sqrt(a.reduce((acc, v, i) => acc + Math.pow((v - b[i]), 2), 0));
|
|
191
|
+
const targetEmbeddings = yield this.openai.embeddings.create({
|
|
192
|
+
model: 'text-embedding-3-small',
|
|
193
|
+
input: target,
|
|
194
|
+
}).then(res => res.data[0].embedding);
|
|
195
|
+
const embeddings = yield Promise.all(items.map(getEmbeddings));
|
|
196
|
+
const items_ = items.map((item, i) => ({
|
|
197
|
+
item,
|
|
198
|
+
embedding: embeddings[i],
|
|
199
|
+
distance: dist(embeddings[i], targetEmbeddings),
|
|
200
|
+
}));
|
|
201
|
+
return items_.sort((a, b) => a.distance - b.distance).map(({ item }) => item);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
138
204
|
parseInput(input) {
|
|
139
205
|
return typeof input === 'string' ? input : JSON.stringify(input);
|
|
140
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/agent/agent.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/agent/agent.ts"],"names":[],"mappings":";;;;AAIA,sCAAgD;AAChD,+CAA0D;AAE1D,MAAM,QAAQ,GAAG,YAAqB,CAAC;AACvC,MAAM,SAAS,GAAG,aAAsB,CAAC;AAEzC,SAAgB,OAAO,CAAC,GAAW,EAAE,IAAY;;IAC/C,GAAG,CAAC,QAAQ,CAAC,GAAG,MAAA,GAAG,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;IACpC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC;AACb,CAAC;AAJD,0BAIC;AAED,SAAgB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AAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC9E,CAAC;KAAA;IAEO,UAAU,CAAC,KAAU;QAC3B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;CACF;AAvFD,kCAuFC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,MAAM,GAAG,IAAA,4BAAmB,GAAE,CAAC;IACrC,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAHD,8CAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/agent/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/agent/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,wDAA8B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.targetConstructorToSchema = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_validator_jsonschema_1 = require("class-validator-jsonschema");
|
|
6
|
+
const { defaultMetadataStorage } = require('class-transformer/cjs/storage');
|
|
7
|
+
function getPropType(target, property) {
|
|
8
|
+
return Reflect.getMetadata('design:type', target, property);
|
|
9
|
+
}
|
|
10
|
+
function targetToSchema(type, options) {
|
|
11
|
+
if (typeof type === 'function') {
|
|
12
|
+
if (type.prototype === String.prototype ||
|
|
13
|
+
type.prototype === Symbol.prototype) {
|
|
14
|
+
return { type: 'string' };
|
|
15
|
+
}
|
|
16
|
+
else if (type.prototype === Number.prototype) {
|
|
17
|
+
return { type: 'number' };
|
|
18
|
+
}
|
|
19
|
+
else if (type.prototype === Boolean.prototype) {
|
|
20
|
+
return { type: 'boolean' };
|
|
21
|
+
}
|
|
22
|
+
return targetConstructorToSchema(type, options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const additionalConverters = {
|
|
26
|
+
[class_validator_1.ValidationTypes.NESTED_VALIDATION]: (meta, options) => {
|
|
27
|
+
if (typeof meta.target === 'function') {
|
|
28
|
+
const typeMeta = options.classTransformerMetadataStorage
|
|
29
|
+
? options.classTransformerMetadataStorage.findTypeMetadata(meta.target, meta.propertyName)
|
|
30
|
+
: null;
|
|
31
|
+
const childType = typeMeta
|
|
32
|
+
? typeMeta.typeFunction()
|
|
33
|
+
: getPropType(meta.target.prototype, meta.propertyName);
|
|
34
|
+
return targetToSchema(childType, options);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
function targetConstructorToSchema(target, options = {}) {
|
|
39
|
+
return (0, class_validator_jsonschema_1.targetConstructorToSchema)(target, Object.assign(Object.assign({}, options), { additionalConverters, classTransformerMetadataStorage: defaultMetadataStorage }));
|
|
40
|
+
}
|
|
41
|
+
exports.targetConstructorToSchema = targetConstructorToSchema;
|
|
42
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/agent/json-schema.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AACjD,2EAAoG;AAGpG,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5E,SAAS,WAAW,CAAC,MAAc,EAAE,QAAgB;IACnD,OAAO,OAA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AEF,SAAgB,yBAAyB,CAAC,MAAgB,EAAE,UAA6B,EAAE;IACzF,OAAO,IAAA,sDAA0B,EAAC,MAAM,kCACnC,OAAO,KACV,oBAAoB,EACpB,+BAA+B,EAAE,sBAAsB,IACvD,CAAC;AACL,CAAC;AAND,8DAMC"}
|
|
@@ -7,7 +7,7 @@ const openai_1 = require("openai");
|
|
|
7
7
|
const open_ai_config_1 = require("./open-ai.config");
|
|
8
8
|
let OpenAiServiceImpl = class OpenAiServiceImpl extends openai_1.OpenAI {
|
|
9
9
|
constructor(config) {
|
|
10
|
-
super(
|
|
10
|
+
super(config);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
exports.OpenAiServiceImpl = OpenAiServiceImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-ai.service.impl.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/openai/open-ai.service.impl.ts"],"names":[],"mappings":";;;;AAAA,wCAAmD;AACnD,mCAAgC;AAChC,qDAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAM;IAC3C,YAAoC,MAAoB;QACtD,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"open-ai.service.impl.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/openai/open-ai.service.impl.ts"],"names":[],"mappings":";;;;AAAA,wCAAmD;AACnD,mCAAgC;AAChC,qDAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAM;IAC3C,YAAoC,MAAoB;QACtD,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACF,CAAA;AAJY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,iBAAU,EAAC,EAAC,UAAU,EAAE,MAAM,EAAC,CAAC;IAElB,mBAAA,IAAA,aAAM,EAAC,+BAAc,CAAC,CAAA;;GADxB,iBAAiB,CAI7B"}
|