Skip to content

Commit

Permalink
feat(route): add ollama models (#15383)
Browse files Browse the repository at this point in the history
* feat(route): add ollama models

* fix some problems
  • Loading branch information
Nick22nd committed Apr 26, 2024
1 parent 472073d commit 80e3ced
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/routes/ollama/models.ts
@@ -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,
};
}
6 changes: 6 additions & 0 deletions lib/routes/ollama/namespace.ts
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Ollama',
url: 'ollama.com',
};

0 comments on commit 80e3ced

Please sign in to comment.