Skip to content

Commit 44c3f4c

Browse files
feat: 为 LLM 调用添加更详细的日志
Co-authored-by: aider (vertex_ai/gemini-2.5-pro) <aider@aider.chat>
1 parent 221875c commit 44c3f4c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/mcp-server/src/bridge/openai.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export function createOpenAIRouter(config: Config): Router {
1111
router.post('/chat/completions', async (req: Request, res: Response) => {
1212
try {
1313
const body = req.body as OpenAIChatCompletionRequest;
14+
console.log(
15+
'[OpenAI Bridge] Received /chat/completions request:',
16+
JSON.stringify(body, null, 2),
17+
);
1418
const stream = body.stream !== false;
1519

1620
if (!stream) {

packages/mcp-server/src/bridge/stream-transformer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export function createOpenAIStreamTransformer(
6868

6969
return new TransformStream({
7070
transform(event: ServerGeminiStreamEvent, controller) {
71+
console.log(
72+
`[Stream Transformer] Received event: ${event.type}`,
73+
event.value ? JSON.stringify(event.value) : '',
74+
);
7175
let delta: OpenAIDelta = {};
7276

7377
if (isFirstChunk) {

packages/mcp-server/src/gemini-client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ export class GeminiApiClient {
137137
}) {
138138
const history = messages.map(msg => this.openAIMessageToGemini(msg));
139139
const lastMessage = history.pop();
140+
console.log(
141+
'[GeminiApiClient] Sending to Gemini. History:',
142+
JSON.stringify(history, null, 2),
143+
);
144+
console.log(
145+
'[GeminiApiClient] Last Message:',
146+
JSON.stringify(lastMessage, null, 2),
147+
);
140148
if (!lastMessage) {
141149
throw new Error('No message to send.');
142150
}
@@ -174,6 +182,7 @@ export class GeminiApiClient {
174182
},
175183
});
176184

185+
console.log('[GeminiApiClient] Got stream from Gemini.');
177186
return geminiStream;
178187
}
179188
}

0 commit comments

Comments
 (0)