mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 21:20:44 +00:00
Merge branch 'main' into fix/test-artifacts-and-shell-permissions
This commit is contained in:
commit
6653edeb0c
24 changed files with 1190 additions and 19 deletions
|
|
@ -34,6 +34,7 @@ import {
|
|||
import { getCoreSystemPrompt, getCustomSystemPrompt } from './prompts.js';
|
||||
import { DEFAULT_QWEN_FLASH_MODEL } from '../config/models.js';
|
||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||
import { promptIdContext } from '../utils/promptIdContext.js';
|
||||
import { setSimulate429 } from '../utils/testUtils.js';
|
||||
import { ideContextStore } from '../ide/ideContext.js';
|
||||
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
||||
|
|
@ -2441,6 +2442,55 @@ Other open files:
|
|||
);
|
||||
});
|
||||
|
||||
it('should prefer the current prompt id context for stateless requests', async () => {
|
||||
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
||||
const abortSignal = new AbortController().signal;
|
||||
|
||||
await promptIdContext.run('btw-prompt-id', async () => {
|
||||
await client.generateContent(
|
||||
contents,
|
||||
{},
|
||||
abortSignal,
|
||||
DEFAULT_QWEN_FLASH_MODEL,
|
||||
);
|
||||
});
|
||||
|
||||
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
model: DEFAULT_QWEN_FLASH_MODEL,
|
||||
contents,
|
||||
}),
|
||||
'btw-prompt-id',
|
||||
);
|
||||
});
|
||||
|
||||
it('should prefer an explicit prompt id override over the current context', async () => {
|
||||
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
||||
const abortSignal = new AbortController().signal;
|
||||
|
||||
await promptIdContext.run('context-prompt-id', async () => {
|
||||
await (
|
||||
client.generateContent as unknown as (
|
||||
...args: unknown[]
|
||||
) => Promise<GenerateContentResponse>
|
||||
)(
|
||||
contents,
|
||||
{},
|
||||
abortSignal,
|
||||
DEFAULT_QWEN_FLASH_MODEL,
|
||||
'override-prompt-id',
|
||||
);
|
||||
});
|
||||
|
||||
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
model: DEFAULT_QWEN_FLASH_MODEL,
|
||||
contents,
|
||||
}),
|
||||
'override-prompt-id',
|
||||
);
|
||||
});
|
||||
|
||||
it('should use config system prompt override when provided', async () => {
|
||||
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
||||
const abortSignal = new AbortController().signal;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import { reportError } from '../utils/errorReporting.js';
|
|||
import { getErrorMessage } from '../utils/errors.js';
|
||||
import { checkNextSpeaker } from '../utils/nextSpeakerChecker.js';
|
||||
import { flatMapTextParts } from '../utils/partUtils.js';
|
||||
import { promptIdContext } from '../utils/promptIdContext.js';
|
||||
import { retryWithBackoff } from '../utils/retry.js';
|
||||
|
||||
// Hook types and utilities
|
||||
|
|
@ -786,8 +787,11 @@ export class GeminiClient {
|
|||
generationConfig: GenerateContentConfig,
|
||||
abortSignal: AbortSignal,
|
||||
model: string,
|
||||
promptIdOverride?: string,
|
||||
): Promise<GenerateContentResponse> {
|
||||
let currentAttemptModel: string = model;
|
||||
const promptId =
|
||||
promptIdOverride ?? promptIdContext.getStore() ?? this.lastPromptId!;
|
||||
|
||||
try {
|
||||
const userMemory = this.config.getUserMemory();
|
||||
|
|
@ -810,7 +814,7 @@ export class GeminiClient {
|
|||
config: requestConfig,
|
||||
contents,
|
||||
},
|
||||
this.lastPromptId!,
|
||||
promptId,
|
||||
);
|
||||
};
|
||||
const result = await retryWithBackoff(apiCall, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue