* feat(route/cookbook): Add OpenAICookbook fix(route/cookbook): add missing example & follow the guidelines fix(route/cookbook): use ofetch fix(route/cookbook): delete duplicated namespace.ts fix(route/cookbook): lint issues * fix: use namespace `openai` ---------
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import { getApiUrl, parseArticle } from './common';
|
|
|
|
export const route: Route = {
|
|
path: '/research',
|
|
categories: ['programming'],
|
|
example: '/openai/research',
|
|
parameters: {},
|
|
features: {
|
|
requireConfig: false,
|
|
requirePuppeteer: false,
|
|
antiCrawler: false,
|
|
supportBT: false,
|
|
supportPodcast: false,
|
|
supportScihub: false,
|
|
},
|
|
name: 'Research',
|
|
maintainers: ['yuguorui'],
|
|
handler,
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
const apiUrl = new URL('/api/v1/research-publications', await getApiUrl());
|
|
const researchRootUrl = 'https://openai.com/research';
|
|
|
|
// Construct API query
|
|
apiUrl.searchParams.append('sort', '-publicationDate,-createdAt');
|
|
apiUrl.searchParams.append('include', 'media');
|
|
|
|
const resp = await got({
|
|
method: 'get',
|
|
url: apiUrl,
|
|
});
|
|
const obj = resp.data;
|
|
|
|
const items = await Promise.all(
|
|
obj.data.map((item) => {
|
|
const attributes = item.attributes;
|
|
return parseArticle(ctx, researchRootUrl, attributes);
|
|
})
|
|
);
|
|
|
|
const title = 'OpenAI Research';
|
|
|
|
return {
|
|
title,
|
|
link: researchRootUrl,
|
|
item: items,
|
|
};
|
|
}
|