@ai-d/aid
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -48,3 +48,2 @@ "use strict"; | ||
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema")); | ||
var import_zod_to_ts = require("zod-to-ts"); | ||
var instruction = (strategy) => ` | ||
@@ -55,2 +54,4 @@ Response in JSON format (without other words or code fences) that follows the ${strategy === "ts" ? "TypeScript type" : "JSON Schema"}: | ||
return async (messages, schema) => { | ||
const ts_module = "zod-to-ts"; | ||
const ts = (opt == null ? void 0 : opt.strategy) === "ts" ? await import(ts_module) : {}; | ||
let system = messages.find((m) => m.role === "system"); | ||
@@ -61,3 +62,3 @@ if (!system) { | ||
} | ||
system.content += instruction(opt == null ? void 0 : opt.strategy) + ((opt == null ? void 0 : opt.strategy) === "ts" ? (0, import_zod_to_ts.printNode)((0, import_zod_to_ts.zodToTs)(schema).node) : JSON.stringify((0, import_zod_to_json_schema.default)(schema), null, 2)); | ||
system.content += instruction(opt == null ? void 0 : opt.strategy) + ((opt == null ? void 0 : opt.strategy) === "ts" ? ts.printNode(ts.zodToTs(schema).node) : JSON.stringify((0, import_zod_to_json_schema.default)(schema), null, 2)); | ||
system.content = system.content.trim(); | ||
@@ -70,2 +71,4 @@ return messages; | ||
var _a; | ||
const ts_module = "zod-to-ts"; | ||
const ts = (opt == null ? void 0 : opt.strategy) === "ts" ? await import(ts_module) : {}; | ||
let system = messages.find((m) => m.role === "system"); | ||
@@ -76,3 +79,3 @@ if (!system) { | ||
} | ||
const prompt = instruction(opt == null ? void 0 : opt.strategy) + ((opt == null ? void 0 : opt.strategy) === "ts" ? (0, import_zod_to_ts.printNode)((0, import_zod_to_ts.zodToTs)(schema).node) : JSON.stringify((0, import_zod_to_json_schema.default)(schema), null, 2)); | ||
const prompt = instruction(opt == null ? void 0 : opt.strategy) + ((opt == null ? void 0 : opt.strategy) === "ts" ? ts.printNode(ts.zodToTs(schema).node) : JSON.stringify((0, import_zod_to_json_schema.default)(schema), null, 2)); | ||
if (typeof system.content === "string") { | ||
@@ -79,0 +82,0 @@ system.content += prompt; |
{ | ||
"name": "@ai-d/aid", | ||
"description": "Aid provides a structured and type-safe way to interact with LLMs.", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"author": "JacobLinCool <jacoblincool@gmail.com> (https://jacoblin.cool)", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
31996
628