var http = require('http');
// The following 4 are the actual values that pertain to your account and this specific metric.
var apiKey = '50bd0b6abb354a97bf3256c3e6439060';
var pageId = 'rv39vdb0xws9';
var metricId = 'pgq8vmhnmqzl';
var apiBase = 'https://api.statuspage.io/v1';
var url = apiBase + '/pages/' + pageId + '/metrics/' + metricId + '/data.json';
var authHeader = { 'Authorization': 'OAuth ' + apiKey };
var options = { method: 'POST', headers: authHeader };
// Need at least 1 data point for every 5 minutes.
// Submit random data for the whole day.
var totalPoints = 60 / 5 * 24;
var epochInSeconds = Math.floor(new Date() / 1000);
// This function gets called every second.
function submit(count) {
count = count + 1;
if(count > totalPoints) return;
var currentTimestamp = epochInSeconds - (count - 1) * 5 * 60;
var randomValue = Math.floor(Math.random() * 1000);
var data = {
timestamp: currentTimestamp,
value: randomValue,
};
var request = http.request(url, options, function (res) {
if (res.statusMessage === "Unauthorized") {
const genericError =
"Error encountered. Please ensure that your page code and authorization key are correct.";
return console.error(genericError);
}
res.on("data", function () {
console.log("Submitted point " + count + " of " + totalPoints);
});
res.on("end", function () {
setTimeout(function () {
submit(count);
}, 1000);
});
res.on("error", (error) => {
console.error(`Error caught: ${error.message}`);
});
});
request.end(JSON.stringify({ data: data }));
}
// Initial call to start submitting data.
submit(0);
var admin = require("firebase-admin");
var serviceAccount = require("path/to/serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
npm i --save genkit @genkit-ai/googleai
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=AIzaSyBh8TMadCkryj17qwhVQfwv7BA5bAMyVeQ" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "Explain how AI works"}]
}]
}'
// import the Genkit and Google AI plugin libraries
import { gemini15Flash, googleAI } from '@genkit-ai/googleai';
import { genkit } from 'genkit';
// configure a Genkit instance
const ai = genkit({
plugins: [googleAI()],
model: gemini15Flash, // set default model
});
const helloFlow = ai.defineFlow('helloFlow', async (name) => {
// make a generation request
const { text } = await ai.generate(`Hello Gemini, my name is ${name}`);
console.log(text);
});
helloFlow('Ifut Coy');
terima kasih
ReplyDeleteMantab
ReplyDelete