Skip to main content

RAGents Frontend - A Python-embeddable Next.js frontend for RAG agents

Project description

RAGents Frontend

A Python package that bundles the RAGents Next.js frontend for easy integration into Python applications.

Installation

Using uv (recommended)

uv pip install -e .

Using pip

pip install -e .

Usage

As a Python Module

from ragents_frontend import get_frontend_path, FRONTEND_DIR
from ragents_frontend.server import create_app, serve

# Get the frontend directory path
frontend_path = get_frontend_path()
print(f"Frontend is located at: {frontend_path}")

# Create a FastAPI app with the frontend
app = create_app()

# Or serve directly
serve(host="0.0.0.0", port=3000)

As a CLI Tool

# Run the frontend server
python -m ragents_frontend

# With custom options
python -m ragents_frontend --host 127.0.0.1 --port 8080

# With auto-reload for development
python -m ragents_frontend --reload

# With a custom frontend directory
python -m ragents_frontend --frontend-dir /path/to/frontend

Integration with Existing FastAPI Apps

from fastapi import FastAPI
from ragents_frontend.server import create_app

# Your existing FastAPI app
main_app = FastAPI()

# Mount the frontend
frontend_app = create_app()
main_app.mount("/", frontend_app)

# Your API routes
@main_app.get("/api/data")
def get_data():
    return {"message": "Hello from API"}

Development

Prerequisites

  • Python 3.9+
  • Node.js 18+ (for building the frontend)
  • uv (recommended) or pip

Building the Package

  1. Build the Next.js frontend first:
cd ../ragents-frontend
npm install
npm run build
  1. Build the Python package:
cd ragents_frontend
uv build

Development Installation

uv pip install -e ".[dev]"

Running Tests

pytest

Package Structure

ragents_frontend/
├── src/
│   └── ragents_frontend/
│       ├── __init__.py          # Package entry point
│       ├── __main__.py          # CLI entry point
│       ├── server.py            # FastAPI server implementation
│       ├── frontend/            # Bundled Next.js frontend
│       └── frontend_lib/        # Frontend library code
├── pyproject.toml               # Package configuration
└── README.md                    # This file

License

MIT License

Author

Mehran Moazeni (mehran1414@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragents_frontend-0.1.0.tar.gz (27.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragents_frontend-0.1.0-py3-none-any.whl (27.6 MB view details)

Uploaded Python 3

File details

Details for the file ragents_frontend-0.1.0.tar.gz.

File metadata

  • Download URL: ragents_frontend-0.1.0.tar.gz
  • Upload date:
  • Size: 27.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for ragents_frontend-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5a0714b2b826b67856675f2d55e5290a0f3be05025624cc4c9d98d964786587f
MD5 bbd2fb5dc67613ce600597742731da05
BLAKE2b-256 77e987d0e1c66d39940661bdbe02040572ecfc56d1a2873d90437c624d889419

See more details on using hashes here.

File details

Details for the file ragents_frontend-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ragents_frontend-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ac6a31754761ad452ac28f884b0fbaf120533dc104ee218fbb8c2aacab706f3
MD5 60fd5b5812608e4491566b10c001eb3e
BLAKE2b-256 10ba77d37620666643c49d4dd3746ccc9ad7370438dee486e8c0c868945d5c0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page