
{
"entry":"IT Support"
}
Travel, Finance, Need Help
Step 3: Let's test if things are fine.via our Display API, like we did in Episode 4.
sap.ui.define([
"sap/ui/core/mvc/Controller"
],
/**
* @param {typeof sap.ui.core.mvc.Controller} Controller
*/
function (Controller) {
"use strict";
return Controller.extend("openai.openai.controller.OpenAI", {
onInit: function () {
},
askAI: function () {
var ques = this.getView().byId("chatques").getValue();
var that = this;
var busyDialog = new sap.m.BusyDialog();
this.getView().addDependent(busyDialog);
var payload = {
"ques" : ques
};
///
var sURL = "https://openaiapi.[Your API Service URL].ondemand.com/askai"
var that = this;
$.ajax({
url: sURL,
dataType: 'json',
type: 'POST',
data: JSON.stringify(payload),
contentType: 'application/json',
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*" ,
"Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept, authorization",
"Access-Control-Allow-Methods": "GET,POST,DELETE,PUT,OPTIONS",
'Authorization': 'Basic YWRtaW46b3Vyc2VjcmV0'
},
crossDomain: true,
success: function (oData) {
console.log(oData);
that.getView().byId("chatans1a").setValue(oData[0][0]);
that.getView().byId("chatans1b").setValue("Matched : " + (oData[0][1]*100).toString() + " %");
that.getView().byId("chatans2a").setValue(oData[1][0]);
that.getView().byId("chatans2b").setValue("Matched : " + (oData[1][1]*100).toString() + " %");
that.getView().byId("chatans3a").setValue(oData[2][0]);
that.getView().byId("chatans3b").setValue("Matched : " + (oData[2][1]*100).toString() + " %");
}
})
///
}
});
});
Cool, it's showing the top 3 matches with Match Percentage.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
15 | |
10 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |