chore: commit current working state with config updates, test fixes, and continuity ledgers
This commit is contained in:
1 parent
afe8859f16
commit
04014b8c7d
64 files changed
+5412
-4972
No files matched your search
@@ -16,7 +16,7 @@ import { Observable } from 'rxjs';
|
||||
|
||||
import { ProxyGuard } from './proxy.guard';
|
||||
import { ProxyService } from './proxy.service';
|
||||
import { GeminiRequest, GeminiResponse } from './interfaces/request-interfaces';
|
||||
import type { GeminiRequest, GeminiResponse } from './interfaces/request-interfaces';
|
||||
import { getServerConfig } from '../../server-config';
|
||||
import { getAllDynamicModels } from '../../../lib/geminiNexus/ModelMapping';
|
||||
import { TokenManagerService } from './token-manager.service';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Injectable, Logger, NotFoundException, BadRequestException, Inject } from '@nestjs/common';
|
||||
import { registerProxyAdvancedService } from '../../../ipc/proxy-advanced/service-registry';
|
||||
import { ProxyService } from './proxy.service';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import {
|
||||
OpenAIChatRequest,
|
||||
AnthropicChatRequest,
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ProxyService, ProxyRequestContext, ProxyConfigOverride } from './proxy.
|
||||
import { ProxyReplayService } from './proxy-replay.service';
|
||||
import { Observable, interval, map } from 'rxjs';
|
||||
import { trafficLogger } from '../../../utils/traffic-logger';
|
||||
import {
|
||||
import type {
|
||||
OpenAIChatRequest,
|
||||
AnthropicChatRequest,
|
||||
OpenAIChatResponse,
|
||||
@@ -223,15 +223,7 @@ export class ProxyController {
|
||||
this.tokenManager?.getAllCollectedModels(),
|
||||
);
|
||||
|
||||
const capabilitiesMap: Record<string, { vision: boolean; streaming: boolean; jsonMode: boolean; audio: boolean; imageGeneration: boolean }> = {
|
||||
'gemini-3-pro': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: true },
|
||||
'gemini-3-pro-image': { vision: true, streaming: false, jsonMode: false, audio: false, imageGeneration: true },
|
||||
'gemini-3-flash': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
'gemini-3-flash-lite': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
'claude-3-5-sonnet': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
'claude-3-5-haiku': { vision: false, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
'claude-3-opus': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
};
|
||||
const capabilitiesMap = this.buildCapabilitiesMap();
|
||||
|
||||
const data = modelIds.map((id) => {
|
||||
const baseId = Object.keys(capabilitiesMap).find((key) => id.includes(key)) ?? 'gemini-3-flash';
|
||||
@@ -265,6 +257,34 @@ export class ProxyController {
|
||||
}
|
||||
}
|
||||
|
||||
private buildCapabilitiesMap(): Record<string, { vision: boolean; streaming: boolean; jsonMode: boolean; audio: boolean; imageGeneration: boolean }> {
|
||||
const allTokens = this.tokenManager?.getAllTokens() ?? [];
|
||||
const map: Record<string, { vision: boolean; streaming: boolean; jsonMode: boolean; audio: boolean; imageGeneration: boolean }> = {};
|
||||
|
||||
for (const [, tokenData] of allTokens) {
|
||||
for (const [modelId, modelInfo] of Object.entries(tokenData.quota?.models ?? {})) {
|
||||
if (map[modelId]) continue;
|
||||
const baseId = modelId.toLowerCase();
|
||||
const isProImage = baseId.includes('gemini-3-pro') && baseId.includes('image');
|
||||
map[baseId] = {
|
||||
vision: modelInfo.supports_images ?? false,
|
||||
streaming: isProImage ? false : true,
|
||||
jsonMode: isProImage ? false : true,
|
||||
audio: false,
|
||||
imageGeneration: baseId.includes('gemini-3-pro') && !baseId.includes('flash'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(map).length === 0) {
|
||||
return {
|
||||
'gemini-3-flash': { vision: true, streaming: true, jsonMode: true, audio: false, imageGeneration: false },
|
||||
};
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Post('batch/completions')
|
||||
async batchCompletions(
|
||||
@Body() body: { requests: OpenAIChatRequest[] },
|
||||
|
||||
@@ -180,6 +180,12 @@ export class RateLimitTracker {
|
||||
deleted++;
|
||||
}
|
||||
}
|
||||
for (const [key, entry] of this.failureCounts.entries()) {
|
||||
if (entry.lastFailureMs + FAILURE_COUNT_EXPIRY_MS <= now) {
|
||||
this.failureCounts.delete(key);
|
||||
deleted++;
|
||||
}
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import axios from 'axios';
|
||||
import { isString } from 'lodash-es';
|
||||
import { version } from '../../../../package.json';
|
||||
import { getGeminiNexusVersion } from '../../../utils/geminiNexusVersion';
|
||||
import { logger } from '../../../utils/logger';
|
||||
|
||||
const REMOTE_VERSION_URL = 'https://antigravity-auto-updater-974169037036.us-central1.run.app';
|
||||
const CHANGELOG_URL = 'https://antigravity.google/changelog';
|
||||
export const FALLBACK_VERSION = '1.22.2';
|
||||
export const FALLBACK_VERSION = version;
|
||||
const DEFAULT_REMOTE_TIMEOUT_MS = 2500;
|
||||
const VERSION_REGEX = /\d+\.\d+\.\d+/g;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { RateLimitReason, RateLimitTracker } from './rate-limit-tracker';
|
||||
import { updateDynamicForwardingRules } from '../../../lib/geminiNexus/ModelMapping';
|
||||
import { registerProxyAdvancedService } from '../../../ipc/proxy-advanced/service-registry';
|
||||
|
||||
interface TokenData {
|
||||
export interface TokenData {
|
||||
email: string;
|
||||
account_id: string;
|
||||
access_token: string;
|
||||
@@ -36,7 +36,7 @@ interface GetNextTokenOptions {
|
||||
accountId?: string;
|
||||
}
|
||||
|
||||
type TokenEntry = [string, TokenData];
|
||||
export type TokenEntry = [string, TokenData];
|
||||
|
||||
interface CircuitBreakerEntry {
|
||||
failureCount: number;
|
||||
@@ -1158,6 +1158,10 @@ export class TokenManagerService implements OnModuleInit {
|
||||
return GoogleAPIService.normalizeRefreshedOAuthClientKey(currentToken, refreshedClientKey);
|
||||
}
|
||||
|
||||
getAllTokens(): TokenEntry[] {
|
||||
return Array.from(this.tokens.entries());
|
||||
}
|
||||
|
||||
getAllCollectedModels(): Set<string> {
|
||||
const allModels = new Set<string>();
|
||||
for (const tokenData of this.tokens.values()) {
|
||||
|
||||
Reference in new issue
Block a user