ตอนนี้ฉันมีส่วนขยายที่ส่งข้อความไปยัง NLP API ผ่านฟังก์ชันคลาวด์ ข้อความชิ้นนี้ได้รับการประมวลผลและคาดการณ์ และให้คะแนนตามการทำนาย (ประโยคอาจเป็น 0.33 - "ความยินยอมที่สำคัญ" เป็นต้น) ฉันสงสัยว่าเป็นไปได้หรือไม่ที่จะบันทึกประโยคที่มีคะแนนตามลำดับลงใน Firestore ขณะนี้ ฉันสามารถบันทึกได้เพียงประโยคเท่านั้น แต่ยังบันทึกคะแนนไม่ได้
เราอยากได้คะแนนใน Firestore DB จริงๆ เนื่องจากขีดจำกัดที่เราใช้อยู่ หากไม่มีคะแนน เกณฑ์จะล้าสมัย
นี่คือฟังก์ชันคลาวด์ ในกรณี:
exports.queryAutoML = (req, res) => {
const automl = require('@google-cloud/automl');
const client = new automl.PredictionServiceClient();
var formattedName = client.modelPath('*********', '**********', '*****************');
var payload = {
"textSnippet": {
"content": req.body,
"mime_type": "text/plain"
},
};
var request = {
name: formattedName,
payload: payload,
};
client.predict(request)
.then(responses => {
console.log("in success");
let title = responses[0].payload[0].displayName;
let score = responses[0].payload[0].classification.score;
output = [req.body, title, score];
res.status(200).send(output);
})
.catch(err => {
console.log("in error");
console.error(err);
});