@skmtc/core 0.0.504 → 0.0.506

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.
@@ -1,3 +1,4 @@
1
1
  import type { EnrichmentRequest } from '../types/EnrichmentRequest.js';
2
2
  export declare const handleEnrichment: <EnrichmentType>({ prompt, content, responseSchema: zodResponseSchema }: EnrichmentRequest<EnrichmentType>) => Promise<string>;
3
+ export declare function removeProperties<T extends Record<string, any>>(obj: T, propertyName: string): Partial<T>;
3
4
  //# sourceMappingURL=handleEnrichment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAuCnC,CAAA"}
1
+ {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAyCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
@@ -10,7 +10,9 @@ const model = genAI.getGenerativeModel({
10
10
  model: 'gemini-1.5-flash'
11
11
  });
12
12
  export const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSchema }) => {
13
- const responseSchema = zodToJsonSchema(zodResponseSchema);
13
+ const responseSchema = zodToJsonSchema(zodResponseSchema, {
14
+ target: 'openApi3'
15
+ });
14
16
  console.log('RESPONSE SCHEMA', responseSchema);
15
17
  const chatSession = model.startChat({
16
18
  generationConfig: {
@@ -19,7 +21,7 @@ export const handleEnrichment = async ({ prompt, content, responseSchema: zodRes
19
21
  topK: 40,
20
22
  maxOutputTokens: 8192,
21
23
  responseMimeType: 'application/json',
22
- responseSchema
24
+ responseSchema: removeProperties(responseSchema, 'additionalProperties')
23
25
  },
24
26
  history: [
25
27
  {
@@ -44,3 +46,27 @@ export const handleEnrichment = async ({ prompt, content, responseSchema: zodRes
44
46
  console.log('RESULT', result);
45
47
  return result.response.text();
46
48
  };
49
+ // deno-lint-ignore no-explicit-any
50
+ export function removeProperties(obj, propertyName) {
51
+ if (typeof obj !== 'object' || obj === null) {
52
+ return obj;
53
+ }
54
+ // deno-lint-ignore ban-ts-comment
55
+ // @ts-ignore
56
+ const result = Array.isArray(obj) ? [] : {};
57
+ for (const key in obj) {
58
+ if (key === propertyName) {
59
+ continue;
60
+ }
61
+ const value = obj[key];
62
+ if (typeof value === 'object' && value !== null) {
63
+ // deno-lint-ignore ban-ts-comment
64
+ // @ts-ignore
65
+ result[key] = removeProperties(value, propertyName);
66
+ }
67
+ else {
68
+ result[key] = value;
69
+ }
70
+ }
71
+ return result;
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.504",
3
+ "version": "0.0.506",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1,3 +1,4 @@
1
1
  import type { EnrichmentRequest } from '../types/EnrichmentRequest.js';
2
2
  export declare const handleEnrichment: <EnrichmentType>({ prompt, content, responseSchema: zodResponseSchema }: EnrichmentRequest<EnrichmentType>) => Promise<string>;
3
+ export declare function removeProperties<T extends Record<string, any>>(obj: T, propertyName: string): Partial<T>;
3
4
  //# sourceMappingURL=handleEnrichment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAuCnC,CAAA"}
1
+ {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAyCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.handleEnrichment = void 0;
27
+ exports.removeProperties = removeProperties;
27
28
  const dntShim = __importStar(require("../_dnt.shims.js"));
28
29
  const generative_ai_1 = require("@google/generative-ai");
29
30
  const zod_to_json_schema_1 = require("zod-to-json-schema");
@@ -36,7 +37,9 @@ const model = genAI.getGenerativeModel({
36
37
  model: 'gemini-1.5-flash'
37
38
  });
38
39
  const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSchema }) => {
39
- const responseSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(zodResponseSchema);
40
+ const responseSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(zodResponseSchema, {
41
+ target: 'openApi3'
42
+ });
40
43
  console.log('RESPONSE SCHEMA', responseSchema);
41
44
  const chatSession = model.startChat({
42
45
  generationConfig: {
@@ -45,7 +48,7 @@ const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSc
45
48
  topK: 40,
46
49
  maxOutputTokens: 8192,
47
50
  responseMimeType: 'application/json',
48
- responseSchema
51
+ responseSchema: removeProperties(responseSchema, 'additionalProperties')
49
52
  },
50
53
  history: [
51
54
  {
@@ -71,3 +74,27 @@ const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSc
71
74
  return result.response.text();
72
75
  };
73
76
  exports.handleEnrichment = handleEnrichment;
77
+ // deno-lint-ignore no-explicit-any
78
+ function removeProperties(obj, propertyName) {
79
+ if (typeof obj !== 'object' || obj === null) {
80
+ return obj;
81
+ }
82
+ // deno-lint-ignore ban-ts-comment
83
+ // @ts-ignore
84
+ const result = Array.isArray(obj) ? [] : {};
85
+ for (const key in obj) {
86
+ if (key === propertyName) {
87
+ continue;
88
+ }
89
+ const value = obj[key];
90
+ if (typeof value === 'object' && value !== null) {
91
+ // deno-lint-ignore ban-ts-comment
92
+ // @ts-ignore
93
+ result[key] = removeProperties(value, propertyName);
94
+ }
95
+ else {
96
+ result[key] = value;
97
+ }
98
+ }
99
+ return result;
100
+ }