Changesets · Branches · Tags · Compare
| Changeset | b350229dfa06dc2836fd5125309c044f05ef986bcf69004411a56aa684b0bbd9 |
|---|---|
| Author | Ting-Wai To <40179554+tingwai@users.noreply.github.com> · 2025-09-05 00:59 -07:00 |
| Committer | Ting-Wai To <40179554+tingwai@users.noreply.github.com> · 2025-09-05 00:59 -07:00 |
| Parents | 5191f4d3357d |
4 files changed
modified packages/openai-adapters/src/apis/Gemini.ts +4 −1
| @@ -39,7 +39,10 @@ | ||
| 39 | 39 | RerankCreateParams, |
| 40 | 40 | } from "./base.js"; |
| 41 | 41 | |
| 42 | -type UsageInfo = Pick<CompletionUsage, 'total_tokens' | 'completion_tokens' | 'prompt_tokens'>; | |
| 42 | +type UsageInfo = Pick< | |
| 43 | + CompletionUsage, | |
| 44 | + "total_tokens" | "completion_tokens" | "prompt_tokens" | |
| 45 | +>; | |
| 43 | 46 | |
| 44 | 47 | export class GeminiApi implements BaseLlmApi { |
| 45 | 48 | apiBase: string = "https://generativelanguage.googleapis.com/v1beta/"; |
modified packages/openai-adapters/src/apis/OpenAI.ts +1 −1
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | if (body.stream) { |
| 40 | 40 | (body as any).stream_options = { include_usage: true }; |
| 41 | 41 | } |
| 42 | - | |
| 42 | + | |
| 43 | 43 | // o-series models - only apply for official OpenAI API |
| 44 | 44 | const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/"; |
| 45 | 45 | if (isOfficialOpenAIAPI) { |
modified packages/openai-adapters/src/apis/Relace.ts +4 −1
| @@ -30,7 +30,10 @@ | ||
| 30 | 30 | RerankCreateParams, |
| 31 | 31 | } from "./base.js"; |
| 32 | 32 | |
| 33 | -type UsageInfo = Pick<CompletionUsage, 'total_tokens' | 'completion_tokens' | 'prompt_tokens'>; | |
| 33 | +type UsageInfo = Pick< | |
| 34 | + CompletionUsage, | |
| 35 | + "total_tokens" | "completion_tokens" | "prompt_tokens" | |
| 36 | +>; | |
| 34 | 37 | |
| 35 | 38 | // Relace only supports apply through a /v1/apply endpoint |
| 36 | 39 | export class RelaceApi implements BaseLlmApi { |
modified packages/openai-adapters/src/test/util.ts +1 −1
| @@ -108,7 +108,7 @@ | ||
| 108 | 108 | expect(usage!.prompt_tokens).toBeGreaterThan(0); |
| 109 | 109 | // Gemini 2.5 models have thinking tokens, so total_tokens >= prompt + completion |
| 110 | 110 | // Other models should have total_tokens = prompt + completion |
| 111 | - if (model.includes('gemini-2.5') || model.includes('gemini-2.0')) { | |
| 111 | + if (model.includes("gemini-2.5") || model.includes("gemini-2.0")) { | |
| 112 | 112 | expect(usage!.total_tokens).toBeGreaterThanOrEqual( |
| 113 | 113 | usage!.prompt_tokens + usage!.completion_tokens, |
| 114 | 114 | ); |