DemoSpace / README.md
Fafnirk's picture
Update README
03dbec2
|
Raw
History Blame Contribute Delete
3.57 kB
metadata
title: Coding Assistant
emoji: πŸ’»
colorFrom: blue
colorTo: indigo
sdk: docker
app_file: app.py
pinned: false

Qwen Coder β€” Cloud-Native Personal Coding Assistant

A project-aware coding companion powered by Qwen2.5-Coder-1.5B optimized for cloud deployment on Railway.

This assistant provides high-quality coding intelligence within a constrained 2GB RAM environment using llama-cpp-python and GGUF quantization.


✨ Features

  • Cloud-Ready LLM β€” Optimized Qwen 1.5B model running on CPU-only instances.
  • Persistent Storage β€” Integrated with Railway Volumes for project files and model storage.
  • Project-based Context β€” Automatically injects your uploaded project files into the AI's context.
  • Streaming Output β€” Real-time, token-by-token response streaming.
  • Web Search β€” Integrated DuckDuckGo API for quick information lookup.
  • File Uploads β€” Upload project files directly via the web UI.
  • Persistent Chat Memory β€” Remembers previous interactions per project using SQLite.
  • Memory Efficient β€” Uses Flash Attention and 4-bit quantization to fit coding intelligence into 2GB RAM.

πŸ“‚ Project Structure

. β”œβ”€β”€ backend/ β”‚ └── app.py # Flask backend with Ollama integration β”œβ”€β”€ static/ β”‚ β”œβ”€β”€ styles.css # Dark mode styling β”‚ └── script.js # Frontend interactivity & streaming β”œβ”€β”€ templates/ β”‚ └── index.html # Web interface β”œβ”€β”€ projects/ # Your saved coding projects β”œβ”€β”€ memory.db # SQLite chat history database └── README.md


πŸ”’ Security & Authentication

This project incorporates robust security controls tailored for public cloud deployments:

  1. Authentication: Secure Google OAuth 2.0 / OIDC login supporting public multi-user access via JSON Web Token (JWT) verification.

  2. Rate Limiting: Custom IP-based rate tracking returns HTTP 429 (Too Many Requests) status codes if thresholds are exceeded.


Deployment (Railway)

  1. Mount Volumes: Create a volume and mount it to /app/data and /app/models.

  2. Environment Variables:

    • API_KEY: Your secret key for API verification.
    • PORT: 8080
    • PYTHONUNBUFFERED: 1
  3. Start command:

    gunicorn --workers 1 --timeout 300 --bind 0.0.0.0:8080 backend.app:app
    

Deployment (Hugging Face Spaces)

  1. Environment Variables / Secrets: Add the following secret keys in your Space settings:
    • GOOGLE_CLIENT_ID: Your Google OAuth Client ID.
    • TAVILY_API_KEY: Your Tavily search API key.

Privacy

This assistant runs on your private Railway instance. No data is sent to OpenAI, Anthropic, or any other third-party LLM providers.

🧩 Technology Stack

Backend

Python 3.9+ β€” Core backend language.

Flask β€” Lightweight web framework for handling API routes and serving the web UI.

SQLite β€” Embedded database for persistent per-project chat history.

Ollama β€” Local LLM runner for Qwen v3 30B.

Qwen v3 30B β€” Large Language Model specialized for coding and reasoning.

Requests β€” HTTP client for DuckDuckGo search API.

Frontend

HTML5 β€” Web interface structure.

CSS3 β€” Custom dark mode styling.

JavaScript (ES6+) β€” Client-side logic for chat interaction & streaming.

Fetch API β€” Asynchronous communication with the backend.

Marked.js β€” Client-side Markdown rendering for assistant messages.

Highlight.js β€” Syntax highlighting for code blocks.

πŸ”’ Privacy

Everything runs entirely locally. No data is sent to external services except optional DuckDuckGo search queries.