chore: update story summary and lint fixes
This commit is contained in:
@@ -166,6 +166,7 @@ class StreamingGeneration {
|
||||
if (!source) throw new Error(`不支持的 api: ${opts.api}`);
|
||||
|
||||
const model = String(opts.model || '').trim();
|
||||
const msgCount = Array.isArray(messages) ? messages.length : null;
|
||||
|
||||
if (!model) {
|
||||
try { xbLog.error('streamingGeneration', 'missing model', null); } catch {}
|
||||
@@ -175,7 +176,6 @@ class StreamingGeneration {
|
||||
try {
|
||||
try {
|
||||
if (xbLog.isEnabled?.()) {
|
||||
const msgCount = Array.isArray(messages) ? messages.length : null;
|
||||
xbLog.info('streamingGeneration', `callAPI stream=${!!stream} api=${String(opts.api || '')} model=${model} messages=${msgCount ?? '-'}`);
|
||||
}
|
||||
} catch {}
|
||||
@@ -286,10 +286,34 @@ class StreamingGeneration {
|
||||
}
|
||||
|
||||
|
||||
const logSendRequestError = (err, streamMode) => {
|
||||
if (err?.name !== 'AbortError') {
|
||||
const safeApiUrl = String(cmdApiUrl || reverseProxy || oai_settings?.custom_url || '').trim();
|
||||
try {
|
||||
xbLog.error('streamingGeneration', 'sendRequest failed', {
|
||||
message: err?.message || String(err),
|
||||
name: err?.name,
|
||||
stream: !!streamMode,
|
||||
api: String(opts.api || ''),
|
||||
model,
|
||||
msgCount,
|
||||
apiurl: safeApiUrl,
|
||||
});
|
||||
} catch {}
|
||||
console.error('[xbgen:callAPI] sendRequest failed:', err);
|
||||
}
|
||||
};
|
||||
|
||||
if (stream) {
|
||||
const payload = ChatCompletionService.createRequestData(body);
|
||||
|
||||
const streamFactory = await ChatCompletionService.sendRequest(payload, false, abortSignal);
|
||||
let streamFactory;
|
||||
try {
|
||||
streamFactory = await ChatCompletionService.sendRequest(payload, false, abortSignal);
|
||||
} catch (err) {
|
||||
logSendRequestError(err, true);
|
||||
throw err;
|
||||
}
|
||||
|
||||
const generator = (typeof streamFactory === 'function') ? streamFactory() : streamFactory;
|
||||
|
||||
@@ -350,7 +374,13 @@ class StreamingGeneration {
|
||||
})();
|
||||
} else {
|
||||
const payload = ChatCompletionService.createRequestData(body);
|
||||
const extracted = await ChatCompletionService.sendRequest(payload, false, abortSignal);
|
||||
let extracted;
|
||||
try {
|
||||
extracted = await ChatCompletionService.sendRequest(payload, false, abortSignal);
|
||||
} catch (err) {
|
||||
logSendRequestError(err, false);
|
||||
throw err;
|
||||
}
|
||||
|
||||
let result = '';
|
||||
if (extracted && typeof extracted === 'object') {
|
||||
|
||||
Reference in New Issue
Block a user