Spaces:
Sleeping
Sleeping
Commit Β·
8fcd54a
1
Parent(s): 5eebd59
checking changes
Browse files
README.md
CHANGED
|
@@ -1,95 +1,79 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
- **RAG Chatbot** - Repository-aware Q&A using retrieval-augmented generation
|
| 9 |
-
- **Mentor Matching** - Tech stack-based mentor recommendations
|
| 10 |
-
- **Hype Generator** - Celebration messages for PRs
|
| 11 |
-
- **AI Chat** - General assistance for contributors
|
| 12 |
|
| 13 |
-
##
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
| `/chat` | POST | AI chat assistant |
|
| 20 |
-
| `/rag/chat` | POST | RAG-based Q&A |
|
| 21 |
-
| `/rag/index` | POST | Index repository for RAG |
|
| 22 |
-
| `/rag/suggestions` | GET | Suggested questions |
|
| 23 |
-
| `/mentor-match` | POST | Find mentor matches |
|
| 24 |
-
| `/hype` | POST | Generate PR celebration |
|
| 25 |
-
| `/rag/prepare` | POST | Prepare RAG documents |
|
| 26 |
-
| `/rag/chunks` | GET | Get chunks for embedding |
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
##
|
| 31 |
|
| 32 |
-
|
| 33 |
-
# Create virtual environment
|
| 34 |
-
python -m venv venv
|
| 35 |
-
source venv/bin/activate
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
``
|
|
|
|
| 46 |
|
| 47 |
-
### Docker
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
```bash
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
- `MONGO_URL` (optional, for DB features)
|
| 60 |
-
3. Push this folder to the Space
|
| 61 |
-
|
| 62 |
-
The Dockerfile is pre-configured for HF Spaces (non-root user, port 7860).
|
| 63 |
-
|
| 64 |
-
## Environment Variables
|
| 65 |
-
|
| 66 |
-
| Variable | Required | Description |
|
| 67 |
-
|----------|----------|-------------|
|
| 68 |
-
| `OPENROUTER_API_KEY` | Yes | OpenRouter API key |
|
| 69 |
-
| `MONGO_URL` | No | MongoDB connection string |
|
| 70 |
-
| `FRONTEND_URL` | No | Frontend URL for CORS |
|
| 71 |
-
| `CORS_ORIGINS` | No | Comma-separated CORS origins |
|
| 72 |
-
| `ENVIRONMENT` | No | `development` or `production` |
|
| 73 |
-
|
| 74 |
-
## Architecture
|
| 75 |
-
|
| 76 |
-
```
|
| 77 |
-
ai-engine/
|
| 78 |
-
βββ main.py # FastAPI wrapper (new)
|
| 79 |
-
βββ Dockerfile # HF-compliant Docker config
|
| 80 |
-
βββ requirements.txt # Python dependencies
|
| 81 |
-
βββ config/
|
| 82 |
-
β βββ settings.py # Environment configuration
|
| 83 |
-
βββ models/ # Pydantic models (original)
|
| 84 |
-
βββ services/ # AI services (original, unchanged)
|
| 85 |
-
β βββ ai_service.py
|
| 86 |
-
β βββ rag_chatbot_service.py
|
| 87 |
-
β βββ mentor_matching_service.py
|
| 88 |
-
β βββ hype_generator_service.py
|
| 89 |
-
β βββ rag_data_prep.py
|
| 90 |
-
βββ utils/ # Utilities (original)
|
| 91 |
-
```
|
| 92 |
-
|
| 93 |
-
## License
|
| 94 |
-
|
| 95 |
-
MIT - See parent repository LICENSE file.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: OpenTriage AI Engine
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: pink
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
|
| 11 |
+
# π§ OpenTriage AI Engine (Microservice)
|
| 12 |
|
| 13 |
+
This is the **AI Brain** of the OpenTriage platform. It is a specialized Python microservice acting as a "Sidecar" to the main TypeScript backend.
|
| 14 |
|
| 15 |
+
It hosts the heavy-lifting AI logic, including RAG (Retrieval-Augmented Generation), Issue Triage, and Mentor Matching, keeping the main application fast and lightweight.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
## π Features
|
| 18 |
|
| 19 |
+
* **π AI Triage:** Automatically classifies GitHub issues by complexity and type.
|
| 20 |
+
* **π RAG Chatbot:** "Chat with Repo" functionality using vector search.
|
| 21 |
+
* **π€ Mentor Match:** Connects contributors to mentors based on tech stack analysis.
|
| 22 |
+
* **π Hype Generator:** Generates celebratory messages for PR merges.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
---
|
| 25 |
|
| 26 |
+
## π How to Connect
|
| 27 |
|
| 28 |
+
This service exposes a REST API via **FastAPI**. It is designed to be called by the Main Backend, not directly by users.
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
### Base URL
|
| 31 |
+
Your API is live at:
|
| 32 |
+
`https://[YOUR_USERNAME]-opentriage-ai-engine.hf.space`
|
| 33 |
+
|
| 34 |
+
*(Check the "Embed this space" menu in the top right to get your exact direct URL)*
|
| 35 |
+
|
| 36 |
+
### API Endpoints
|
| 37 |
+
|
| 38 |
+
| Method | Endpoint | Description |
|
| 39 |
+
| :--- | :--- | :--- |
|
| 40 |
+
| `GET` | `/health` | Server health check (returns 200 OK) |
|
| 41 |
+
| `POST` | `/triage` | Classifies an issue description |
|
| 42 |
+
| `POST` | `/chat` | General AI assistant response |
|
| 43 |
+
| `POST` | `/rag/chat` | Context-aware repository Q&A |
|
| 44 |
+
| `POST` | `/mentor-match` | Finds best matching mentors |
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## π Deployment Configuration
|
| 49 |
|
| 50 |
+
### 1. Environment Variables (Secrets)
|
| 51 |
+
You must set these in the **Settings** tab of this Space under "Variables and secrets":
|
| 52 |
|
| 53 |
+
| Secret Name | Required? | Description |
|
| 54 |
+
| :--- | :--- | :--- |
|
| 55 |
+
| `OPENROUTER_API_KEY` | **Yes** | Required for all AI generation |
|
| 56 |
+
| `MONGO_URL` | Optional | If your RAG needs persistent vector storage |
|
| 57 |
|
| 58 |
+
### 2. Docker Configuration
|
| 59 |
+
This Space uses a custom Dockerfile to ensure all Python scientific libraries (NumPy, Scikit-learn, LangChain) are installed in a compatible environment.
|
| 60 |
+
|
| 61 |
+
* **Port:** 7860 (Standard HF Space port)
|
| 62 |
+
* **User:** Runs as non-root user `user` (ID 1000) for security.
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
## π» Local Development
|
| 67 |
+
|
| 68 |
+
If you want to run this brain locally:
|
| 69 |
|
| 70 |
```bash
|
| 71 |
+
# 1. Create venv
|
| 72 |
+
python -m venv venv
|
| 73 |
+
source venv/bin/activate
|
| 74 |
+
|
| 75 |
+
# 2. Install
|
| 76 |
+
pip install -r requirements.txt
|
| 77 |
+
|
| 78 |
+
# 3. Run
|
| 79 |
+
uvicorn main:app --reload --port 8000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|