From 1b80e37057411d1ed202bebb771fc3c33e7569da Mon Sep 17 00:00:00 2001 From: Baptiste Adrien Date: Thu, 6 Jun 2024 11:22:00 +0200 Subject: [PATCH 1/2] feat: switch to gpt-o, fix some issue (#122) --- package.json | 1 - src/app/(app)/page.tsx | 5 +++-- src/middleware.ts | 9 --------- src/pages/api/teams/[teamId]/bookmark/summary.tsx | 8 ++++---- src/services/database/link.ts | 2 +- src/utils/openai.ts | 4 ++-- 6 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 src/middleware.ts diff --git a/package.json b/package.json index 0b731cd..bc40998 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@radix-ui/react-tabs": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.5", "@react-icons/all-files": "^4.1.0", - "@redirection.io/vercel-middleware": "^0.1.4", "@resvg/resvg-js": "^2.4.1", "@sendinblue/client": "^3.3.1", "@sentry/nextjs": "^7.51.2", diff --git a/src/app/(app)/page.tsx b/src/app/(app)/page.tsx index bc12fc0..229b7be 100644 --- a/src/app/(app)/page.tsx +++ b/src/app/(app)/page.tsx @@ -3,8 +3,9 @@ import { getCurrentUser } from '@/lib/sessions'; export const dynamic = 'force-dynamic'; const Home = async () => { - await getCurrentUser(); - return ; + const user = await getCurrentUser(); + + return ; }; export default Home; diff --git a/src/middleware.ts b/src/middleware.ts deleted file mode 100644 index 031c7d7..0000000 --- a/src/middleware.ts +++ /dev/null @@ -1,9 +0,0 @@ -import redirectionioMiddleware from '@redirection.io/vercel-middleware'; - -export default redirectionioMiddleware; - -export const config = { - unstable_allowDynamic: [ - '/node_modules/@redirection.io/**', - ], -} diff --git a/src/pages/api/teams/[teamId]/bookmark/summary.tsx b/src/pages/api/teams/[teamId]/bookmark/summary.tsx index 2fb4118..7f8f613 100644 --- a/src/pages/api/teams/[teamId]/bookmark/summary.tsx +++ b/src/pages/api/teams/[teamId]/bookmark/summary.tsx @@ -1,10 +1,10 @@ -import { openAiCompletion } from '@/utils/openai'; import { checkProAccount, checkTeam } from '@/lib/middleware'; import { AuthApiRequest, errorHandler } from '@/lib/router'; +import { getTeamById } from '@/services/database/team'; +import { openAiCompletion } from '@/utils/openai'; +import Parser from '@postlight/parser'; import type { NextApiResponse } from 'next'; import { createRouter } from 'next-connect'; -import Parser from '@postlight/parser'; -import { getTeamById } from '@/services/database/team'; export const router = createRouter(); @@ -38,7 +38,7 @@ router .slice(0, 5500) .join(' '); - const response = await openAiCompletion({ prompt, model: 'gpt-4' }); + const response = await openAiCompletion({ prompt }); const summary = response[0]?.message?.content; return res.status(201).json(summary); diff --git a/src/services/database/link.ts b/src/services/database/link.ts index 8c217ac..95d0231 100644 --- a/src/services/database/link.ts +++ b/src/services/database/link.ts @@ -176,7 +176,7 @@ export const generateLinksTags = async ( --- `; - const response = await openAiCompletion({ prompt, model: 'gpt-4' }); + const response = await openAiCompletion({ prompt }); const data = response[0].message.content; if (data === 'NONE' || !data) return []; diff --git a/src/utils/openai.ts b/src/utils/openai.ts index a8ae996..e631114 100644 --- a/src/utils/openai.ts +++ b/src/utils/openai.ts @@ -6,10 +6,10 @@ const openai = new OpenAI({ export const openAiCompletion = async ({ prompt, - model = 'gpt-3.5-turbo', + model = 'gpt-4o', }: { prompt: string; - model?: 'gpt-3.5-turbo' | 'gpt-4'; + model?: 'gpt-4o' | 'gpt-4-turbo'; }) => { const chatCompletion = await openai.chat.completions.create({ messages: [{ role: 'user', content: prompt }], From 4523dd7abe36e9f6ae937fe7d785d195d6429380 Mon Sep 17 00:00:00 2001 From: Baptiste Adrien Date: Thu, 6 Jun 2024 15:58:12 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7a846fe..5c52a08 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,8 @@ yarn dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +## Sponsors + +This project is being developed by [Premier Octet](https://www.premieroctet.com), a Web and mobile agency specializing in React and React Native developments. +