@hazeljs/ai 0.2.0-beta.61 → 0.2.0-beta.65

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,4 +1,5 @@
1
1
  import { AITaskConfig, AITaskResult } from './ai.types';
2
+ import './prompts/task.prompt';
2
3
  export declare class AIService {
3
4
  private providers;
4
5
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"ai.service.d.ts","sourceRoot":"","sources":["../src/ai.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AAYvE,qBACa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAsC;;IAOvD,OAAO,CAAC,mBAAmB;IAqL3B,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,aAAa;IAkBf,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;CAkC/E"}
1
+ {"version":3,"file":"ai.service.d.ts","sourceRoot":"","sources":["../src/ai.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AAIvE,OAAO,uBAAuB,CAAC;AAW/B,qBACa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAsC;;IAOvD,OAAO,CAAC,mBAAmB;IAoL3B,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,aAAa;IAkBf,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;CAkC/E"}
@@ -16,6 +16,9 @@ exports.AIService = void 0;
16
16
  const core_1 = require("@hazeljs/core");
17
17
  const core_2 = __importDefault(require("@hazeljs/core"));
18
18
  const openai_1 = __importDefault(require("openai"));
19
+ const prompts_1 = require("@hazeljs/prompts");
20
+ require("./prompts/task.prompt");
21
+ const task_prompt_1 = require("./prompts/task.prompt");
19
22
  let AIService = class AIService {
20
23
  constructor() {
21
24
  this.providers = new Map();
@@ -189,7 +192,6 @@ let AIService = class AIService {
189
192
  },
190
193
  });
191
194
  }
192
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
193
195
  formatPrompt(config, input) {
194
196
  const context = {
195
197
  taskName: config.name,
@@ -198,9 +200,12 @@ let AIService = class AIService {
198
200
  outputExample: `Expected ${config.outputType} output`,
199
201
  input: input,
200
202
  };
201
- return config.prompt.replace(/{{(\w+)}}/g, (_, key) => {
202
- return String(context[key] || '');
203
+ // Normalise legacy {{variable}} to {variable} and render via PromptTemplate
204
+ const normalizedTemplate = config.prompt.replace(/\{\{(\w+)\}\}/g, '{$1}');
205
+ const tpl = new prompts_1.PromptTemplate(normalizedTemplate, {
206
+ name: task_prompt_1.AI_TASK_FORMAT_KEY,
203
207
  });
208
+ return tpl.render(context);
204
209
  }
205
210
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
206
211
  parseResponse(response, outputType) {
@@ -0,0 +1,12 @@
1
+ import { PromptTemplate } from '@hazeljs/prompts';
2
+ export declare const AI_TASK_FORMAT_KEY = "ai:task:format";
3
+ export interface AITaskFormatVariables {
4
+ taskName: string;
5
+ description: string;
6
+ input: string;
7
+ inputExample: string;
8
+ outputExample: string;
9
+ }
10
+ declare const template: PromptTemplate<AITaskFormatVariables>;
11
+ export { template as aiTaskFormatPrompt };
12
+ //# sourceMappingURL=task.prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.prompt.d.ts","sourceRoot":"","sources":["../../src/prompts/task.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAElE,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,QAAA,MAAM,QAAQ,uCAKZ,CAAC;AAIH,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aiTaskFormatPrompt = exports.AI_TASK_FORMAT_KEY = void 0;
4
+ const prompts_1 = require("@hazeljs/prompts");
5
+ exports.AI_TASK_FORMAT_KEY = 'ai:task:format';
6
+ const template = new prompts_1.PromptTemplate(`{description}`, {
7
+ name: 'AI Task Format',
8
+ description: 'Formats an AI task prompt by substituting context variables into the template string',
9
+ version: '1.0.0',
10
+ });
11
+ exports.aiTaskFormatPrompt = template;
12
+ prompts_1.PromptRegistry.register(exports.AI_TASK_FORMAT_KEY, template);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/ai",
3
- "version": "0.2.0-beta.61",
3
+ "version": "0.2.0-beta.65",
4
4
  "description": "AI integration module for HazelJS framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "dependencies": {
18
18
  "@anthropic-ai/sdk": "^0.71.2",
19
19
  "@google/generative-ai": "^0.24.1",
20
+ "@hazeljs/prompts": "^0.2.0-beta.65",
20
21
  "cohere-ai": "^7.14.0",
21
22
  "openai": "^6.15.0"
22
23
  },
@@ -55,5 +56,5 @@
55
56
  "@hazeljs/cache": ">=0.2.0-beta.0",
56
57
  "@hazeljs/core": ">=0.2.0-beta.0"
57
58
  },
58
- "gitHead": "2205447dd2f88f83a7748b0ffdee0417be0f3970"
59
+ "gitHead": "3b2fe9ac12b1b01700090b2a3244a2c8337b17e9"
59
60
  }