Skip to content
Source
Sign inSign up
TanStack/schemas

Clear the price of a Gemini id the pricing page no longer names #311

Mergedtombeckenhammerged 1 commit intomain fromrefs/pull/311/headmerged by tombeckenham View on GitHub

Showing 4 changed files with 63 additions and 14 deletions (loading 1).

x
0 of 4 viewed, 4 left
36 additions and 11 deletionssrc/server/providers/gemini-pricing.tsModified
View file
@@ -384,19 +384,34 @@
unit?: UnitCardSpec
​
+const SECTION = '<div class="models-section">'
+​
+/** The heading group's `<em>` lists every id the section prices. */
+function headingIds(chunk: string): Array<string> {
+ return [
+ ...chunk
+ .slice(0, chunk.indexOf('</em>'))
+ .matchAll(/<code[^>]*>([a-z0-9][a-z0-9.-]+)<\/code>/g),
+ ].map(([, value = '']) => value)
+}
+​
+/**
+ * Every id a section heading names, including sections `parseGeminiPricing`
+ * refuses. A listed id missing from this is one the page no longer prices
+ * (issue #300: deprecated ids routed to a successor), not a parser miss.
+ */
+export function geminiNamedIds(html: string): Array<string> {
+ return [...new Set(html.split(SECTION).slice(1).flatMap(headingIds))]
+}
+​
/** Model id → per-token rates parsed from its Standard table. */
export function parseGeminiPricing(