mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
fix(voice): count OAuth caption transcriptions instead of pricing them
Voice-card captions from main priced transcription usage into the API-key dollar meter. In a ChatGPT OAuth session that could trip the $2 warning or $5 cap while the readout said COST UNKNOWN. Count them with the session's other OAuth usage instead.
This commit is contained in:
1 parent
fb1596d2f1
commit
c99653047f
2 files changed
+34
-4
No files matched your search
@@ -3208,6 +3208,7 @@ test('OAuth cloud sessions report unknown cost and usage without tripping the AP
|
|||||||
responses: 1,
|
responses: 1,
|
||||||
input: 0,
|
input: 0,
|
||||||
output: 1562500,
|
output: 1562500,
|
||||||
|
captions: 0,
|
||||||
costKnown: false,
|
costKnown: false,
|
||||||
});
|
});
|
||||||
const after = controller.costTracker.state();
|
const after = controller.costTracker.state();
|
||||||
@@ -3220,6 +3221,28 @@ test('OAuth cloud sessions report unknown cost and usage without tripping the AP
|
|||||||
assert.match(ui.costValue.title, /Usage is incomplete/);
|
assert.match(ui.costValue.title, /Usage is incomplete/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('OAuth cloud sessions count caption transcriptions without pricing them into the API cap', () => {
|
||||||
|
const { controller, ui } = costControllerHarness();
|
||||||
|
controller.status = 'listening';
|
||||||
|
controller._cost.cloudVoiceAuth = 'oauth';
|
||||||
|
controller._cost.sessionCloudVoiceAuth = 'oauth';
|
||||||
|
controller._cost.bindTranscriptionModel('gpt-4o-mini-transcribe');
|
||||||
|
const before = controller.costTracker.state();
|
||||||
|
// Priced, this much caption audio would cross the $5 cap.
|
||||||
|
const result = controller.recordTranscriptionUsage({
|
||||||
|
type: 'duration',
|
||||||
|
seconds: 3_600_000,
|
||||||
|
});
|
||||||
|
assert.equal(result.captions, 1);
|
||||||
|
assert.equal(result.costKnown, false);
|
||||||
|
const after = controller.costTracker.state();
|
||||||
|
assert.equal(after.totalUsd, before.totalUsd);
|
||||||
|
assert.equal(after.capReached, false);
|
||||||
|
assert.equal(controller.costCapStopped, false);
|
||||||
|
assert.equal(ui.costValue.textContent, 'COST UNKNOWN');
|
||||||
|
assert.match(ui.costValue.title, /1 caption transcription\(s\)/);
|
||||||
|
});
|
||||||
|
|
||||||
test('F1: when idle, toggling does re-price the preview meter', () => {
|
test('F1: when idle, toggling does re-price the preview meter', () => {
|
||||||
const { controller } = costControllerHarness();
|
const { controller } = costControllerHarness();
|
||||||
controller.status = 'idle';
|
controller.status = 'idle';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class RealtimeCost {
|
|||||||
this.voiceLimits = readStoredVoiceLimits();
|
this.voiceLimits = readStoredVoiceLimits();
|
||||||
this.cloudVoiceAuth = readStoredCloudVoiceAuthMode();
|
this.cloudVoiceAuth = readStoredCloudVoiceAuthMode();
|
||||||
this.sessionCloudVoiceAuth = null;
|
this.sessionCloudVoiceAuth = null;
|
||||||
this.oauthUsage = { responses: 0, input: 0, output: 0 };
|
this.oauthUsage = { responses: 0, input: 0, output: 0, captions: 0 };
|
||||||
this.transcribeModel = null;
|
this.transcribeModel = null;
|
||||||
this.costTracker = createVoiceCostTracker({
|
this.costTracker = createVoiceCostTracker({
|
||||||
tier: this.voiceTier,
|
tier: this.voiceTier,
|
||||||
@@ -64,12 +64,12 @@ export class RealtimeCost {
|
|||||||
if (this.ui?.costValue) {
|
if (this.ui?.costValue) {
|
||||||
const liveAuth = this.sessionCloudVoiceAuth || this.cloudVoiceAuth;
|
const liveAuth = this.sessionCloudVoiceAuth || this.cloudVoiceAuth;
|
||||||
if (liveAuth === 'oauth') {
|
if (liveAuth === 'oauth') {
|
||||||
const { responses, input, output } = this.oauthUsage;
|
const { responses, input, output, captions } = this.oauthUsage;
|
||||||
this.ui.costValue.hidden = false;
|
this.ui.costValue.hidden = false;
|
||||||
this.ui.costValue.textContent = 'COST UNKNOWN';
|
this.ui.costValue.textContent = 'COST UNKNOWN';
|
||||||
this.ui.costValue.dataset.level = 'unknown';
|
this.ui.costValue.dataset.level = 'unknown';
|
||||||
this.ui.costValue.title =
|
this.ui.costValue.title =
|
||||||
`ChatGPT OAuth session: ${responses} response(s), ${input} input and ${output} output tokens reported. ` +
|
`ChatGPT OAuth session: ${responses} response(s), ${input} input and ${output} output tokens, ${captions} caption transcription(s) reported. ` +
|
||||||
'USD cost and the API spend cap are unavailable for this auth mode.' +
|
'USD cost and the API spend cap are unavailable for this auth mode.' +
|
||||||
(state.incomplete
|
(state.incomplete
|
||||||
? ' Usage is incomplete because a response was still in flight when the session ended.'
|
? ' Usage is incomplete because a response was still in flight when the session ended.'
|
||||||
@@ -176,6 +176,13 @@ export class RealtimeCost {
|
|||||||
*/
|
*/
|
||||||
recordTranscriptionUsage(usage) {
|
recordTranscriptionUsage(usage) {
|
||||||
if (!usage) return null;
|
if (!usage) return null;
|
||||||
|
// An OAuth session has no API-dollar meter, so captions are counted
|
||||||
|
// rather than priced into the API-key warning and cap.
|
||||||
|
if (this.sessionCloudVoiceAuth === 'oauth') {
|
||||||
|
this.oauthUsage.captions += 1;
|
||||||
|
this.syncCostUi();
|
||||||
|
return { ...this.oauthUsage, costKnown: false };
|
||||||
|
}
|
||||||
return this.applyCost(
|
return this.applyCost(
|
||||||
this.costTracker.recordUsd(
|
this.costTracker.recordUsd(
|
||||||
estimateTranscriptionCostUsd(usage, this.transcribeModel),
|
estimateTranscriptionCostUsd(usage, this.transcribeModel),
|
||||||
@@ -243,7 +250,7 @@ export class RealtimeCost {
|
|||||||
this.voiceLimits = readStoredVoiceLimits();
|
this.voiceLimits = readStoredVoiceLimits();
|
||||||
this.cloudVoiceAuth = readStoredCloudVoiceAuthMode();
|
this.cloudVoiceAuth = readStoredCloudVoiceAuthMode();
|
||||||
this.sessionCloudVoiceAuth = this.cloudVoiceAuth;
|
this.sessionCloudVoiceAuth = this.cloudVoiceAuth;
|
||||||
this.oauthUsage = { responses: 0, input: 0, output: 0 };
|
this.oauthUsage = { responses: 0, input: 0, output: 0, captions: 0 };
|
||||||
this.costCapStopped = false;
|
this.costCapStopped = false;
|
||||||
// Provisional meter (tier-priced) so the readout shows $0.00 while
|
// Provisional meter (tier-priced) so the readout shows $0.00 while
|
||||||
// connecting. It is REPLACED below with one bound to the model the server
|
// connecting. It is REPLACED below with one bound to the model the server
|
||||||
|
|||||||
Reference in new issue
Block a user