Skip to content

Ms1black/mws-gpt

 
 

Repository files navigation

MWS GPT Workspace

Unified AI workspace: text chat, voice, images, files, web search, long-term memory, deep research, presentation generation, and automatic model routing — all powered by the MWS GPT API.

Quick start for judges / first-time setup → QUICKSTART.md (bilingual EN/RU)

One-command Docker boot, no Python / Node / Postgres needed on the host.

Project Structure

backend/              Python backend (FastAPI)
  app/
    config.py         Settings & environment variables
    application.py    FastAPI app factory
    db/
      base.py         SQLAlchemy Base + TimestampMixin
      session.py      Async session & get_db_session dependency
      models/         ORM models (User, Conversation, Message, Memory, File, FileChunk)
      dao/            Data access layer (GenericDAO + per-entity DAOs)
    services/         Business logic (Chat, Memory, Audio, Image, Embedding, Model, Conversation)
    schemas/          Pydantic request/response models
    web/
      api/            API routers (chat, conversations, audio, images, files, web, memory, models)
      error_handlers.py
  alembic/            Database migrations
  tests/              pytest suite
  Dockerfile
  pyproject.toml      Dependencies & tool config (ruff, pytest)
  main.py             Uvicorn entrypoint

ml/                   ML intelligence layer
  router.py           3-stage model router (attachment -> heuristic -> LLM)
  prompt_engine.py    Jinja2 template engine for system prompts
  context_manager.py  Token budgeting & context window packing
  pipelines/          Pipeline configs (ASR, VLM, ImageGen, RAG)
  prompts/            Jinja2 templates (text_chat, code, vlm, rag, web_search, etc.)

frontend/             OpenWebUI fork (git submodule)

docs/                 Feature specs per branch
  backend/            Backend feature docs (01-chat-proxy .. 11-deep-research)
  frontend/           Frontend feature docs (01-text-chat .. 12-deep-research)
  ml/                 ML feature docs (01-model-router .. 10-deep-research)

docker-compose.yml    Full stack: backend + frontend + PostgreSQL (pgvector) + Redis

Quickstart

Prerequisites

  • Docker & Docker Compose
  • MWS GPT API key

Run with Docker (recommended)

cp .env.example .env
# Edit .env — set MWS_GPT_API_KEY=sk-your-key

docker compose up --build

Database migrations and the default user are applied automatically by the backend container's entrypoint — no manual alembic step needed.

For a step-by-step guide (incl. Russian version, troubleshooting, and feature walk-through) see QUICKSTART.md.

Local Development (backend)

cd backend

# Create venv & install
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# Start PostgreSQL + Redis (via docker-compose or locally)
docker-compose up postgres redis -d

# Run migrations
alembic upgrade head

# Start server
python main.py

Local Development (frontend)

The frontend is an OpenWebUI fork. See frontend-overrides/INTEGRATION.md for how to wire it to our backend.

Tech Stack

Layer Stack
Backend Python 3.12, FastAPI, SQLAlchemy 2.0, asyncpg, pgvector, httpx, Alembic
ML Jinja2, tiktoken, regex-based + LLM classifier routing
Frontend Svelte (OpenWebUI), TailwindCSS
Database PostgreSQL 16 + pgvector
Cache Redis 7
Infra Docker, docker-compose

API Endpoints

Endpoint Method Purpose
/api/chat/completions POST Chat with SSE streaming
/api/chats GET/POST List / create conversations
/api/chats/{id} GET/PUT/DELETE Conversation CRUD
/api/audio/transcribe POST Voice recording ASR
/api/audio/upload POST Audio file ASR
/api/images/generate POST Image generation
/api/files/upload POST File upload + RAG indexing
/api/files GET List uploaded files
/api/web/search POST Web search
/api/web/parse POST URL content parsing
/api/memory GET/POST List / create memories
/api/memory/{id} PUT/DELETE Memory CRUD
/api/models GET Available models by category

Architecture

Frontend (OpenWebUI)
    |
    | HTTP / SSE
    v
Backend (FastAPI)
    |
    +-- Model Router (ML) --> selects model + builds prompt
    +-- Memory Service -----> pgvector similarity search
    +-- File Service -------> text extraction + RAG embedding
    +-- Web Service --------> search + URL parsing
    |
    v
MWS GPT API (api.gpt.mws.ru/v1/)
    - /chat/completions   (text, VLM)
    - /embeddings         (bge-m3)
    - /images/generations
    - /audio/transcriptions

Branch Ownership

Directory Owner Scope
backend/ Backend engineer API, DB, services, Docker
ml/ ML engineer Routing, prompts, context, pipelines
frontend/ Frontend engineer OpenWebUI modifications

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 36.9%
  • Svelte 30.3%
  • JavaScript 23.6%
  • TypeScript 4.7%
  • CSS 2.4%
  • HTML 1.4%
  • Other 0.7%