Spaces:
Running
Running
import { BaseProviderFetcher } from "./base"; | |
import { ProviderEntry, FeatherlessModel } from "./types"; | |
export class FeatherlessFetcher extends BaseProviderFetcher { | |
name = "featherless"; | |
constructor(apiKey?: string) { | |
super("https://api.featherless.ai", apiKey, { | |
requestsPerMinute: 60, // Conservative default | |
}); | |
} | |
async fetchModels(): Promise<ProviderEntry[]> { | |
try { | |
const response = await this.fetchWithRetry<{ data: FeatherlessModel[] }>( | |
`${this.baseUrl}/v1/models` | |
); | |
return response.data.map((model) => this.mapModelToProviderEntry(model)); | |
} catch (error) { | |
console.error(`Failed to fetch Featherless models: ${error}`); | |
return []; | |
} | |
} | |
private mapModelToProviderEntry(model: FeatherlessModel): ProviderEntry { | |
const entry: ProviderEntry = { | |
provider: this.name, | |
context_length: model.context_length, | |
max_completion_tokens: model.max_completion_tokens, | |
status: model.available_on_current_plan ? "live" : "offline", | |
owned_by: model.owned_by, | |
model_class: model.model_class, | |
is_gated: model.is_gated, | |
}; | |
return entry; | |
} | |
} | |