办学质量监测教学评价系统
ageer
2024-05-17 7fe89a931b291196b0b571c668bd3758309019d7
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package com.xmzs.midjourney;
 
import com.xmzs.midjourney.enums.TranslateWay;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
 
@Data
@Component
@ConfigurationProperties(prefix = "mj")
public class ProxyProperties {
    /**
     * task存储配置.
     */
    private final TaskStore taskStore = new TaskStore();
    /**
     * discord账号选择规则.
     */
    private String accountChooseRule = "BestWaitIdleRule";
    /**
     * discord单账号配置.
     */
    private final DiscordAccountConfig discord = new DiscordAccountConfig();
    /**
     * discord账号池配置.
     */
    private final List<DiscordAccountConfig> accounts = new ArrayList<>();
    /**
     * 代理配置.
     */
    private final ProxyConfig proxy = new ProxyConfig();
    /**
     * 反代配置.
     */
    private final NgDiscordConfig ngDiscord = new NgDiscordConfig();
    /**
     * 百度翻译配置.
     */
    private final BaiduTranslateConfig baiduTranslate = new BaiduTranslateConfig();
    /**
     * openai配置.
     */
    private final OpenaiConfig openai = new OpenaiConfig();
    /**
     * 中文prompt翻译方式.
     */
    private TranslateWay translateWay = TranslateWay.NULL;
    /**
     * 接口密钥,为空不启用鉴权;调用接口时需要加请求头 mj-api-secret.
     */
    private String apiSecret;
    /**
     * 任务状态变更回调地址.
     */
    private String notifyHook;
    /**
     * 通知回调线程池大小.
     */
    private int notifyPoolSize = 10;
 
    @Data
    public static class DiscordAccountConfig {
        /**
         * 服务器ID.
         */
        private String guildId;
        /**
         * 频道ID.
         */
        private String channelId;
        /**
         * 用户Token.
         */
        private String userToken;
        /**
         * 用户UserAgent.
         */
        private String userAgent = Constants.DEFAULT_DISCORD_USER_AGENT;
        /**
         * 是否可用.
         */
        private boolean enable = true;
        /**
         * 并发数.
         */
        private int coreSize = 3;
        /**
         * 等待队列长度.
         */
        private int queueSize = 10;
        /**
         * 任务超时时间(分钟).
         */
        private int timeoutMinutes = 5;
    }
 
    @Data
    public static class BaiduTranslateConfig {
        /**
         * 百度翻译的APP_ID.
         */
        private String appid;
        /**
         * 百度翻译的密钥.
         */
        private String appSecret;
    }
 
    @Data
    public static class OpenaiConfig {
        /**
         * 自定义gpt的api-url.
         */
        private String gptApiUrl;
        /**
         * gpt的api-key.
         */
        private String gptApiKey;
        /**
         * 超时时间.
         */
        private Duration timeout = Duration.ofSeconds(30);
        /**
         * 使用的模型.
         */
        private String model = "gpt-3.5-turbo";
        /**
         * 返回结果的最大分词数.
         */
        private int maxTokens = 2048;
        /**
         * 相似度,取值 0-2.
         */
        private double temperature = 0;
    }
 
    @Data
    public static class TaskStore {
        /**
         * 任务过期时间,默认30天.
         */
        private Duration timeout = Duration.ofDays(30);
        /**
         * 任务存储方式: redis(默认)、in_memory.
         */
        private Type type = Type.IN_MEMORY;
 
        public enum Type {
            /**
             * redis.
             */
            REDIS,
            /**
             * in_memory.
             */
            IN_MEMORY
        }
    }
 
    @Data
    public static class ProxyConfig {
        /**
         * 代理host.
         */
        private String host;
        /**
         * 代理端口.
         */
        private Integer port;
    }
 
    @Data
    public static class NgDiscordConfig {
        /**
         * https://discord.com 反代.
         */
        private String server;
        /**
         * https://cdn.discordapp.com 反代.
         */
        private String cdn;
        /**
         * wss://gateway.discord.gg 反代.
         */
        private String wss;
        /**
         * https://discord-attachments-uploads-prd.storage.googleapis.com 反代.
         */
        private String uploadServer;
    }
 
    @Data
    public static class TaskQueueConfig {
        /**
         * 并发数.
         */
        private int coreSize = 3;
        /**
         * 等待队列长度.
         */
        private int queueSize = 10;
        /**
         * 任务超时时间(分钟).
         */
        private int timeoutMinutes = 5;
    }
}