Просмотр исходного кода

fix: get model id from ApiHandler (#3512)

Not all handlers/providers use apiModelId, but they do all return a
model id from getModel().
John Richmond 7 месяцев назад
Родитель
Сommit
8a1cc06b54

+ 2 - 2
src/core/environment/__tests__/getEnvironmentDetails.test.ts

@@ -69,7 +69,6 @@ describe("getEnvironmentDetails", () => {
 			maxOpenTabsContext: 10,
 			mode: "code",
 			customModes: [],
-			apiModelId: "test-model",
 			experiments: {},
 			customInstructions: "test instructions",
 			language: "en",
@@ -102,7 +101,7 @@ describe("getEnvironmentDetails", () => {
 			} as unknown as RooIgnoreController,
 			clineMessages: [],
 			api: {
-				getModel: jest.fn().mockReturnValue({ info: { contextWindow: 100000 } }),
+				getModel: jest.fn().mockReturnValue({ id: "test-model", info: { contextWindow: 100000 } }),
 				createMessage: jest.fn(),
 				countTokens: jest.fn(),
 			} as unknown as ApiHandler,
@@ -144,6 +143,7 @@ describe("getEnvironmentDetails", () => {
 		expect(result).toContain("# Current Context Size (Tokens)")
 		expect(result).toContain("# Current Cost")
 		expect(result).toContain("# Current Mode")
+		expect(result).toContain("<model>test-model</model>")
 
 		expect(mockProvider.getState).toHaveBeenCalled()
 

+ 2 - 3
src/core/environment/getEnvironmentDetails.ts

@@ -190,7 +190,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
 
 	// Add context tokens information.
 	const { contextTokens, totalCost } = getApiMetrics(cline.clineMessages)
-	const modelInfo = cline.api.getModel().info
+	const { id: modelId, info: modelInfo } = cline.api.getModel()
 	const contextWindow = modelInfo.contextWindow
 
 	const contextPercentage =
@@ -203,7 +203,6 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
 	const {
 		mode,
 		customModes,
-		apiModelId,
 		customModePrompts,
 		experiments = {} as Record<ExperimentId, boolean>,
 		customInstructions: globalCustomInstructions,
@@ -221,7 +220,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
 	details += `\n\n# Current Mode\n`
 	details += `<slug>${currentMode}</slug>\n`
 	details += `<name>${modeDetails.name}</name>\n`
-	details += `<model>${apiModelId}</model>\n`
+	details += `<model>${modelId}</model>\n`
 
 	if (Experiments.isEnabled(experiments ?? {}, EXPERIMENT_IDS.POWER_STEERING)) {
 		details += `<role>${modeDetails.roleDefinition}</role>\n`