diff --git a/app/api/chat-messages/route.ts b/app/api/chat-messages/route.ts new file mode 100644 index 0000000..453035e --- /dev/null +++ b/app/api/chat-messages/route.ts @@ -0,0 +1,18 @@ +import { type NextRequest } from 'next/server' +import { cookies } from 'next/headers' +import { client } from '@/service' + +export async function POST(request: NextRequest) { + const { inputs, query, conversation_id } = await request.json() + const cookieStore = cookies() + const user = cookieStore.get('user')?.value || 'anonymous' + + const res = await client.createChatMessage( + inputs, + query, + user, + true, + conversation_id + ) + return new Response(res.data) +} diff --git a/app/chat/main.tsx b/app/chat/main.tsx index e5508b6..8facec3 100644 --- a/app/chat/main.tsx +++ b/app/chat/main.tsx @@ -1,11 +1,9 @@ 'use client' -import { Suspense } from 'react' import { FC, useReducer } from 'react' import { AppProps, ConversationsProps, LocaleProps } from '@/interface' import Button from '@/components/button' import PencilSquare from '@heroicons/react/24/solid/PencilSquareIcon' import MenuItem from '@/components/menu-item' -import Loading from '@/components/loading' import Welcome from '@/components/welcome' import Form from '@/components/form' import XPowerBy, { XPowerByPrivacy } from '@/components/x-power-by' @@ -65,42 +63,40 @@ const Main: FC = ({ }) return ( <> - }> -
-
- - 🤖️ - - - {I18N(locale)('app.name')} +
+
+ + 🤖️ + + + {I18N(locale)('app.name')} + +
+
+ +
+
+
+ {I18N(locale)('app.chats')}
-
- -
-
-
- {I18N(locale)('app.chats')} -
-
- {}} /> - {}} /> - {}} /> - {}} /> -
+
+ {}} /> + {}} /> + {}} /> + {}} />
- +