refactor(core): keep Codex routing in plugin
This commit is contained in:
parent
2de8ab95d1
commit
aef37e4514
4 changed files with 39 additions and 72 deletions
|
|
@ -307,7 +307,7 @@ describe("ModelResolver", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps an explicit endpoint for ChatGPT OAuth credentials", () =>
|
||||
it.effect("does not reinterpret an explicit endpoint based on the OAuth method", () =>
|
||||
Effect.gen(function* () {
|
||||
const resolved = yield* ModelResolver.fromCatalogModel(
|
||||
model(Provider.aisdk("@ai-sdk/openai"), {
|
||||
|
|
@ -338,7 +338,7 @@ describe("ModelResolver", () => {
|
|||
endpoint: { baseURL: "https://openai.example/v1" },
|
||||
})
|
||||
expect(headers.authorization).toBe("Bearer chatgpt-token")
|
||||
expect(headers["chatgpt-account-id"]).toBe("acct_123")
|
||||
expect(headers["chatgpt-account-id"]).toBeUndefined()
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
@ -367,7 +367,7 @@ describe("ModelResolver", () => {
|
|||
|
||||
expect(resolved.route.endpoint.baseURL).toBe("https://openai.example/v1")
|
||||
expect(headers.authorization).toBe("Bearer chatgpt-token")
|
||||
expect(headers["chatgpt-account-id"]).toBe("acct_123")
|
||||
expect(headers["chatgpt-account-id"]).toBeUndefined()
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
@ -407,37 +407,6 @@ describe("ModelResolver", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps an explicit endpoint for ChatGPT OAuth credentials without an account id", () =>
|
||||
Effect.gen(function* () {
|
||||
const resolved = yield* ModelResolver.fromCatalogModel(
|
||||
model(Provider.aisdk("@ai-sdk/openai"), {
|
||||
settings: { baseURL: "https://openai.example/v1" },
|
||||
headers: {},
|
||||
body: {},
|
||||
}),
|
||||
Credential.OAuth.make({
|
||||
type: "oauth",
|
||||
methodID: Integration.MethodID.make("chatgpt-headless"),
|
||||
access: "chatgpt-token",
|
||||
refresh: "refresh",
|
||||
expires: Date.now() + 60_000,
|
||||
}),
|
||||
)
|
||||
const request = LLM.request({ model: resolved, prompt: "Hello" })
|
||||
const headers = yield* resolved.route.auth.apply({
|
||||
request,
|
||||
method: "POST",
|
||||
url: "https://openai.example/v1/responses",
|
||||
body: "{}",
|
||||
headers: Headers.empty,
|
||||
})
|
||||
|
||||
expect(resolved.route.endpoint.baseURL).toBe("https://openai.example/v1")
|
||||
expect(headers.authorization).toBe("Bearer chatgpt-token")
|
||||
expect(headers["chatgpt-account-id"]).toBeUndefined()
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps non-ChatGPT OAuth credentials on the configured endpoint", () =>
|
||||
Effect.gen(function* () {
|
||||
const resolved = yield* ModelResolver.fromCatalogModel(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue