File size: 740 Bytes
d386c7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 };