feat(route): add ollama models (#15383)

* feat(route): add ollama models

* fix some problems
This commit is contained in:
Nick22nd 2024-04-27 02:59:13 +08:00 committed by GitHub
parent 472073d2fc
commit 80e3ceda53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,39 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
export const route: Route = {
path: '/library',
categories: ['programming'],
example: '/ollama/library',
radar: [
{
source: ['ollama.com/library'],
},
],
name: 'Models',
maintainers: ['Nick22nd'],
handler,
};
async function handler() {
const response = await ofetch('https://ollama.com/library');
const $ = load(response);
const items = $('#repo > ul > li > a')
.toArray()
.map((item) => {
const name = $(item).children('h2').first();
const link = $(item).attr('href');
const description = $(item).children('p').first();
return {
title: name.text(),
link,
description: description.text(),
};
});
return {
title: 'ollama library',
link: 'https://ollama.com/library',
item: items,
};
}

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Ollama',
url: 'ollama.com',
};