Fixed JSON method
All checks were successful
Publish Library / Build NPM Project (push) Successful in 21s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2025-12-13 16:45:28 -05:00
parent 2e28ffd152
commit 709ba05e28
2 changed files with 9 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/ai-utils", "name": "@ztimson/ai-utils",
"version": "0.1.4", "version": "0.1.5",
"description": "AI Utility library", "description": "AI Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@@ -138,9 +138,15 @@ export class LLM {
return Math.ceil((text.length / 4) * 1.2); 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, { let resp = await this.ask(message, {
system: '', system: 'Respond using a JSON blob',
...options ...options
}); });
if(!resp?.[0]?.content) return {}; if(!resp?.[0]?.content) return {};