File size: 800 Bytes
b486d09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7e5cb8
 
 
 
b486d09
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import got from 'got';

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 { AlibabaTogether };