├── .env.example ├── .eslintrc.json ├── .vs ├── slnx.sqlite ├── chat-llm │ └── v17 │ │ └── .wsuo └── VSWorkspaceState.json ├── app ├── favicon.ico ├── globals.css ├── layout.tsx ├── api │ └── chat │ │ └── route.ts └── page.tsx ├── public ├── clean.png ├── patient.png ├── vercel.svg ├── ai.svg ├── next.svg └── user.svg ├── next.config.js ├── postcss.config.js ├── .gitignore ├── tailwind.config.ts ├── tsconfig.json ├── package.json ├── styles └── root.module.css └── README.md /.env.example: -------------------------------------------------------------------------------- 1 | GOOGLE_API_KEY= -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanugurajesh/Chat-LLM/HEAD/.vs/slnx.sqlite -------------------------------------------------------------------------------- /app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanugurajesh/Chat-LLM/HEAD/app/favicon.ico -------------------------------------------------------------------------------- /public/clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanugurajesh/Chat-LLM/HEAD/public/clean.png -------------------------------------------------------------------------------- /public/patient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanugurajesh/Chat-LLM/HEAD/public/patient.png -------------------------------------------------------------------------------- /.vs/chat-llm/v17/.wsuo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanugurajesh/Chat-LLM/HEAD/.vs/chat-llm/v17/.wsuo -------------------------------------------------------------------------------- /.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "" 4 | ], 5 | "PreviewInSolutionExplorer": false 6 | } -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {} 3 | 4 | module.exports = nextConfig 5 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | box-sizing: border-box; 7 | } -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next' 2 | import { Inter } from 'next/font/google' 3 | import './globals.css' 4 | 5 | const inter = Inter({ subsets: ['latin'] }) 6 | 7 | export const metadata: Metadata = { 8 | title: 'Chat LLM', 9 | description: 'Chat with Gemini Pro LLM', 10 | } 11 | 12 | export default function RootLayout({ 13 | children, 14 | }: { 15 | children: React.ReactNode 16 | }) { 17 | return ( 18 | 19 |
{children} 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'tailwindcss' 2 | 3 | const config: Config = { 4 | content: [ 5 | './pages/**/*.{js,ts,jsx,tsx,mdx}', 6 | './components/**/*.{js,ts,jsx,tsx,mdx}', 7 | './app/**/*.{js,ts,jsx,tsx,mdx}', 8 | ], 9 | theme: { 10 | extend: { 11 | backgroundImage: { 12 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 13 | 'gradient-conic': 14 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 15 | }, 16 | }, 17 | }, 18 | plugins: [], 19 | } 20 | export default config 21 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chat-llm", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@google/generative-ai": "^0.1.3", 13 | "next": "14.0.4", 14 | "react": "^18", 15 | "react-dom": "^18", 16 | "react-hot-toast": "^2.4.1", 17 | "react-markdown": "^9.0.1", 18 | "react-spinners": "^0.13.8" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^20", 22 | "@types/react": "^18", 23 | "@types/react-dom": "^18", 24 | "autoprefixer": "^10.0.1", 25 | "eslint": "^8", 26 | "eslint-config-next": "14.0.4", 27 | "postcss": "^8", 28 | "tailwindcss": "^3.3.0", 29 | "typescript": "^5" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /styles/root.module.css: -------------------------------------------------------------------------------- 1 | .user { 2 | float: left; 3 | max-width: 50%; 4 | background-color: white; 5 | border: 1px solid #ccc; 6 | } 7 | 8 | .model { 9 | float: right; 10 | max-width: 50%; 11 | background-color: white; 12 | border: 1px solid #ccc; 13 | } 14 | 15 | .container { 16 | display: flex; 17 | flex-direction: column; 18 | align-items: center; 19 | height: 100vh; 20 | width: 100vw; 21 | gap: 10px; 22 | padding: 20px; 23 | } 24 | 25 | .chatHistory { 26 | height: 90vh; 27 | width: 100%; 28 | padding: 20px 10px; 29 | overflow-y: scroll; 30 | } 31 | 32 | .inputContainer { 33 | display: flex; 34 | flex-direction: row; 35 | padding: 20px 10px; 36 | height: 10vh; 37 | width: 100vw; 38 | } 39 | 40 | .button { 41 | background-color: black; 42 | color: white; 43 | padding: 10px; 44 | border-radius: 5px; 45 | cursor: pointer; 46 | font-weight: 600; 47 | border: none; 48 | } 49 | 50 | .input { 51 | width: 280px; 52 | padding: 10px; 53 | border-radius: 5px; 54 | border: 1px solid #ccc; 55 | outline: none; 56 | padding-right: 40px; 57 | } 58 | 59 | .icons { 60 | display: flex; 61 | flex-direction: row; 62 | gap: 10px; 63 | } -------------------------------------------------------------------------------- /public/ai.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/api/chat/route.ts: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from "next/server"; 2 | 3 | import { GoogleGenerativeAI } from "@google/generative-ai"; 4 | 5 | const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY as string); 6 | 7 | const model = genAI.getGenerativeModel({ model: "gemini-pro"}); 8 | 9 | const chat = model.startChat({ 10 | history: [ 11 | // you can write any conversation history here 12 | // { 13 | // role: "user", 14 | // parts: "Hello, can you answer my questions.", 15 | // }, 16 | // { 17 | // role: "model", 18 | // parts: "Sure, what do you want to know?", 19 | // }, 20 | ], 21 | generationConfig: { 22 | maxOutputTokens: 1000, 23 | }, 24 | }); 25 | 26 | export async function POST(req: NextRequest) { 27 | 28 | // get prompt field from the request body 29 | const reqBody = await req.json(); 30 | 31 | // get the userPrompt from the request body 32 | const { userPrompt } = reqBody; 33 | 34 | const result = await chat.sendMessage(userPrompt); 35 | 36 | const response = await result.response; 37 | 38 | const text = response.text(); 39 | 40 | if (text === "") { 41 | return NextResponse.json({ 42 | text: "Sorry, I don't understand.", 43 | }); 44 | } 45 | 46 | return NextResponse.json({ 47 | text, 48 | }); 49 | 50 | } -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/user.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### 🌟star this repo if you like it 2 |