From 80e3ceda53f7c074f84ee107f125aa9e8e2f8616 Mon Sep 17 00:00:00 2001 From: Nick22nd Date: Sat, 27 Apr 2024 02:59:13 +0800 Subject: [PATCH] feat(route): add ollama models (#15383) * feat(route): add ollama models * fix some problems --- lib/routes/ollama/models.ts | 39 ++++++++++++++++++++++++++++++++++ lib/routes/ollama/namespace.ts | 6 ++++++ 2 files changed, 45 insertions(+) create mode 100644 lib/routes/ollama/models.ts create mode 100644 lib/routes/ollama/namespace.ts diff --git a/lib/routes/ollama/models.ts b/lib/routes/ollama/models.ts new file mode 100644 index 000000000..335fe4042 --- /dev/null +++ b/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, + }; +} diff --git a/lib/routes/ollama/namespace.ts b/lib/routes/ollama/namespace.ts new file mode 100644 index 000000000..1e60b826e --- /dev/null +++ b/lib/routes/ollama/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Ollama', + url: 'ollama.com', +};