Skip to content

Implementasi chatbot sederhana menggunakan API dari ollama dan Dify AI dengan next.js

Notifications You must be signed in to change notification settings

siddiqodiq/Simple-chatbot-website-with-Ollama-or-dify-AI-APi-using-Next-js

Repository files navigation

Simple chatbot with Ollama using next.js

This project is a React-based Chat Application that uses an AI assistant model for generating responses. It leverages TailwindCSS for styling, ollama-ai-provider for AI interactions, and incorporates live streaming of AI-generated text.


🚀 Features

  • AI-Powered Chat: Integrates with a large language model for generating conversational responses.
  • Real-time Streaming: Messages are displayed as they are generated by the AI.
  • TailwindCSS Styling: Responsive and modern design powered by TailwindCSS.
  • Interactive UI: Smooth input handling and message display.

🛠️ Installation and Setup

Prerequisites

  • Node.js (v16 or higher)
  • NPM or Yarn package manager

Steps to Setup

  1. Clone this repository:

    git clone https://github.com/your-repo/chat-app.git
    cd chat-app
  2. Install dependencies:

    npm install
  3. Add ShadCN components (for UI elements):

    npx shadcn@latest add button input card scroll-area
  4. Start the development server:

    npm run dev
  5. Access the app at http://localhost:3000.

*if your chatbot using dify AI API, switch the branch to dify-ai-api

📂 Project Structure

  • pages/index.tsx: Main entry point for the chat interface.
  • actions.ts: Defines AI-related functions and streaming logic.
  • components/ui/: UI elements like buttons, inputs, cards, and scroll areas.
  • globals.css: Custom TailwindCSS styles.
  • lib/utils.ts: Utility functions for className merging.

📋 Usage

  1. Type a message in the chat input box.
  2. Press the Send button.
  3. The AI assistant will respond with a streaming message.

🛠️ Dependencies

  • Next.js: React framework for server-side rendering.
  • TailwindCSS: CSS utility-first framework.
  • Lucide React: For icons like loading spinners.
  • Ollama-AI Provider: Integration for language model interactions.

📘 Customization

AI Model

The AI model used can be modified in actions.ts:

const model = ollama("hf.co/ojisetyawan/llama3-8b-cpt-sahabatai-v1-instruct-Q4_K_M-GGUF");

Replace the model with your desired model URL.

Styles

Modify globals.css for customizing the theme and styles.


⚡ Commands

  • Start Development Server: npm run dev
  • Build for Production: npm run build
  • Run Production Build: npm start

Screenshot (809)

💬 Feedback

For any questions, feedback, or suggestions, please reach out via https://siddiqodiq.me

About

Implementasi chatbot sederhana menggunakan API dari ollama dan Dify AI dengan next.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published