From 709ba05e28bf7b22201b689e9bc6338c1e2069ce Mon Sep 17 00:00:00 2001 From: ztimson Date: Sat, 13 Dec 2025 16:45:28 -0500 Subject: [PATCH] Fixed JSON method --- package.json | 2 +- src/llm.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 64a8a32..ed42c29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/ai-utils", - "version": "0.1.4", + "version": "0.1.5", "description": "AI Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/llm.ts b/src/llm.ts index c3c70bc..4f1702b 100644 --- a/src/llm.ts +++ b/src/llm.ts @@ -138,9 +138,15 @@ export class LLM { return Math.ceil((text.length / 4) * 1.2); } - async json(message: string, options: LLMRequest) { + /** + * Ask a question with JSON response + * @param {string} message Question + * @param {LLMRequest} options Configuration options and chat history + * @returns {Promise<{} | {} | RegExpExecArray | null>} + */ + async json(message: string, options?: LLMRequest) { let resp = await this.ask(message, { - system: '', + system: 'Respond using a JSON blob', ...options }); if(!resp?.[0]?.content) return {};