Fixed JSON method
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
10
src/llm.ts
10
src/llm.ts
@@ -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 {};
|
||||||
|
|||||||
Reference in New Issue
Block a user