feat: add huggingface provider and new model logos

- Add HuggingFace as AI provider with model fetching
- Add Poolside, Tencent, and HuggingFace logo components
- Update model mappings for new providers
- Add @ai-sdk/huggingface dependency
- Bump longcat-ai-sdk-provider to 0.0.5
This commit is contained in:
Zoe
2026-05-11 17:43:02 -05:00
parent a0f2e89154
commit a1aeed51e2
8 changed files with 197 additions and 9 deletions
+51
View File
@@ -0,0 +1,51 @@
import { createHuggingFace } from '@ai-sdk/huggingface';
import { GatewayFetchError } from '~~/server/utils/ai-provider';
import { Err, Ok } from '~~/types/result';
import type { ProviderModule } from '.';
import { getModelData } from './helpers';
export default {
id: 'huggingface',
baseUrl: 'https://router.huggingface.co/v1',
modelsEndpoint: null,
createGateway({ apiKey, baseURL }) {
if (apiKey === undefined) {
return Err(GatewayFetchError.NoProviderApiKey);
}
return Ok({
gateway: createHuggingFace({ apiKey, baseURL }),
streamTransformer: undefined,
textTransformer: undefined,
});
},
getAuthHeaders(apiKey) {
return apiKey ? { Authorization: `Bearer ${apiKey}` } : {};
},
async fetchModels({ baseURL, apiKey, modelsDevData }) {
const res = await fetch(
'https://huggingface.co/api/models?pipeline_tag=text-generation&sort=downloads',
{
method: 'GET',
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
},
);
const data = await res.json();
if (!res.ok) {
throw createError({ statusCode: res.status, message: JSON.stringify(data) });
}
return data
.filter((model: any) => model.tags?.includes('text-generation-inference'))
.map((model: any) => ({
...getModelData(model.id, 'huggingface', modelsDevData),
id: model.id,
name: model.id,
releasedAt: model.createdAt,
}));
},
} satisfies ProviderModule;
+2
View File
@@ -12,6 +12,7 @@ import nvidia from './nvidia';
import xiaomi from './xiaomi';
import openai from './openai';
import anthropic from './anthropic';
import huggingface from './huggingface';
import type { Result } from '~~/types/result';
import type { Gateway, GatewayFetchError } from '~~/server/utils/ai-provider';
import type { Model as ModelDrizzle } from '~/composables/useModels';
@@ -65,6 +66,7 @@ const providers = [
xiaomi,
openai,
anthropic,
huggingface,
];
type ProviderId = typeof providers[number]['id'];