Skip to content

Commit 91706f4

Browse files
fix code indexing and remove duplicates
1 parent 24f0d45 commit 91706f4

File tree

13 files changed

+33
-78
lines changed

13 files changed

+33
-78
lines changed

packages/types/src/global-settings.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ export const SECRET_STATE_KEYS = [
199199
"codebaseIndexMistralApiKey",
200200
"codebaseIndexVercelAiGatewayApiKey",
201201
"huggingFaceApiKey",
202-
"watsonxApiKey",
203-
"codebaseIndexWatsonxApiKey",
204-
"codebaseIndexWatsonxProjectId",
205202
"sambaNovaApiKey",
206203
"zaiApiKey",
207204
"fireworksApiKey",

packages/types/src/provider-settings.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ export const providerNames = [
139139
"vertex",
140140
"xai",
141141
"zai",
142-
"watsonx",
143142
] as const
144143

145144
export const providerNamesSchema = z.enum(providerNames)
@@ -457,7 +456,6 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
457456
huggingFaceSchema.merge(z.object({ apiProvider: z.literal("huggingface") })),
458457
chutesSchema.merge(z.object({ apiProvider: z.literal("chutes") })),
459458
litellmSchema.merge(z.object({ apiProvider: z.literal("litellm") })),
460-
watsonxSchema.merge(z.object({ apiProvider: z.literal("watsonx") })),
461459
cerebrasSchema.merge(z.object({ apiProvider: z.literal("cerebras") })),
462460
sambaNovaSchema.merge(z.object({ apiProvider: z.literal("sambanova") })),
463461
zaiSchema.merge(z.object({ apiProvider: z.literal("zai") })),

packages/types/src/providers/watsonx.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,15 @@ export const watsonxAiDefaultModelId = ""
55

66
// Common model properties
77
export const baseModelInfo: ModelInfo = {
8-
maxTokens: 131072,
8+
maxTokens: 8192,
99
contextWindow: 131072,
1010
supportsImages: false,
1111
supportsPromptCache: false,
12-
supportsReasoningEffort: true,
13-
supportsReasoningBudget: false,
14-
requiredReasoningBudget: false,
15-
inputPrice: 5.22,
16-
outputPrice: 5.22,
1712
}
1813

1914
export const watsonxAiModels = {
2015
// IBM Granite model
2116
"ibm/granite-3-3-8b-instruct": {
2217
...baseModelInfo,
23-
description: "",
2418
},
2519
} as const satisfies Record<string, ModelInfo>

pnpm-lock.yaml

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/providers/fetchers/watsonx.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,19 @@ export async function getWatsonxModels(
6868
if (Array.isArray(modelsList) && modelsList.length > 0) {
6969
for (const model of modelsList) {
7070
const modelId = model.id || model.name || model.model_id
71-
const contextWindow = model.context_length || model.max_input_tokens || 8192
72-
const maxTokens = model.max_output_tokens || Math.floor(contextWindow / 2)
71+
const contextWindow = model.model_limits.max_sequence_length || 131072
72+
const maxTokens = model.model_limits.max_output_tokens || Math.floor(contextWindow / 2)
7373

7474
let description = ""
7575
if (model.long_description) {
7676
description = model.long_description
7777
} else if (model.short_description) {
7878
description = model.short_description
7979
}
80-
const supportsImages = model.modality === "multimodal" || model.modality === "vision" || false
81-
const inputPrice = model.pricing?.input_price || 0
82-
const outputPrice = model.pricing?.output_price || 0
8380
knownModels[modelId] = {
8481
contextWindow,
8582
maxTokens,
8683
supportsPromptCache: false,
87-
supportsImages,
88-
supportsReasoningEffort: false,
89-
supportsReasoningBudget: false,
90-
requiredReasoningBudget: false,
91-
inputPrice,
92-
outputPrice,
9384
description,
9485
}
9586
}

src/api/providers/watsonx.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { BaseProvider } from "./base-provider"
88
import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
99
import { WatsonXAI } from "@ibm-cloud/watsonx-ai"
1010
import { convertToWatsonxAiMessages } from "../transform/watsonxai-format"
11-
import { calculateApiCostOpenAI } from "../../shared/cost"
1211

1312
export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHandler {
1413
private options: ApiHandlerOptions
@@ -127,7 +126,6 @@ export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHa
127126

128127
const params = this.createTextChatParams(this.projectId!, modelId, watsonxMessages)
129128
let responseText = ""
130-
let usageInfo: any = null
131129

132130
// Call the IBM watsonx API using textChat (non-streaming); can be changed to streaming..
133131
const response = await this.service.textChat(params)
@@ -142,20 +140,6 @@ export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHa
142140
type: "text",
143141
text: responseText,
144142
}
145-
146-
usageInfo = response.result.usage || {}
147-
const outputTokens = usageInfo.completion_tokens
148-
149-
const inputTokens = usageInfo?.prompt_tokens || 0
150-
const modelInfo = this.getModel().info
151-
const totalCost = calculateApiCostOpenAI(modelInfo, inputTokens, outputTokens)
152-
153-
yield {
154-
type: "usage",
155-
inputTokens: inputTokens,
156-
outputTokens,
157-
totalCost: totalCost,
158-
}
159143
} catch (error) {
160144
await vscode.window.showErrorMessage(error.message)
161145
yield {

src/core/webview/webviewMessageHandler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,12 +2530,6 @@ export const webviewMessageHandler = async (
25302530
settings.codebaseIndexMistralApiKey,
25312531
)
25322532
}
2533-
if (settings.codebaseIndexVercelAiGatewayApiKey !== undefined) {
2534-
await provider.contextProxy.storeSecret(
2535-
"codebaseIndexVercelAiGatewayApiKey",
2536-
settings.codebaseIndexVercelAiGatewayApiKey,
2537-
)
2538-
}
25392533
if (settings.codebaseIndexWatsonxApiKey !== undefined) {
25402534
await provider.contextProxy.storeSecret(
25412535
"codebaseIndexWatsonxApiKey",
@@ -2548,6 +2542,12 @@ export const webviewMessageHandler = async (
25482542
settings.codebaseIndexWatsonxProjectId,
25492543
)
25502544
}
2545+
if (settings.codebaseIndexVercelAiGatewayApiKey !== undefined) {
2546+
await provider.contextProxy.storeSecret(
2547+
"codebaseIndexVercelAiGatewayApiKey",
2548+
settings.codebaseIndexVercelAiGatewayApiKey,
2549+
)
2550+
}
25512551
// Send success response first - settings are saved regardless of validation
25522552
await provider.postMessageToWebview({
25532553
type: "codeIndexSettingsSaved",

src/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
"@aws-sdk/client-bedrock-runtime": "^3.848.0",
443443
"@aws-sdk/credential-providers": "^3.848.0",
444444
"@google/genai": "^1.0.0",
445-
"@ibm-cloud/watsonx-ai": "^1.6.8",
445+
"@ibm-cloud/watsonx-ai": "^1.6.13",
446446
"@lmstudio/sdk": "^1.1.1",
447447
"@mistralai/mistralai": "^1.9.18",
448448
"@modelcontextprotocol/sdk": "1.12.0",
@@ -522,6 +522,7 @@
522522
"@types/diff": "^5.2.1",
523523
"@types/diff-match-patch": "^1.0.36",
524524
"@types/glob": "^8.1.0",
525+
"@types/lodash.debounce": "^4.0.9",
525526
"@types/lodash": "^4.14.201",
526527
"@types/mocha": "^10.0.10",
527528
"@types/node": "20.x",

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export interface WebviewMessage {
285285
| "gemini"
286286
| "mistral"
287287
| "vercel-ai-gateway"
288+
| "watsonx"
288289
codebaseIndexEmbedderBaseUrl?: string
289290
codebaseIndexEmbedderModelId: string
290291
codebaseIndexEmbedderModelDimension?: number // Generic dimension for all providers

webview-ui/src/components/chat/CodeIndexPopover.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,14 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
408408
if (!prev.codebaseIndexMistralApiKey || prev.codebaseIndexMistralApiKey === SECRET_PLACEHOLDER) {
409409
updated.codebaseIndexMistralApiKey = secretStatus.hasMistralApiKey ? SECRET_PLACEHOLDER : ""
410410
}
411-
if (!prev.codebaseIndexWatsonxApiKey || prev.codebaseIndexWatsonxApiKey === SECRET_PLACEHOLDER) {
412-
updated.codebaseIndexWatsonxApiKey = secretStatus.hasWatsonxApiKey ? SECRET_PLACEHOLDER : ""
413-
}
414-
415411
if (
416412
!prev.codebaseIndexVercelAiGatewayApiKey ||
417413
prev.codebaseIndexVercelAiGatewayApiKey === SECRET_PLACEHOLDER
418414
) {
419415
updated.codebaseIndexVercelAiGatewayApiKey = secretStatus.hasVercelAiGatewayApiKey
416+
? SECRET_PLACEHOLDER
417+
: ""
420418
}
421-
422419
if (!prev.codebaseIndexWatsonxApiKey || prev.codebaseIndexWatsonxApiKey === SECRET_PLACEHOLDER) {
423420
updated.codebaseIndexWatsonxApiKey = secretStatus.hasWatsonxApiKey ? SECRET_PLACEHOLDER : ""
424421
}
@@ -430,16 +427,6 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
430427
? SECRET_PLACEHOLDER
431428
: ""
432429
}
433-
434-
if (
435-
!prev.codebaseIndexWatsonxProjectId ||
436-
prev.codebaseIndexWatsonxProjectId === SECRET_PLACEHOLDER
437-
) {
438-
updated.codebaseIndexWatsonxProjectId = secretStatus.hasWatsonxProjectId
439-
? SECRET_PLACEHOLDER
440-
: ""
441-
}
442-
443430
return updated
444431
}
445432

0 commit comments

Comments
 (0)