Bonadio
Bonadio
CDCloudflare Developers
Created by Bonadio on 4/6/2024 in #workers-help
fetch for Anthropic Claude3 never returns
Hello I trying to send a large prompt to Claude3, 66000 (characters) with the below code. After starting it never returns and I get no error back. - If I run the same code with a small prompt (100 characters) it works. - If I run the same code in a node.js or python app with (66000 size prompt) it works fine. It seems to be something related to the workers fetch. I try to add "node_compatibility=true" in wrangler.tom but it had no effect.
const prompt = "My large prompt ...." // small prompt like "Generate a python program to print numbers from 1 to 100" works
const messages = [
{
role: "user",
content: [{
type: "text",
text: prompt
}]
}
]
const data = {
"model": "claude-3-sonnet-20240229",
"max_tokens": 4096,
"messages": messages
}
const fetchData = await fetch("https://api.anthropic.com/v1/messages",
{
method: 'POST',
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01',
'x-api-key': env.ANTHROPIC_API_KEY
},
body: JSON.stringify(data)
}
)
const prompt = "My large prompt ...." // small prompt like "Generate a python program to print numbers from 1 to 100" works
const messages = [
{
role: "user",
content: [{
type: "text",
text: prompt
}]
}
]
const data = {
"model": "claude-3-sonnet-20240229",
"max_tokens": 4096,
"messages": messages
}
const fetchData = await fetch("https://api.anthropic.com/v1/messages",
{
method: 'POST',
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01',
'x-api-key': env.ANTHROPIC_API_KEY
},
body: JSON.stringify(data)
}
)
Thanks for any help
3 replies
CDCloudflare Developers
Created by Bonadio on 12/21/2023 in #workers-help
Is there any service interruption when I redeploy a worker?
Hi, when I redeploy a worker, is there any kind of service interruption for users of the old version of my worker? Thanks
4 replies