mirror of
https://github.com/YuWanTingbb/unofficial-gpt4.git
synced 2025-10-15 06:39:54 +00:00
新增每个密钥对于特定的机器码,一秘钥一机器码,减小被查询异常
This commit is contained in:
@@ -380,6 +380,7 @@ public class ChatController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 为每个密钥设置一个专属的machineId
|
* 为每个密钥设置一个专属的machineId
|
||||||
|
*
|
||||||
* @return hexString.toString();
|
* @return hexString.toString();
|
||||||
*/
|
*/
|
||||||
private static String generateMachineId() {
|
private static String generateMachineId() {
|
||||||
@@ -556,7 +557,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
copilotTokenList.put(apiKey, token);
|
copilotTokenList.put(apiKey, token);
|
||||||
log.info("Github CopilotToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("Github CopilotToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = copilotTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = copilotTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_copilot_limit) {
|
if (requestNum > one_copilot_limit) {
|
||||||
@@ -568,7 +569,7 @@ public class ChatController {
|
|||||||
String chat_token = copilotTokenList.get(apiKey);
|
String chat_token = copilotTokenList.get(apiKey);
|
||||||
Map<String, String> headersMap = new HashMap<>();
|
Map<String, String> headersMap = new HashMap<>();
|
||||||
//添加头部
|
//添加头部
|
||||||
addHeader(headersMap, apiKey, chat_token);
|
addHeader(headersMap, chat_token, apiKey);
|
||||||
String json = com.alibaba.fastjson2.JSON.toJSONString(conversation);
|
String json = com.alibaba.fastjson2.JSON.toJSONString(conversation);
|
||||||
RequestBody requestBody = RequestBody.create(json, JSON);
|
RequestBody requestBody = RequestBody.create(json, JSON);
|
||||||
Request.Builder requestBuilder = new Request.Builder().url(github_chat_url).post(requestBody);
|
Request.Builder requestBuilder = new Request.Builder().url(github_chat_url).post(requestBody);
|
||||||
@@ -641,7 +642,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
coCopilotTokenList.put(apiKey, token);
|
coCopilotTokenList.put(apiKey, token);
|
||||||
log.info("coCopilotToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("coCopilotToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = coCopilotTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = coCopilotTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_coCopilot_limit) {
|
if (requestNum > one_coCopilot_limit) {
|
||||||
@@ -770,7 +771,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
selfTokenLimitList.put(apiKey, new AtomicInteger(1));
|
selfTokenLimitList.put(apiKey, new AtomicInteger(1));
|
||||||
log.info("自定义selfToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("自定义selfToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = selfTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = selfTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_selfCopilot_limit) {
|
if (requestNum > one_selfCopilot_limit) {
|
||||||
@@ -891,7 +892,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
copilotTokenList.put(apiKey, token);
|
copilotTokenList.put(apiKey, token);
|
||||||
log.info("Github CopilotToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("Github CopilotToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = copilotTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = copilotTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_copilot_limit) {
|
if (requestNum > one_copilot_limit) {
|
||||||
@@ -992,7 +993,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
coCopilotTokenList.put(apiKey, token);
|
coCopilotTokenList.put(apiKey, token);
|
||||||
log.info("coCopilotToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("coCopilotToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = coCopilotTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = coCopilotTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_coCopilot_limit) {
|
if (requestNum > one_coCopilot_limit) {
|
||||||
@@ -1072,7 +1073,7 @@ public class ChatController {
|
|||||||
String machineId = generateMachineId();
|
String machineId = generateMachineId();
|
||||||
machineIdList.put(apiKey, machineId);
|
machineIdList.put(apiKey, machineId);
|
||||||
selfTokenList.put(apiKey, token);
|
selfTokenList.put(apiKey, token);
|
||||||
log.info("自定义selfToken初始化成功!对应的机械码为:"+ machineId);
|
log.info("自定义selfToken初始化成功!对应的机械码为:" + machineId);
|
||||||
} else {
|
} else {
|
||||||
int requestNum = selfTokenLimitList.get(apiKey).incrementAndGet();
|
int requestNum = selfTokenLimitList.get(apiKey).incrementAndGet();
|
||||||
if (requestNum > one_selfCopilot_limit) {
|
if (requestNum > one_selfCopilot_limit) {
|
||||||
@@ -1213,6 +1214,7 @@ public class ChatController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模型
|
* 获取模型
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Object getModels() {
|
private Object getModels() {
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
|||||||
artifactId=gpt-4-copilot
|
|
||||||
groupId=com.gpt4.copilot
|
|
||||||
version=0.1.2
|
|
Reference in New Issue
Block a user