This is a Next.js chatbot application that integrates with the Ollama and OpenAI API
deepseek-coder-v2:latest
.llama3.2
, deepseek-coder-v2:latest
).git clone https://github.com/csabika98/NextJS-AI-Chatbot.git
cd NextJS-AI-Chatbot.git
Install the required Node.js packages:
npm install
# or
yarn install
# or
pnpm install
Key dependencies include:
next
, react
, react-dom
: Core Next.js and React libraries.react-markdown
, remark-breaks
, remark-gfm
: For Markdown rendering.@next/font
: For font optimization (Poppins font).Install Ollama: Follow the instructions at Ollama Download to install Ollama on your machine.
Start the Ollama Server:
ollama serve
This runs the server at http://localhost:11434
by default.
Pull a Model: Download the desired AI model (e.g., deepseek-coder-v2:latest
):
ollama pull deepseek-coder-v2:latest
Verify available models:
ollama list
Create a .env
file in the project root to configure the Ollama server host:
Also you can set the OpenAI model + your API_KEY
These two are mandatory for Ollama:
NEXT_PUBLIC_OLLAMA_HOST=http://localhost:11434
NEXT_PUBLIC_CHATBOT_OLLAMA_MODEL_NAME=deepseek-coder-v2:latest
These two are mandatory for OpenAI
NEXT_PUBLIC_OPENAI_DEFAULT_MODEL=gpt-4.1-2025-04-14
NEXT_PUBLIC_OPENAI_API_KEY=<your_key>
You can combine them:
NEXT_PUBLIC_OLLAMA_HOST=http://localhost:11434
NEXT_PUBLIC_CHATBOT_OLLAMA_MODEL_NAME=deepseek-coder-v2:latest
NEXT_PUBLIC_OPENAI_DEFAULT_MODEL=gpt-4.1-2025-04-14
NEXT_PUBLIC_OPENAI_API_KEY=
If using a different host or port, update the value accordingly.
Feel free to edit the base prompt.
const SYSTEM_PROMPT = `You are a helpful assistant. If i type "test" you should answer "test" only, Format all responses in Markdown, using appropriate syntax for headings, lists, code blocks, tables, and other elements where applicable. Use single backticks (\`) for inline code (e.g., \`StringBuilder\`) and triple backticks (\`\`\`) with language identifiers for code blocks (e.g., \`\`\`java\ncode\n\`\`\`).`;
export default SYSTEM_PROMPT;
Styles are defined in app/globals.css
and inline in components. To modify the appearance:
userMessage
and botMessage
classes in ChatBox.tsx
.components
prop in ReactMarkdown
to style lists, code blocks, tables, etc.app/globals.css
for app-wide changes.Example: Change the bot message background color in globals.css
:
.botMessage {
background-color: #d1d5db; /* New color */
}
@next/font
.