diff --git a/package-lock.json b/package-lock.json index 3af5a5b3..474bb763 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,7 +92,6 @@ "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -1170,6 +1169,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.0.tgz", "integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==", "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.27.1", @@ -1923,7 +1923,8 @@ "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-4.0.17.tgz", "integrity": "sha512-2EisRLHk6X/PdicybwlajLGKF5aJf4xnX2uuG5lexuYKt05xV/J/OiBADmi8q9obhxf1nesrMQbqAt+6CsHo/w==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@cspell/dict-dart": { "version": "2.3.0", @@ -2063,14 +2064,16 @@ "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-4.0.11.tgz", "integrity": "sha512-QR3b/PB972SRQ2xICR1Nw/M44IJ6rjypwzA4jn+GH8ydjAX9acFNfc+hLZVyNe0FqsE90Gw3evLCOIF0vy1vQw==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@cspell/dict-html-symbol-entities": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@cspell/dict-html-symbol-entities/-/dict-html-symbol-entities-4.0.3.tgz", "integrity": "sha512-aABXX7dMLNFdSE8aY844X4+hvfK7977sOWgZXo4MTGAmOzR8524fjbJPswIBK7GaD3+SgFZ2yP2o0CFvXDGF+A==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@cspell/dict-java": { "version": "5.0.11", @@ -2268,7 +2271,8 @@ "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-3.2.2.tgz", "integrity": "sha512-H9Y+uUHsTIDFO/jdfUAcqmcd5osT+2DB5b0aRCHfLWN/twUbGn/1qq3b7YwEvttxKlYzWHU3uNFf+KfA93VY7w==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@cspell/dict-vue": { "version": "3.0.4", @@ -3962,6 +3966,7 @@ "integrity": "sha512-vvmsN0r7rguA+FySiCsbaTTobSftpIDIpPW81trAmsv9TGxg3YCujAxRYp/Uy8xmDgYCzzgulG62H7KYUFmeIg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@octokit/auth-token": "^5.0.0", "@octokit/graphql": "^8.2.2", @@ -4151,6 +4156,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=8.0.0" } @@ -4248,6 +4254,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.0.1.tgz", "integrity": "sha512-MaZk9SJIDgo1peKevlbhP6+IwIiNPNmswNL4AF0WaQJLbHXjr9SrZMgS12+iqr9ToV4ZVosCcc0f8Rg67LXjxw==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/semantic-conventions": "^1.29.0" }, @@ -7285,6 +7292,7 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.16.2.tgz", "integrity": "sha512-Cdqa/eJTvt4fC4wmq1Mcc0CPUjp/Qy2FGqLza3z3pKymsI969TcZ54diNJv8UYUgeWxyb8FSbCkhdR6WqmUFhA==", "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -7337,6 +7345,7 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.8.tgz", "integrity": "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==", "license": "MIT", + "peer": true, "dependencies": { "csstype": "^3.0.2" } @@ -7618,6 +7627,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -7765,8 +7775,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/argparse": { "version": "2.0.1", @@ -7894,6 +7903,7 @@ "resolved": "https://registry.npmjs.org/astro/-/astro-5.15.9.tgz", "integrity": "sha512-XLDXxu0282cC/oYHswWZm3johGlRvk9rLRS7pWVWSne+HsZe9JgrpHI+vewAJSSNHBGd1aCyaQOElT5RNGe7IQ==", "license": "MIT", + "peer": true, "dependencies": { "@astrojs/compiler": "^2.13.0", "@astrojs/internal-helpers": "0.7.5", @@ -8291,7 +8301,6 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "license": "MIT", - "peer": true, "engines": { "node": ">=8" }, @@ -8476,6 +8485,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001726", "electron-to-chromium": "^1.5.173", @@ -8682,7 +8692,6 @@ "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", "license": "MIT", - "peer": true, "engines": { "node": ">= 6" } @@ -10028,8 +10037,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", - "license": "Apache-2.0", - "peer": true + "license": "Apache-2.0" }, "node_modules/diff": { "version": "5.2.0", @@ -10519,6 +10527,7 @@ "integrity": "sha512-GVuzuUwtdsghE3ocJ9Bs8PNoF13HNQ5TXbEi2AhvVb8xU1Iwt9Fos9FEamfoee+u/TOsn7GUWc04lz46n2bbTg==", "hasInstallScript": true, "license": "MIT", + "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -12535,7 +12544,6 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "license": "MIT", - "peer": true, "dependencies": { "binary-extensions": "^2.0.0" }, @@ -13188,6 +13196,7 @@ "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", "devOptional": true, "license": "MIT", + "peer": true, "bin": { "jiti": "lib/jiti-cli.mjs" } @@ -15483,7 +15492,6 @@ "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", "license": "MIT", - "peer": true, "engines": { "node": ">= 6" } @@ -16165,6 +16173,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -16179,7 +16188,6 @@ "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", "license": "MIT", - "peer": true, "dependencies": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", @@ -16197,7 +16205,6 @@ "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz", "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==", "license": "MIT", - "peer": true, "dependencies": { "camelcase-css": "^2.0.1" }, @@ -16270,7 +16277,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "postcss-selector-parser": "^6.1.1" }, @@ -16286,7 +16292,6 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", "license": "MIT", - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -16353,22 +16358,6 @@ "node": ">=0.10.0" } }, - "node_modules/prettier": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", - "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", - "license": "MIT", - "optional": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -16597,6 +16586,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -16606,6 +16596,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.26.0" }, @@ -16634,7 +16625,6 @@ "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", "license": "MIT", - "peer": true, "dependencies": { "pify": "^2.3.0" } @@ -17025,6 +17015,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "@nodeutils/defaults-deep": "1.1.0", "@octokit/rest": "21.1.1", @@ -19602,7 +19593,6 @@ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "license": "MIT", - "peer": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -19627,7 +19617,6 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "license": "ISC", - "peer": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -19640,7 +19629,6 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "license": "ISC", - "peer": true, "dependencies": { "is-glob": "^4.0.3" }, @@ -19653,7 +19641,6 @@ "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", "license": "MIT", - "peer": true, "bin": { "jiti": "bin/jiti.js" } @@ -19663,7 +19650,6 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "license": "MIT", - "peer": true, "engines": { "node": ">=8.6" }, @@ -19686,7 +19672,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "lilconfig": "^3.0.0", "yaml": "^2.3.4" @@ -19712,7 +19697,6 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", "license": "MIT", - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -19726,7 +19710,6 @@ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "license": "MIT", - "peer": true, "dependencies": { "picomatch": "^2.2.1" }, @@ -20263,6 +20246,7 @@ "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "~0.25.0", "get-tsconfig": "^4.7.5" @@ -20418,6 +20402,7 @@ "integrity": "sha512-PitbnAps2vpcqK2gargKoiFXLWFttvwUbyns/E6zGIFG5Gz8ZQJGttHnYR9csOlcSjB/uyjd8tnoayrtsXG17w==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">= 18" }, @@ -20462,6 +20447,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -20983,6 +20969,7 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.4.tgz", "integrity": "sha512-NL8jTlbo0Tn4dUEXEsUg8KeyG/Lkmc4Fnzb8JXN/Ykm9G4HNImjtABMJgkQoVjOBN/j2WAwDTRytdqJbZsah7w==", "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -22063,6 +22050,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/ax/dsp/generate.ts b/src/ax/dsp/generate.ts index b95289ba..58ce767f 100644 --- a/src/ax/dsp/generate.ts +++ b/src/ax/dsp/generate.ts @@ -131,6 +131,9 @@ export class AxGen extends AxProgram implements AxProgrammable { + public clone = (): AxGen => { + return new AxGen(this.signature, this.options); + }; private promptTemplate: AxPromptTemplate; private asserts: AxAssertion[]; private streamingAsserts: AxStreamingAssertion[]; @@ -173,6 +176,10 @@ export class AxGen this.usage = []; } + public setInstruction(instruction: string): void { + this.promptTemplate.setInstruction(instruction); + } + private getSignatureName(): string { return this.signature.getDescription() || 'unknown_signature'; } diff --git a/src/ax/dsp/optimizers/miproV2.ts b/src/ax/dsp/optimizers/miproV2.ts index 31180fef..2b94ecf5 100644 --- a/src/ax/dsp/optimizers/miproV2.ts +++ b/src/ax/dsp/optimizers/miproV2.ts @@ -716,6 +716,13 @@ Instruction:`; this.localScoreHistory = []; this.localConfigurationHistory = []; + // Propose instruction candidates + const instructionCandidates = await this.proposeInstructionCandidates( + program, + _options, + examples + ); + const studyName = `mipro_${Date.now()}_${Math.random() .toString(36) .substr(2, 9)}`; @@ -736,6 +743,19 @@ Instruction:`; low: 0, high: this.maxBootstrappedDemos, }, + // Add instruction candidates + { + name: 'instruction', + type: 'categorical' as const, + choices: instructionCandidates, + }, + // Add labeled examples + { + name: 'labeledExamples', + type: 'int' as const, + low: 0, + high: this.maxLabeledDemos, + }, // Optionally include topP as a conservative sampling knob ...(this.optimizeTopP ? ([ @@ -786,6 +806,9 @@ Instruction:`; // Apply the suggested parameters - throw error if missing const temperature = suggestion.params.temperature as number; const bootstrappedDemos = suggestion.params.bootstrappedDemos as number; + const instruction = suggestion.params.instruction as string; + const labeledExamples = suggestion.params.labeledExamples as number; + const topP = this.optimizeTopP ? (suggestion.params.topP as number | undefined) : undefined; @@ -804,6 +827,30 @@ Instruction:`; )}` ); } + if (instruction === undefined) { + throw new Error( + `Missing instruction parameter in suggestion: ${JSON.stringify( + suggestion + )}` + ); + } + if (labeledExamples === undefined) { + throw new Error( + `Missing labeledExamples parameter in suggestion: ${JSON.stringify( + suggestion + )}` + ); + } + + // Clone the program to apply the new instruction + const programForEval = program.clone(); + programForEval.setInstruction(instruction); + programForEval.setExamples( + this.selectLabeledExamples(examples).slice( + 0, + labeledExamples + ) as unknown as readonly (OUT & Partial)[] + ); // Choose evaluation set: minibatch vs full const useFullEval = @@ -826,7 +873,7 @@ Instruction:`; // Evaluate with the suggested parameters const score = await this.evaluateConfiguration( - program, + programForEval, metricFn, { temperature, bootstrappedDemos, topP }, evalSet @@ -989,6 +1036,9 @@ Instruction:`; // Create optimized generator with best configuration const optimizedGen = new AxGen(program.getSignature()); + if ((finalBestConfig as any).instruction) { + optimizedGen.setInstruction((finalBestConfig as any).instruction); + } if (bestDemos.length > 0) { optimizedGen.setDemos(bestDemos); } @@ -1003,7 +1053,7 @@ Instruction:`; const optimizedProgram = new AxOptimizedProgramImpl({ bestScore: finalBestScore, stats: this.stats, - instruction: undefined, // Python path doesn't optimize instructions yet + instruction: (finalBestConfig as any).instruction, demos: bestDemos, examples: [], modelConfig: { @@ -1098,30 +1148,8 @@ Instruction:`; // Use provided examples set (already mini-batched/full-selected by caller) const evaluationExamples = examples as readonly AxTypedExample[]; - // Optional: Pre-bootstrap demos once and reuse for this configuration - let demosForConfig: AxProgramDemos[] = []; - if (config.bootstrappedDemos > 0) { - try { - const bootstrapped = await this.bootstrapFewShotExamples( - program, - metricFn, - evaluationExamples - ); - demosForConfig = bootstrapped.slice(0, config.bootstrappedDemos); - } catch { - // If bootstrap fails, continue without demos - demosForConfig = []; - } - } - for (const example of evaluationExamples) { try { - // Apply bootstrapped demos for this configuration if any were generated - if (demosForConfig.length > 0) { - // Best-effort application; program is Readonly in type but supports runtime mutation - (program as any).setDemos?.(demosForConfig); - } - // Apply the optimized configuration (temperature) during evaluation const prediction = await program.forward( this.studentAI, diff --git a/src/ax/dsp/prompt.ts b/src/ax/dsp/prompt.ts index 13f9c4dd..87d7d65f 100644 --- a/src/ax/dsp/prompt.ts +++ b/src/ax/dsp/prompt.ts @@ -46,6 +46,10 @@ export class AxPromptTemplate { private sig: Readonly; private fieldTemplates?: Record; private task: { type: 'text'; text: string }; + + public setInstruction(instruction: string): void { + this.task = { type: 'text', text: instruction }; + } private readonly thoughtFieldName: string; private readonly functions?: Readonly; private readonly cacheSystemPrompt?: boolean;