yxmiler commited on
Commit
ad23443
·
verified ·
1 Parent(s): bf54148

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +4 -3
index.js CHANGED
@@ -580,7 +580,6 @@ async function handleResponse(response, model, res, isStream) {
580
  for (const line of lines) {
581
  if (!line.trim()) continue;
582
  const trimmedLine = line.trim();
583
- console.log(trimmedLine)
584
  if (trimmedLine.startsWith('data: ')) {
585
  const data = trimmedLine.substring(6);
586
  try {
@@ -799,10 +798,11 @@ app.post('/hf/v1/chat/completions', async (req, res) => {
799
  },
800
  body: JSON.stringify(requestPayload)
801
  });
802
-
 
803
  if (response.ok) {
804
- Logger.info(`请求成功`, 'Server');
805
  CONFIG.SSO_INDEX = (CONFIG.SSO_INDEX + 1) % tokenManager.getTokenCount();
 
806
  Logger.info(`当前剩余可用令牌数: ${tokenManager.getTokenCount()}`, 'Server');
807
  try {
808
  await handleResponse(response, req.body.model, res, req.body.stream);
@@ -852,6 +852,7 @@ app.post('/hf/v1/chat/completions', async (req, res) => {
852
  }
853
  throw new Error('当前模型所有令牌都已耗尽');
854
  } catch (error) {
 
855
  Logger.error(error, 'ChatAPI');
856
  res.status(500).json({
857
  error: {
 
580
  for (const line of lines) {
581
  if (!line.trim()) continue;
582
  const trimmedLine = line.trim();
 
583
  if (trimmedLine.startsWith('data: ')) {
584
  const data = trimmedLine.substring(6);
585
  try {
 
798
  },
799
  body: JSON.stringify(requestPayload)
800
  });
801
+
802
+
803
  if (response.ok) {
 
804
  CONFIG.SSO_INDEX = (CONFIG.SSO_INDEX + 1) % tokenManager.getTokenCount();
805
+ Logger.info(`请求成功`, 'Server');
806
  Logger.info(`当前剩余可用令牌数: ${tokenManager.getTokenCount()}`, 'Server');
807
  try {
808
  await handleResponse(response, req.body.model, res, req.body.stream);
 
852
  }
853
  throw new Error('当前模型所有令牌都已耗尽');
854
  } catch (error) {
855
+ CONFIG.SSO_INDEX = (CONFIG.SSO_INDEX + 1) % tokenManager.getTokenCount();
856
  Logger.error(error, 'ChatAPI');
857
  res.status(500).json({
858
  error: {