File size: 2,977 Bytes
b486d09
 
6a260ce
3e97dd2
06beaf4
3e97dd2
06beaf4
 
 
 
3e97dd2
 
06beaf4
1620cb9
 
 
06beaf4
 
3e97dd2
 
06beaf4
 
6a260ce
651c3c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a260ce
b486d09
 
 
 
 
 
 
 
 
 
 
 
d7e5cb8
 
 
 
b486d09
 
 
 
6a260ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import got from 'got';

export async function CloudFlareQwenTogether(message, { system_prompt = "" } = {}) {
    const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/qwen/qwen1.5-1.8b-chat`, {
        headers: {
            'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`,
            'Content-Type': 'application/json'
        },
        json: {
            'messages': [
                {"role": "system", "content": system_prompt},
                {"role": "user", "content": message}
            ],
            'temperature': 0.7,
            'top_p': 0.7,
            'repetition_penalty': 1,
            'stream': false
        }
    }).json();
    return run.result.response;
}

export async function DeepseekQwenTogether(message, { system_prompt = "" } = {}) {
    const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/deepseek-ai/deepseek-r1-distill-qwen-32b`, {
        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 async function AlibabaTogether(message, { system_prompt = "" } = {}) {
    const response = await got.post('https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions', {
        headers: {
            'Authorization': 'Bearer ' + process.env['ALIBABA_API_KEY'],
            'Content-Type': 'application/json'
        },
        json: {
            'model': 'qwen-plus',
            'messages': [
              {"role": "system", "content": system_prompt},
              
              {'role': 'user', 'content': message}
            ],
            'temperature': 0.7,
            'top_p': 0.7,
            'repetition_penalty': 1,
            'stream': false
        }
    }).json();
    return response.choices[0].message.content;
}

export async function AlibabaTurboTogether(message, { system_prompt = "" } = {}) {
    const response = await got.post('https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions', {
        headers: {
            'Authorization': 'Bearer ' + process.env['ALIBABA_API_KEY'],
            'Content-Type': 'application/json'
        },
        json: {
            'model': 'qwen-turbo-latest',
            'messages': [
              {"role": "system", "content": system_prompt},
              
              {'role': 'user', 'content': message}
            ],
            'temperature': 0.7,
            'top_p': 0.7,
            'repetition_penalty': 1,
            'stream': false
        }
    }).json();
    return response.choices[0].message.content;
}