-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
82 lines (71 loc) · 1.56 KB
/
config.js
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
const deepSeekApiKey = "";
const openaiApiKey = "";
const Model = Object.freeze({
DeepSeek: "deepSeek",
OpenAI: "openai",
});
// 获取 API Key
const getApiKeyByModel = (model) => {
switch (model) {
case Model.DeepSeek:
return deepSeekApiKey;
case Model.OpenAI:
return openaiApiKey;
default:
return openaiApiKey;
}
};
// 获取 API EndPoint
const getApiEndPoint = (model) => {
switch (model) {
case Model.DeepSeek:
return "https://api.deepseek.com/v1/chat/completions";
case Model.OpenAI:
return "https://api.openai.com/v1/chat/completions";
default:
return "https://api.openai.com/v1/chat/completions";
}
};
// 获取 API Model
const getApiModel = (model) => {
switch (model) {
case Model.DeepSeek:
return "deepseek-chat";
case Model.OpenAI:
return "gpt-4o";
default:
return "gpt-4o";
}
};
// 每百万输入/输出 tokens 的成本($)
const getCostPerMillionTokens = (model) => {
switch (model) {
case Model.DeepSeek:
return {
input: 0.27,
output: 1.1,
};
case Model.OpenAI:
return {
input: 2.5,
output: 10,
};
default:
return {
input: 2.5,
output: 10,
};
}
}
// 切换当前使用的模型
const currModel = Model.DeepSeek;
const apiKey = getApiKeyByModel(currModel);
const apiEndPoint = getApiEndPoint(currModel);
const apiModel = getApiModel(currModel);
const apiCost = getCostPerMillionTokens(currModel);
module.exports = {
apiKey,
apiEndPoint,
apiModel,
apiCost,
}