|
import got from 'got'; |
|
|
|
async function CloudFlareMistralTogether(message, { system_prompt = "" } = {}) { |
|
const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/mistral/mistral-7b-instruct-v0.1`, { |
|
headers: { |
|
'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`, |
|
'Content-Type': 'application/json' |
|
}, |
|
json: { |
|
'messages': [ |
|
{"role": "system", "content": system_prompt}, |
|
{"role": "user", "content": message} |
|
], |
|
'max_tokens': 200, |
|
'stream': false |
|
} |
|
}).json(); |
|
return run.result.response; |
|
} |
|
export { CloudFlareMistralTogether }; |