feat: add basic webui
This commit is contained in:
22
packages/ai/components/message.tsx
Normal file
22
packages/ai/components/message.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Message as MessageType } from 'ai';
|
||||
import type { ComponentProps } from 'react';
|
||||
import Markdown from 'react-markdown';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
type MessageProps = {
|
||||
data: MessageType;
|
||||
markdown?: ComponentProps<typeof Markdown>;
|
||||
};
|
||||
|
||||
export const Message = ({ data, markdown }: MessageProps) => (
|
||||
<div
|
||||
className={twMerge(
|
||||
'flex max-w-[80%] flex-col gap-2 rounded-xl px-4 py-2',
|
||||
data.role === 'user'
|
||||
? 'self-end bg-foreground text-background'
|
||||
: 'self-start bg-muted'
|
||||
)}
|
||||
>
|
||||
<Markdown {...markdown}>{data.content}</Markdown>
|
||||
</div>
|
||||
);
|
||||
16
packages/ai/components/thread.tsx
Normal file
16
packages/ai/components/thread.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
type ThreadProps = HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const Thread = ({ children, className, ...props }: ThreadProps) => (
|
||||
<div
|
||||
className={twMerge(
|
||||
'flex flex-1 flex-col items-start gap-4 overflow-y-auto p-8 pb-0',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
1
packages/ai/index.ts
Normal file
1
packages/ai/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from 'ai';
|
||||
7
packages/ai/lib/provider.ts
Normal file
7
packages/ai/lib/provider.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { createOpenAI } from '@ai-sdk/openai';
|
||||
import { env } from '@konobangu/env';
|
||||
|
||||
export const provider = createOpenAI({
|
||||
apiKey: env.OPENAI_API_KEY,
|
||||
compatibility: 'strict',
|
||||
});
|
||||
1
packages/ai/lib/react.ts
Normal file
1
packages/ai/lib/react.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from 'ai/react';
|
||||
23
packages/ai/package.json
Normal file
23
packages/ai/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@konobangu/ai",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo dist node_modules",
|
||||
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/openai": "^1.0.8",
|
||||
"@konobangu/env": "workspace:*",
|
||||
"ai": "^4.0.14",
|
||||
"react": "^19.0.0",
|
||||
"react-markdown": "^9.0.1",
|
||||
"tailwind-merge": "^2.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@konobangu/typescript-config": "workspace:*",
|
||||
"@types/node": "22.10.1",
|
||||
"@types/react": "19.0.1",
|
||||
"@types/react-dom": "^19.0.2"
|
||||
}
|
||||
}
|
||||
8
packages/ai/tsconfig.json
Normal file
8
packages/ai/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@konobangu/typescript-config/nextjs.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user