Skip to content

This project lets you point a URL to your chatbot, scrapes and indexes the page with TF-IDF, and then powers an interactive Q&A interface that uses top-k context to ground AI model responses. It’s ideal for building personal assistants that can “read” and answer questions about any website.

License

Notifications You must be signed in to change notification settings

www-norma-dev/IONOS-simple-chatbot

Repository files navigation

AI Chatbot Image

Screenshot

Project Overview

This repository contains a full-stack RAG chatbot powered by LangChain and IONOS, with separate frontend and backend folders:

  • frontend: A Next.js (React) application that allows users to input a page URL, select a model, and chat with an AI assistant based on website content.

  • backend: A FastAPI service that:

    1. Scrapes and indexes webpage text using TF-IDF for RAG.
    2. Routes chat requests to IONOS AI models, managing conversation history.
    3. Exposes endpoints for initializing RAG index, fetching chat history, and sending user messages.

Table of Contents


Prerequisites

Before you begin, ensure you have:

  • Node.js (v18 or above) and npm or yarn
  • Python (v3.10 or above)
  • pip or poetry for Python dependencies
  • An IONOS API Key for language model access

Environment Variables

Create a .env file in both the frontend and backend folders using the following template: (you can instead create a single unique .env file at project root if you prefer)

# Frontend (Next.js)
NEXT_PUBLIC_APP_BASE_URL=http://localhost:8000  # URL of the backend API

# Shared / Backend (.env)
IONOS_API_KEY=your_ionos_api_key_here           # IONOS AI Model Hub key
RAG_K=3                                         # top-k RAG chunks to retrieve (default: 3)
CHUNK_SIZE=500                                  # chars per chunk (default: 500)
MAX_CHUNK_COUNT=256                             # maximum number of chunks (default: 256)
  • NEXT_PUBLIC_APP_BASE_URL: URL where your backend is running, used by the frontend.

  • IONOS_API_KEY: Your secret key for accessing IONOS AI Model Hub (required by the backend).

  • RAG_K: Number of top chunks to retrieve for context.

  • CHUNK_SIZE: Maximum characters per chunk when splitting scraped text.

  • MAX_CHUNK_COUNT: Cap on total chunks to index.


Backend Setup

  1. Navigate to the backend folder:

    cd backend
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the FastAPI server locally:

    python main.py

    The backend will be available at http://localhost:8000.


Frontend Setup

  1. Navigate to the frontend folder:

    cd frontend
  2. Install dependencies:

    npm install
    # or
    yarn install
  3. Start the development server:

    npm run dev
    # or
    yarn dev

    The frontend will be available at http://localhost:3000.


Usage

  1. Open your browser at http://localhost:3000.
  2. Enter a page URL to scrape and wait for RAG initialization.
  3. Select an AI model from the dropdown.
  4. Start chatting—messages will be sent to the backend, enriched with top-k context, and answered by your chosen model.

Project Structure

├── frontend             # Next.js React app
│   ├── .env             # Frontend environment config
│   ├── app/
│   ├── components/
│   ├── public/
│   ├── lib/
│   └── package.json
└── backend              # FastAPI service
    ├── .env             # Backend environment config
    ├── main.py          # FastAPI entrypoint
    ├── requirements.txt
    └── other modules…

License

This project is released under the MIT License. Feel free to use and modify it in your own applications.

About

This project lets you point a URL to your chatbot, scrapes and indexes the page with TF-IDF, and then powers an interactive Q&A interface that uses top-k context to ground AI model responses. It’s ideal for building personal assistants that can “read” and answer questions about any website.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8