Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./model": {
"types": "./src/model.ts",
"import": "./src/model.ts"
},
"./provider-identifiers": {
"types": "./src/provider-identifiers.ts",
"import": "./src/provider-identifiers.ts"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
},
"scripts": {
Expand Down
13 changes: 11 additions & 2 deletions packages/types/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ export const verbosityLevelsSchema = z.enum(verbosityLevels)

export type VerbosityLevel = z.infer<typeof verbosityLevelsSchema>

/** Serialized service tier field used in provider request payloads and responses. */
export const SERVICE_TIER_KEY = "service_tier"

/**
* Service tiers (OpenAI Responses API)
* Service tiers for the public OpenAI Responses API.
*/
export const serviceTiers = ["default", "flex", "priority"] as const
export const OpenAiServiceTier = {
Default: "default",
Flex: "flex",
Priority: "priority",
} as const

export const serviceTiers = [OpenAiServiceTier.Default, OpenAiServiceTier.Flex, OpenAiServiceTier.Priority] as const
export const serviceTierSchema = z.enum(serviceTiers)
export type ServiceTier = z.infer<typeof serviceTierSchema>

Expand Down
17 changes: 9 additions & 8 deletions src/api/providers/__tests__/bedrock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
BEDROCK_1M_CONTEXT_MODEL_IDS,
BEDROCK_SERVICE_TIER_MODEL_IDS,
bedrockModels,
SERVICE_TIER_KEY,
ApiProviderError,
} from "@roo-code/types"

Expand Down Expand Up @@ -1233,10 +1234,10 @@ describe("AwsBedrockHandler", () => {
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any

// service_tier should be at the top level of the payload
expect(commandArg.service_tier).toBe("PRIORITY")
expect(commandArg[SERVICE_TIER_KEY]).toBe("PRIORITY")
// service_tier should NOT be in additionalModelRequestFields
if (commandArg.additionalModelRequestFields) {
expect(commandArg.additionalModelRequestFields.service_tier).toBeUndefined()
expect(commandArg.additionalModelRequestFields[SERVICE_TIER_KEY]).toBeUndefined()
}
})

Expand All @@ -1263,10 +1264,10 @@ describe("AwsBedrockHandler", () => {
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any

// service_tier should be at the top level of the payload
expect(commandArg.service_tier).toBe("FLEX")
expect(commandArg[SERVICE_TIER_KEY]).toBe("FLEX")
// service_tier should NOT be in additionalModelRequestFields
if (commandArg.additionalModelRequestFields) {
expect(commandArg.additionalModelRequestFields.service_tier).toBeUndefined()
expect(commandArg.additionalModelRequestFields[SERVICE_TIER_KEY]).toBeUndefined()
}
})

Expand Down Expand Up @@ -1294,9 +1295,9 @@ describe("AwsBedrockHandler", () => {
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any

// Service tier should NOT be included for unsupported models (at top level or in additionalModelRequestFields)
expect(commandArg.service_tier).toBeUndefined()
expect(commandArg[SERVICE_TIER_KEY]).toBeUndefined()
if (commandArg.additionalModelRequestFields) {
expect(commandArg.additionalModelRequestFields.service_tier).toBeUndefined()
expect(commandArg.additionalModelRequestFields[SERVICE_TIER_KEY]).toBeUndefined()
}
})

Expand All @@ -1323,9 +1324,9 @@ describe("AwsBedrockHandler", () => {
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any

// Service tier should NOT be included when not specified (at top level or in additionalModelRequestFields)
expect(commandArg.service_tier).toBeUndefined()
expect(commandArg[SERVICE_TIER_KEY]).toBeUndefined()
if (commandArg.additionalModelRequestFields) {
expect(commandArg.additionalModelRequestFields.service_tier).toBeUndefined()
expect(commandArg.additionalModelRequestFields[SERVICE_TIER_KEY]).toBeUndefined()
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/api/providers/__tests__/openai-native-usage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach } from "vitest"
import { OpenAiNativeHandler } from "../openai-native"
import { openAiNativeModels } from "@roo-code/types"
import { OpenAiServiceTier, openAiNativeModels } from "@roo-code/types"

describe("OpenAiNativeHandler - normalizeUsage", () => {
let handler: OpenAiNativeHandler
Expand Down Expand Up @@ -468,7 +468,7 @@ describe("OpenAiNativeHandler - normalizeUsage", () => {
it("should not apply GPT-5.4 long-context pricing to priority tier", () => {
handler = new OpenAiNativeHandler({
openAiNativeApiKey: "test-key",
openAiNativeServiceTier: "priority",
openAiNativeServiceTier: OpenAiServiceTier.Priority,
})

const usage = {
Expand Down
Loading
Loading