Web Bae
Explore posts from serversCDCloudflare Developers
•Created by Web Bae on 7/1/2024 in #workers-help
Service Workers and Typescript
Hello!
I'm trying to call worker B from worker A.
I've set up everything as described in the docs (https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/) and the calls work, but receive Typescript errors:
I found this on the forum: https://community.cloudflare.com/t/binding-service-rpc-using-typescript/652041
Still can't get something working 😦
Found this as well, still can't figure it out: https://developers.cloudflare.com/workers/runtime-apis/rpc/typescript/
Note worker A and worker B are in separate repos, so maybe it's a moot point in this case? I'm not super familar with RPC stuff.
7 replies
CDCloudflare Developers
•Created by Web Bae on 6/28/2024 in #workers-help
Require JSON output from Workers AI?
Hello!
Looking through all the models in Workers AI.
Any chance to force output response in JSON format?
I saw OpenAI has a JSON mode but not sure if cloudflare offers anything like that?
https://community.openai.com/t/openai-api-guide-using-json-mode/557265
Thanks!
1 replies
CDCloudflare Developers
•Created by Web Bae on 6/19/2024 in #workers-help
D1 Best Practices dev/prod modes and --local and --remote flags
Hi!
What are best practices around databases with D1 for building web apps that have dev and prod modes?
I tried creating a wrangler.toml like this:
notice the ids are the same.
when I create migrations, I have to use --env=dev and --env=prod flags. But not I have duplicated migrations in the same folder.
What's the right way to do this? Should I have two databases in each env? A dev and a prod?
Or should I control using the --local and --remote flags somehow?
2 replies
CDCloudflare Developers
•Created by Web Bae on 5/16/2024 in #workers-help
Can I specify language output for image-to-text?
Default return is in English, can I specify which language to output in? Didn't see anything in docs.
If not, I'll just use the translation AI models but figured I would ask!
2 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
Hi!
I'm using workers KV to keep track of # of credits a user has (the count property).
i.e.
{user1234: {credits: 10}}
In my client application, I'm using Promise.all
to make multiple requests to an endpoint on my Worker /decrementCreditsByOne
which does what the name implies.
It works great locally, but on the deployed worker, The count loses track.
My app frequently uses Promise.all
to call /decrementCreditsByOne
at least 10 times.
the function essentially gets
the JSON from KV using the unique key, decrement the credits by 1, then puts
the value back in with the updated credits.
Is KV the wrong choice here? Would Durable Objects, or D1 be better? What would you recommend? Should this work and my logic is just wrong?
Also, I noticed timestamps aren't really a thing with KV. They aren't a requirement for my app but would be nice to have!7 replies
CDCloudflare Developers
•Created by Web Bae on 4/15/2024 in #workers-help
Image to Text with Workers AI.
Hello! I'm testing out some options for creating image alt text using AI.
Most API endpoints I've trialed take a image URL string as the input paramter.
The cloudflare API JSON schema is unfamiliar to me - where am I passing the image here?
https://developers.cloudflare.com/workers-ai/models/uform-gen2-qwen-500m/
The Cloudflare API docs also don't seem to list Image to Text as an available endpoint.
https://developers.cloudflare.com/api/operations/workers-ai-post-run-cf-microsoft-resnet-50
Finally, the API offers GET for model search. https://developers.cloudflare.com/api/operations/workers-ai-search-model
I found the url listed doesn't work:
https://api.cloudflare.com/client/v4/apiv4/accounts/{account_id}/models/search
But this did return a bunch of models, including the image-to-text model I want to trial (@cf/unum/uform-gen2-qwen-500m)
https://api.cloudflare.com/client/v4/accounts/{{account_id}}/ai/models/search
Can someone help me decipher if an image-to-text endpoint is available and how to send that request? The docs are really confusing me here.9 replies
AOAnswer Overflow
•Created by Web Bae on 4/9/2024 in #questions
Application did not respond error
![No description](https://cdn.answeroverflow.com/1227284649651339325/Xnapper-2024-04-09-08.49.55.png)
4 replies