Mrinank
Mrinank
CDCloudflare Developers
Created by Mrinank on 7/7/2024 in #workers-help
Gemini API in cloudflare worker
Getting an error while using free gemini api from google ai studio in cloudflare worker
(error) Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:streamGenerateContent?alt=sse: [400 Bad Request] User location is not supported for the API use without a billing account linked.
(error) Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:streamGenerateContent?alt=sse: [400 Bad Request] User location is not supported for the API use without a billing account linked.
5 replies
CDCloudflare Developers
Created by Mrinank on 6/20/2024 in #workers-help
Switch cases with only one Cron Job?
async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {

/*
*/

const currentMinute = new Date().getMinutes();
// cron - 0,3,6,9,12,15 0,12 * * *
switch (currentMinute) {
case 0:
await manageVectorEmbeddings();
break;
case 3:
await add_top_10_news();
break;
case 6:
await add_business_news();
break;
case 9:
await add_politics_news();
break;
case 12:
await add_sports_news();
break;
case 15:
await add_technology_news();
break;
}
async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {

/*
*/

const currentMinute = new Date().getMinutes();
// cron - 0,3,6,9,12,15 0,12 * * *
switch (currentMinute) {
case 0:
await manageVectorEmbeddings();
break;
case 3:
await add_top_10_news();
break;
case 6:
await add_business_news();
break;
case 9:
await add_politics_news();
break;
case 12:
await add_sports_news();
break;
case 15:
await add_technology_news();
break;
}
Can I rely on this?
2 replies
CDCloudflare Developers
Created by Mrinank on 6/12/2024 in #pages-help
full stack Nextjs on pages with hono | Sometimes Work, Sometimes Not
No description
13 replies
CDCloudflare Developers
Created by Mrinank on 6/7/2024 in #workers-help
stop double execution of code when the time limit exceedes
var worker_default = {
async fetch(request, env, ctx) {
let counter = 0
while(true){
console.log(counter)
counter+=1
await new Promise((resolve) => setTimeout(resolve, 1000));
}
return new Response("Hello World!");
}
};
var worker_default = {
async fetch(request, env, ctx) {
let counter = 0
while(true){
console.log(counter)
counter+=1
await new Promise((resolve) => setTimeout(resolve, 1000));
}
return new Response("Hello World!");
}
};
Its printing 0,1,2,3...59 then again the loop is running and printing 0,1,2,3....59 then it stops
3 replies