Skip to content

Commit

Permalink
feat(route): Add Chub (#15298)
Browse files Browse the repository at this point in the history
* Create characters.ts

* Create namespace.ts

* Update characters.ts

* remove uncessary ctx

* Update lib/routes/chub/characters.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/chub/characters.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/chub/characters.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/chub/characters.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Moved topics to category field

* replaced got with ofetch + query

* Update characters.ts

* Update lib/routes/chub/characters.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

---------
  • Loading branch information
flameleaf authored Apr 28, 2024
1 parent b566ebb commit d4a88c7
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
68 changes: 68 additions & 0 deletions lib/routes/chub/characters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/characters',
categories: ['new-media'],
example: '/chub/characters',
name: 'Characters',
maintainers: ['flameleaf'],
handler,
};


async function handler() {
const hostURL = 'https://www.chub.ai/characters';
const apiURL = 'https://api.chub.ai/api/characters/search';
const data = await ofetch(apiURL, {
headers: { Accept: 'application/json' },
query: {
query: '',
first: 200,
page: 1,
sort: 'last_activity_at',
asc: 'false',
include_forks: 'false',
nsfw: 'true',
nsfl: 'true',
nsfw_only: 'false',
require_images: 'false',
require_example_dialogues: 'false',
require_alternate_greetings: 'false',
require_custom_prompt: 'false',
exclude_mine: 'false',
venus: 'true',
chub: 'true',
min_tokens: 50,
require_expressions: 'false',
require_lore: 'false',
mine_first: 'false',
require_lore_embedded: 'false',
require_lore_linked: 'false',
inclusive_or: 'false',
recommended_verified: 'false',
},
});
const nodes = data.nodes;

return {
allowEmpty: true,
title: 'Chub',
link: hostURL,
item: nodes
.map((item) => ({
title: item.name,
description: `${item.tagline}<br><br>${item.description}`,
pubDate: parseDate(item.createdAt),
updated: parseDate(item.lastActivityAt),
link: `${hostURL}/${item.fullPath}`,
author: String(item.fullPath.split('/', 1)),
enclosure_url: item.avatar_url,
enclosure_type: `image/webp`,
category: item.topics,
})),
};
}


6 changes: 6 additions & 0 deletions lib/routes/chub/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Chub',
url: 'chub.ai',
};

0 comments on commit d4a88c7

Please sign in to comment.