Web Bae
Web Bae
Explore posts from servers
CDCloudflare Developers
Created by Web Bae on 6/19/2024 in #workers-help
D1 Best Practices dev/prod modes and --local and --remote flags
just found this, which looks to be using 2 separate databases. https://developers.cloudflare.com/d1/configuration/environments/ what is the difference between managing it like this vs. using --local and --dev flags?
2 replies
CDCloudflare Developers
Created by Web Bae on 4/15/2024 in #workers-help
Image to Text with Workers AI.
I haven’t tried that one I think - can you link me to it?
9 replies
CDCloudflare Developers
Created by Web Bae on 4/15/2024 in #workers-help
Image to Text with Workers AI.
@another_User here you go
const imgUrl = data.hostedUrl;
const response = await fetch(imgUrl);
const arrayBuffer = await response.arrayBuffer();
const arr = Array.from(new Uint8Array(arrayBuffer));

// Create an AI request with the base64 encoded image
const ai = new Ai(c.env.AI);
const input = {
image: arr, // Directly use the base64 string
prompt: 'Provide a one sentence description of the image to be used as website alt text',
max_tokens: 256,
};

const aiResponse = await ai.run<'@cf/unum/uform-gen2-qwen-500m'>('@cf/unum/uform-gen2-qwen-500m', input);
const { description } = aiResponse;
const imgUrl = data.hostedUrl;
const response = await fetch(imgUrl);
const arrayBuffer = await response.arrayBuffer();
const arr = Array.from(new Uint8Array(arrayBuffer));

// Create an AI request with the base64 encoded image
const ai = new Ai(c.env.AI);
const input = {
image: arr, // Directly use the base64 string
prompt: 'Provide a one sentence description of the image to be used as website alt text',
max_tokens: 256,
};

const aiResponse = await ai.run<'@cf/unum/uform-gen2-qwen-500m'>('@cf/unum/uform-gen2-qwen-500m', input);
const { description } = aiResponse;
9 replies
CDCloudflare Developers
Created by Web Bae on 4/21/2024 in #workers-help
Decrementing a count property by 1 with KV and Promise.all
I'm a long way from those numbers but maybe some day... haha
7 replies
CDCloudflare Developers
Created by Web Bae on 4/21/2024 in #workers-help
Decrementing a count property by 1 with KV and Promise.all
Thank you @Chaika - Refactor here I come!
7 replies
CDCloudflare Developers
Created by Web Bae on 4/21/2024 in #workers-help
Decrementing a count property by 1 with KV and Promise.all
ChatGPT says to use DO but I would love to hear what the humans say too! https://chat.openai.com/share/68757cf5-eafb-4248-80d8-28d28b5bfefc
7 replies
CDCloudflare Developers
Created by Web Bae on 4/15/2024 in #workers-help
Image to Text with Workers AI.
thanks @Raylight ! I got it working
9 replies
CDCloudflare Developers
Created by Web Bae on 4/15/2024 in #workers-help
Image to Text with Workers AI.
I've also experiement with the ai package directly in the worker (vice hitting the api endpoint). It seems the expected input is an arraybuffer... is there a way to give it a hostedUrl string?
9 replies