AngusMa
AngusMa
CDCloudflare Developers
Created by AngusMa on 8/3/2024 in #workers-help
Embedding worker in Notion
I’m trying to embed my worker in my Notion page, but when Notion sends a HEAD request to my worker, I’m not sure what to return to let Notion know that this URL can be embedded. Can you help me out with this?
5 replies
CDCloudflare Developers
Created by AngusMa on 6/24/2024 in #workers-help
workers.api.error.tail_not_allowed [code: 100150]
I was trying to deploy a worker that connect to a tail worker, but wrangler gave me an error:tail_not_allowed [code: 100150] Here is my wrangler.toml
name = "check-ios-app-update"
main = "src/worker.js"
compatibility_date = "2024-06-19"
workers_dev = true
tail_consumers = [{service = "tail"}]

[placement]
mode = "smart"

[triggers]
crons = [ "*/30 * * * *" ]

[[kv_namespaces]]
id = "<hidden>"
binding = "KV"
name = "check-ios-app-update"
main = "src/worker.js"
compatibility_date = "2024-06-19"
workers_dev = true
tail_consumers = [{service = "tail"}]

[placement]
mode = "smart"

[triggers]
crons = [ "*/30 * * * *" ]

[[kv_namespaces]]
id = "<hidden>"
binding = "KV"
3 replies
CDCloudflare Developers
Created by AngusMa on 6/20/2024 in #workers-help
Dashboard can't count Chinese characters correctly
No description
4 replies
CDCloudflare Developers
Created by AngusMa on 1/19/2024 in #workers-help
504 error when calling the Text-to-Image model
When I called the AI model through the ai.run function, it returned a document like the attachment 504.html:
model="@cf/stabilityai/stable-diffusion-xl-base-1.0";
inputs={
prompt: "cyberpunk cat",
num_steps: 20
}
ai.run(model, inputs)
model="@cf/stabilityai/stable-diffusion-xl-base-1.0";
inputs={
prompt: "cyberpunk cat",
num_steps: 20
}
ai.run(model, inputs)
The AI model can be called normally by the API endpoint:
fetch(
"https://api.cloudflare.com/client/v4/accounts/"+env.CLOUDFLARE_ACCOUNT+"/ai/run/"+model,
{
method: "POST",
headers:{
"Content-Type":"application/json",
"User-Agent":"awwbot/10",
"Authorization":"Bearer "+env.CLOUDFLARE_TOKEN
} ,
body:JSON.stringify(inputs)
})
fetch(
"https://api.cloudflare.com/client/v4/accounts/"+env.CLOUDFLARE_ACCOUNT+"/ai/run/"+model,
{
method: "POST",
headers:{
"Content-Type":"application/json",
"User-Agent":"awwbot/10",
"Authorization":"Bearer "+env.CLOUDFLARE_TOKEN
} ,
body:JSON.stringify(inputs)
})
1 replies
CDCloudflare Developers
Created by AngusMa on 12/23/2023 in #workers-help
Workers AI Error
Sometimes the Workers AI will throw a SyntaxError, but it doesn’t always fail, It usually succeeds. Code part about Workers AI:
const ai = new Ai(env.AI);
const output = ai.run('@cf/meta/llama-2-7b-chat-int8', {
prompt: args.prompt
}).then(function (result){
return result;
}).then(async function (result){
await fetch('https://discord.com/api/v10/webhooks/'+env.DISCORD_APPLICATION_ID+'/'+interaction.token+'/messages/@original',{
method:'PATCH',
headers:{'content-type': 'application/json;charset=UTF-8',},
body:JSON.stringify({
content: result.response,
})
})
})
const ai = new Ai(env.AI);
const output = ai.run('@cf/meta/llama-2-7b-chat-int8', {
prompt: args.prompt
}).then(function (result){
return result;
}).then(async function (result){
await fetch('https://discord.com/api/v10/webhooks/'+env.DISCORD_APPLICATION_ID+'/'+interaction.token+'/messages/@original',{
method:'PATCH',
headers:{'content-type': 'application/json;charset=UTF-8',},
body:JSON.stringify({
content: result.response,
})
})
})
The error (root directory path replaced with PROJECT_DIR):
✘ [ERROR] Uncaught (in promise) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON

at async InferenceSession.run
({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6124:26)
at async Ai.run
({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6192:30)


✘ [ERROR] Uncaught (async) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
✘ [ERROR] Uncaught (in promise) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON

at async InferenceSession.run
({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6124:26)
at async Ai.run
({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6192:30)


✘ [ERROR] Uncaught (async) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
3 replies
CDCloudflare Developers
Created by AngusMa on 12/17/2023 in #workers-help
Execute something after return
I want to use Workers AI on Discord through my bot, AI content takes a long time to generate, so I need to respond Discord first and update the result later. Is there a way to solve it? By the way, how do I get my account ID?
13 replies