mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
parent
0978ba3996
commit
0e7a878fa5
5 changed files with 23 additions and 21 deletions
|
|
@ -377,7 +377,7 @@ const sambaNovaSchema = apiModelIdProviderModelSchema.extend({
|
|||
sambaNovaApiKey: z.string().optional(),
|
||||
})
|
||||
|
||||
export const zaiApiLineSchema = z.enum(["international_coding", "international", "china_coding", "china"])
|
||||
export const zaiApiLineSchema = z.enum(["international_coding", "china_coding"])
|
||||
|
||||
export type ZaiApiLine = z.infer<typeof zaiApiLineSchema>
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,9 @@ export const zaiApiLineConfigs = {
|
|||
baseUrl: "https://api.z.ai/api/coding/paas/v4",
|
||||
isChina: false,
|
||||
},
|
||||
international: { name: "International Standard", baseUrl: "https://api.z.ai/api/paas/v4", isChina: false },
|
||||
china_coding: { name: "China Coding Plan", baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4", isChina: true },
|
||||
china: { name: "China Standard", baseUrl: "https://open.bigmodel.cn/api/paas/v4", isChina: true },
|
||||
china_coding: {
|
||||
name: "China Coding Plan",
|
||||
baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4",
|
||||
isChina: true,
|
||||
},
|
||||
} satisfies Record<ZaiApiLine, { name: string; baseUrl: string; isChina: boolean }>
|
||||
|
|
|
|||
|
|
@ -36,21 +36,21 @@ describe("ZAiHandler", () => {
|
|||
|
||||
describe("International Z AI", () => {
|
||||
beforeEach(() => {
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international" })
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international_coding" })
|
||||
})
|
||||
|
||||
it("should use the correct international Z AI base URL", () => {
|
||||
new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international" })
|
||||
new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international_coding" })
|
||||
expect(OpenAI).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
baseURL: "https://api.z.ai/api/paas/v4",
|
||||
baseURL: "https://api.z.ai/api/coding/paas/v4",
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it("should use the provided API key for international", () => {
|
||||
const zaiApiKey = "test-zai-api-key"
|
||||
new ZAiHandler({ zaiApiKey, zaiApiLine: "international" })
|
||||
new ZAiHandler({ zaiApiKey, zaiApiLine: "international_coding" })
|
||||
expect(OpenAI).toHaveBeenCalledWith(expect.objectContaining({ apiKey: zaiApiKey }))
|
||||
})
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ describe("ZAiHandler", () => {
|
|||
const handlerWithModel = new ZAiHandler({
|
||||
apiModelId: testModelId,
|
||||
zaiApiKey: "test-zai-api-key",
|
||||
zaiApiLine: "international",
|
||||
zaiApiLine: "international_coding",
|
||||
})
|
||||
const model = handlerWithModel.getModel()
|
||||
expect(model.id).toBe(testModelId)
|
||||
|
|
@ -77,7 +77,7 @@ describe("ZAiHandler", () => {
|
|||
const handlerWithModel = new ZAiHandler({
|
||||
apiModelId: testModelId,
|
||||
zaiApiKey: "test-zai-api-key",
|
||||
zaiApiLine: "international",
|
||||
zaiApiLine: "international_coding",
|
||||
})
|
||||
const model = handlerWithModel.getModel()
|
||||
expect(model.id).toBe(testModelId)
|
||||
|
|
@ -88,19 +88,19 @@ describe("ZAiHandler", () => {
|
|||
|
||||
describe("China Z AI", () => {
|
||||
beforeEach(() => {
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "china" })
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "china_coding" })
|
||||
})
|
||||
|
||||
it("should use the correct China Z AI base URL", () => {
|
||||
new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "china" })
|
||||
new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "china_coding" })
|
||||
expect(OpenAI).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ baseURL: "https://open.bigmodel.cn/api/paas/v4" }),
|
||||
expect.objectContaining({ baseURL: "https://open.bigmodel.cn/api/coding/paas/v4" }),
|
||||
)
|
||||
})
|
||||
|
||||
it("should use the provided API key for China", () => {
|
||||
const zaiApiKey = "test-zai-api-key"
|
||||
new ZAiHandler({ zaiApiKey, zaiApiLine: "china" })
|
||||
new ZAiHandler({ zaiApiKey, zaiApiLine: "china_coding" })
|
||||
expect(OpenAI).toHaveBeenCalledWith(expect.objectContaining({ apiKey: zaiApiKey }))
|
||||
})
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ describe("ZAiHandler", () => {
|
|||
const handlerWithModel = new ZAiHandler({
|
||||
apiModelId: testModelId,
|
||||
zaiApiKey: "test-zai-api-key",
|
||||
zaiApiLine: "china",
|
||||
zaiApiLine: "china_coding",
|
||||
})
|
||||
const model = handlerWithModel.getModel()
|
||||
expect(model.id).toBe(testModelId)
|
||||
|
|
@ -127,7 +127,7 @@ describe("ZAiHandler", () => {
|
|||
const handlerWithModel = new ZAiHandler({
|
||||
apiModelId: testModelId,
|
||||
zaiApiKey: "test-zai-api-key",
|
||||
zaiApiLine: "china",
|
||||
zaiApiLine: "china_coding",
|
||||
})
|
||||
const model = handlerWithModel.getModel()
|
||||
expect(model.id).toBe(testModelId)
|
||||
|
|
@ -151,14 +151,14 @@ describe("ZAiHandler", () => {
|
|||
})
|
||||
|
||||
it("should use 'not-provided' as default API key when none is specified", () => {
|
||||
new ZAiHandler({ zaiApiLine: "international" })
|
||||
new ZAiHandler({ zaiApiLine: "international_coding" })
|
||||
expect(OpenAI).toHaveBeenCalledWith(expect.objectContaining({ apiKey: "not-provided" }))
|
||||
})
|
||||
})
|
||||
|
||||
describe("API Methods", () => {
|
||||
beforeEach(() => {
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international" })
|
||||
handler = new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international_coding" })
|
||||
})
|
||||
|
||||
it("completePrompt method should return text from Z AI API", async () => {
|
||||
|
|
@ -231,7 +231,7 @@ describe("ZAiHandler", () => {
|
|||
const handlerWithModel = new ZAiHandler({
|
||||
apiModelId: modelId,
|
||||
zaiApiKey: "test-zai-api-key",
|
||||
zaiApiLine: "international",
|
||||
zaiApiLine: "international_coding",
|
||||
})
|
||||
|
||||
mockCreate.mockImplementationOnce(() => {
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ const ApiOptions = ({
|
|||
zai: {
|
||||
field: "apiModelId",
|
||||
default:
|
||||
apiConfiguration.zaiApiLine === "china"
|
||||
apiConfiguration.zaiApiLine === "china_coding"
|
||||
? mainlandZAiDefaultModelId
|
||||
: internationalZAiDefaultModelId,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ function getSelectedModel({
|
|||
return { id, info }
|
||||
}
|
||||
case "zai": {
|
||||
const isChina = apiConfiguration.zaiApiLine === "china"
|
||||
const isChina = apiConfiguration.zaiApiLine === "china_coding"
|
||||
const models = isChina ? mainlandZAiModels : internationalZAiModels
|
||||
const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId
|
||||
const id = apiConfiguration.apiModelId ?? defaultModelId
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue