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