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
1 Reply
Luka
Luka13mo ago
I experience the same It's unpredictable
Want results from more Discord servers?
Add your server