add analyzer function
This commit is contained in:
parent
c063a21530
commit
809c5ac093
2 changed files with 22 additions and 0 deletions
|
@ -223,5 +223,8 @@
|
||||||
},
|
},
|
||||||
"error_msg_APImissing": {
|
"error_msg_APImissing": {
|
||||||
"message": "You have not yet added the API keys. To continue, please add one in the options."
|
"message": "You have not yet added the API keys. To continue, please add one in the options."
|
||||||
|
},
|
||||||
|
"AI_message_prompt": {
|
||||||
|
"message": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,4 +85,23 @@ export default class product {
|
||||||
// Write the analysis data to the storage.
|
// Write the analysis data to the storage.
|
||||||
(this[`analysis`]) ? secretariat.write([`sites`, this.URL, `analysis`], this.analysis): false;
|
(this[`analysis`]) ? secretariat.write([`sites`, this.URL, `analysis`], this.analysis): false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async analyze() {
|
||||||
|
// Stop when the data is already analyzed.
|
||||||
|
if (this[`analysis`]) {return(this.analysis)}
|
||||||
|
else if (this.status ? (!this.status.update) : false) {this.analysis = await secretariat.read([`sites`, this.URL, `analysis`]);}
|
||||||
|
else {
|
||||||
|
// Analyze the data.
|
||||||
|
const gemini = (await import(chrome.runtime.getURL("scripts/AI/gemini.js"))).default;
|
||||||
|
let analyzer = new gemini (await secretariat.read([`settings`,`analysis`,`api`,`key`]), `gemini-pro`);
|
||||||
|
|
||||||
|
// Analyze the data.
|
||||||
|
await analyzer.generate(this.details);
|
||||||
|
|
||||||
|
// Return the analysis
|
||||||
|
this.analysis = analyzer.response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(this.analysis);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue