File size: 1,040 Bytes
ec59be7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
function pingChatbot() {
// Your FastAPI endpoint URL
var url = "https://amanm10000-mlsc-coherence-25-faq-chatbot-api.hf.space/chat";
// Create query parameters
var params = {
"question": "Who are the sponsors baby?"
};
// Build URL with query parameters
var queryString = Object.keys(params)
.map(key => key + '=' + encodeURIComponent(params[key]))
.join('&');
var fullUrl = url + '?' + queryString;
// Request options
var options = {
"method": "get",
"muteHttpExceptions": true
};
try {
// Make the request
var response = UrlFetchApp.fetch(fullUrl, options);
// Get response code and content
var responseCode = response.getResponseCode();
var responseText = response.getContentText();
// Log the response
Logger.log("Response Code: " + responseCode);
Logger.log("Response: " + responseText);
return responseText;
} catch (error) {
Logger.log("Error: " + error.toString());
return "Error: " + error.toString();
}
} |