临时打印req body方便排查问题
This commit is contained in:
@@ -640,6 +640,7 @@ async function streamAssistant(sessionId, run, session, messages, tools) {
|
||||
// 本轮是否启用深度思考;由 postUserMessage 从消息 POST 参数写进 run
|
||||
deepThink: !!run.deepThink,
|
||||
onMeta: handleSseMeta,
|
||||
onFetchParams: params => log.debug('req', JSON.stringify(params, null, 2)),
|
||||
onBadData: raw => log.warn('sse', sessionId + ' 坏帧:' + raw.slice(0, 200)),
|
||||
// data 解析成功但没有 choices(如 event: error 帧):上游发了非正常响应,
|
||||
// 之前会伪装成"0 字"沉默忽略,这里 warn 把原始 evt 打出来便于定位。
|
||||
|
||||
@@ -249,6 +249,13 @@ async function callModel(cfg, modelId, messages, tools, options) {
|
||||
const headers = { 'Content-Type': 'application/json' };
|
||||
if (modelCfg.api_key) headers.Authorization = 'Bearer ' + modelCfg.api_key;
|
||||
|
||||
if (opts.onFetchParams) {
|
||||
const logBody = { ...body };
|
||||
delete logBody.messages;
|
||||
delete logBody.tools;
|
||||
opts.onFetchParams(logBody);
|
||||
}
|
||||
|
||||
const res = await fetch(modelCfg.url + '/chat/completions', {
|
||||
method: 'POST',
|
||||
headers,
|
||||
|
||||
Reference in New Issue
Block a user