mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-04 16:13:11 +00:00
fix(provider): forward metadata options to cloudflare-ai-gateway provider (#15619)
This commit is contained in:
@@ -2218,3 +2218,64 @@ test("Google Vertex: supports OpenAI compatible models", async () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("cloudflare-ai-gateway loads with env variables", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
await Bun.write(
|
||||
path.join(dir, "opencode.json"),
|
||||
JSON.stringify({
|
||||
$schema: "https://opencode.ai/config.json",
|
||||
}),
|
||||
)
|
||||
},
|
||||
})
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
init: async () => {
|
||||
Env.set("CLOUDFLARE_ACCOUNT_ID", "test-account")
|
||||
Env.set("CLOUDFLARE_GATEWAY_ID", "test-gateway")
|
||||
Env.set("CLOUDFLARE_API_TOKEN", "test-token")
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["cloudflare-ai-gateway"]).toBeDefined()
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("cloudflare-ai-gateway forwards config metadata options", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
await Bun.write(
|
||||
path.join(dir, "opencode.json"),
|
||||
JSON.stringify({
|
||||
$schema: "https://opencode.ai/config.json",
|
||||
provider: {
|
||||
"cloudflare-ai-gateway": {
|
||||
options: {
|
||||
metadata: { invoked_by: "test", project: "opencode" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
},
|
||||
})
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
init: async () => {
|
||||
Env.set("CLOUDFLARE_ACCOUNT_ID", "test-account")
|
||||
Env.set("CLOUDFLARE_GATEWAY_ID", "test-gateway")
|
||||
Env.set("CLOUDFLARE_API_TOKEN", "test-token")
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["cloudflare-ai-gateway"]).toBeDefined()
|
||||
expect(providers["cloudflare-ai-gateway"].options.metadata).toEqual({
|
||||
invoked_by: "test",
|
||||
project: "opencode",
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user