Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| import API from './API' | |
| class Descriptions { | |
| private static instance: Descriptions | null = null | |
| private descriptions: Record<string, any> = {} | |
| private modelDescriptions: Record<string, any> = {} | |
| private metricDescriptions: Record<string, any> = {} | |
| private datasetDescriptions: Record<string, any> = {} | |
| private loaded: boolean = false | |
| private loadingPromise: Promise<void> | null = null | |
| private constructor() {} | |
| static getInstance(): Descriptions { | |
| if (!Descriptions.instance) { | |
| Descriptions.instance = new Descriptions() | |
| } | |
| return Descriptions.instance | |
| } | |
| async load(): Promise<void> { | |
| if (this.loaded) return | |
| if (this.loadingPromise) return this.loadingPromise | |
| this.loadingPromise = API.fetchDescriptions().then((data) => { | |
| this.descriptions = data.descriptions || {} | |
| this.modelDescriptions = data.model_descriptions || {} | |
| this.metricDescriptions = data.metric_descriptions || {} | |
| this.datasetDescriptions = data.dataset_descriptions || {} | |
| this.loaded = true | |
| }) | |
| return this.loadingPromise | |
| } | |
| getDescriptionFullName(name: string): string | undefined { | |
| return this.descriptions[name]?.full_name | |
| } | |
| getDescription(name: string): string | undefined { | |
| return this.descriptions[name]?.description | |
| } | |
| getDescriptionUrl(name: string): string | undefined { | |
| return this.descriptions[name]?.link | |
| } | |
| getModelAlias(name: string): string | undefined { | |
| return this.modelDescriptions[name]?.alias | |
| } | |
| getModelDescription(name: string): string | undefined { | |
| return this.modelDescriptions[name]?.description | |
| } | |
| getModelFullName(name: string): string | undefined { | |
| return this.modelDescriptions[name]?.full_name | |
| } | |
| getModelPaperUrl(name: string): string | undefined { | |
| return this.modelDescriptions[name]?.paper_link | |
| } | |
| getModelGithubUrl(name: string): string | undefined { | |
| return this.modelDescriptions[name]?.github_link | |
| } | |
| getModelMessageSize(name: string): number | undefined { | |
| return this.modelDescriptions[name]?.message_size | |
| } | |
| // Metric description methods | |
| getMetricDescription(name: string): string | undefined { | |
| return this.metricDescriptions[name]?.description | |
| } | |
| getMetricFullName(name: string): string | undefined { | |
| return this.metricDescriptions[name]?.full_name | |
| } | |
| getMetricUrl(name: string): string | undefined { | |
| return this.metricDescriptions[name]?.link | |
| } | |
| // Dataset description methods | |
| getDatasetDescription(name: string): string | undefined { | |
| return this.datasetDescriptions[name]?.description | |
| } | |
| getDatasetFullName(name: string): string | undefined { | |
| return this.datasetDescriptions[name]?.full_name | |
| } | |
| getDatasetPaperUrl(name: string): string | undefined { | |
| return this.datasetDescriptions[name]?.paper_link | |
| } | |
| getDatasetGithubUrl(name: string): string | undefined { | |
| return this.datasetDescriptions[name]?.github_link | |
| } | |
| } | |
| export default Descriptions | |