@@ -8,7 +8,6 @@ import { BaseProvider } from "./base-provider"
88import type { SingleCompletionHandler , ApiHandlerCreateMessageMetadata } from "../index"
99import { WatsonXAI } from "@ibm-cloud/watsonx-ai"
1010import { convertToWatsonxAiMessages } from "../transform/watsonxai-format"
11- import { calculateApiCostOpenAI } from "../../shared/cost"
1211
1312export 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 {
0 commit comments