Skip to content

Commit 3d7a2a5

Browse files
authored
feat: add logging for request and response IDs in ZgsmAiHandler (#451)
1 parent 81106a1 commit 3d7a2a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/api/providers/zgsm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export class ZgsmAiHandler extends BaseProvider implements SingleCompletionHandl
164164

165165
let stream
166166
try {
167+
this.logger.info(`[RequestID]:`, requestId)
167168
const { data: _stream, response } = await this.client.chat.completions
168169
.create(
169170
requestOptions,
@@ -172,6 +173,7 @@ export class ZgsmAiHandler extends BaseProvider implements SingleCompletionHandl
172173
}),
173174
)
174175
.withResponse()
176+
this.logger.info(`[ResponseID]:`, response.headers.get("x-request-id"))
175177
stream = _stream
176178
this.curStream = _stream
177179
if (this.options.zgsmModelId === autoModeModelId) {
@@ -200,12 +202,14 @@ export class ZgsmAiHandler extends BaseProvider implements SingleCompletionHandl
200202

201203
let response
202204
try {
205+
this.logger.info(`[RequestID]:`, requestId)
203206
response = await this.client.chat.completions.create(
204207
requestOptions,
205208
Object.assign(isAzureAiInference ? { path: OPENAI_AZURE_AI_INFERENCE_PATH } : {}, {
206209
headers: _headers,
207210
}),
208211
)
212+
this.logger.info(`[ResponseId]:`, response._request_id)
209213
} catch (error) {
210214
throw handleOpenAIError(error, this.providerName)
211215
}
@@ -217,7 +221,6 @@ export class ZgsmAiHandler extends BaseProvider implements SingleCompletionHandl
217221

218222
yield this.processUsageMetrics(response.usage, modelInfo)
219223
}
220-
this.logger.info(`[RequestID]:`, requestId)
221224
}
222225

223226
protected processUsageMetrics(usage: any, _modelInfo?: ModelInfo): ApiStreamUsageChunk {

0 commit comments

Comments
 (0)