Spaces:
Running
Running
Commit Β·
ad99445
1
Parent(s): 93ad15b
Fix PEFT and update README
Browse files- README.md +82 -73
- requirements.txt +1 -2
README.md
CHANGED
|
@@ -1,113 +1,122 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
colorTo:
|
|
|
|
| 6 |
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
---
|
| 9 |
-
# KORA API Backend (FastAPI + Transformers)
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
## Features
|
| 14 |
|
| 15 |
-
|
| 16 |
-
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
```text
|
| 26 |
-
|
| 27 |
-
βββ
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
β βββ services/
|
| 31 |
-
β β βββ model_service.py
|
| 32 |
-
β β βββ prompt_service.py
|
| 33 |
-
β βββ utils/
|
| 34 |
-
β βββ config.py
|
| 35 |
βββ prompts/
|
| 36 |
-
β βββ system_prompt.txt
|
| 37 |
βββ knowledge/
|
| 38 |
-
β βββ kontyra.md
|
| 39 |
-
βββ Dockerfile
|
| 40 |
βββ main.py
|
| 41 |
-
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
## Environment Variables
|
| 45 |
|
| 46 |
-
Create `.env` in `apps/api/` (optional):
|
| 47 |
-
|
| 48 |
```bash
|
| 49 |
-
APP_NAME="KORA AI
|
| 50 |
APP_ENV="production"
|
| 51 |
LOG_LEVEL="INFO"
|
|
|
|
| 52 |
MODEL_NAME="microsoft/Phi-3-mini-4k-instruct"
|
| 53 |
-
|
| 54 |
-
LOW_CPU_MEM_USAGE=true
|
| 55 |
-
MAX_INPUT_TOKENS=3072
|
| 56 |
-
TORCH_NUM_THREADS=0
|
| 57 |
-
TORCH_NUM_INTEROP_THREADS=0
|
| 58 |
DEFAULT_TEMPERATURE=0.7
|
| 59 |
DEFAULT_TOP_P=0.9
|
| 60 |
DEFAULT_MAX_TOKENS=512
|
| 61 |
-
```
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
python -m venv .venv
|
| 68 |
-
source .venv/bin/activate
|
| 69 |
-
pip install -r requirements.txt
|
| 70 |
-
uvicorn main:app --host 0.0.0.0 --port 8000
|
| 71 |
```
|
| 72 |
|
| 73 |
-
##
|
| 74 |
-
|
| 75 |
-
```bash
|
| 76 |
-
cd apps/api
|
| 77 |
-
docker build -t kora-api .
|
| 78 |
-
docker run --rm -p 7860:7860 \
|
| 79 |
-
-e PORT=7860 \
|
| 80 |
-
-e MODEL_NAME=microsoft/Phi-3-mini-4k-instruct \
|
| 81 |
-
kora-api
|
| 82 |
-
```
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
```bash
|
| 89 |
uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}
|
| 90 |
```
|
| 91 |
|
| 92 |
-
##
|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
]
|
| 103 |
-
}
|
| 104 |
-
```
|
| 105 |
|
| 106 |
-
##
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
```
|
| 112 |
|
| 113 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
title: KORA AI
|
| 4 |
+
emoji: π
|
| 5 |
+
colorTo: blue
|
| 6 |
+
short_description: KORA is the intelligent AI assistant for the Kontyra ecosyst
|
| 7 |
sdk: docker
|
|
|
|
| 8 |
---
|
|
|
|
| 9 |
|
| 10 |
+
# KORA AI
|
| 11 |
+
|
| 12 |
+
KORA is the intelligent AI assistant for the Kontyra ecosystem.
|
| 13 |
+
|
| 14 |
+
This Space hosts the KORA application and related AI services.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
## Overview
|
| 18 |
+
|
| 19 |
+
This repository contains the backend infrastructure for KORA, built with FastAPI, Transformers, and Docker. The API is designed to be compatible with OpenAI-style chat completion endpoints while supporting custom system prompts, knowledge-base integration, and streaming responses.
|
| 20 |
|
| 21 |
## Features
|
| 22 |
|
| 23 |
+
* OpenAI-compatible API endpoint
|
| 24 |
+
* FastAPI-based architecture
|
| 25 |
+
* Streaming responses via Server-Sent Events (SSE)
|
| 26 |
+
* Docker-ready deployment
|
| 27 |
+
* Environment-based configuration
|
| 28 |
+
* Custom KORA system prompt injection
|
| 29 |
+
* Knowledge-base context integration
|
| 30 |
+
* Scalable backend foundation for future Kontyra products
|
| 31 |
+
|
| 32 |
+
## Technology Stack
|
| 33 |
+
|
| 34 |
+
* Python
|
| 35 |
+
* FastAPI
|
| 36 |
+
* Transformers
|
| 37 |
+
* PyTorch
|
| 38 |
+
* Docker
|
| 39 |
+
* Hugging Face
|
| 40 |
+
|
| 41 |
+
## API Endpoint
|
| 42 |
+
|
| 43 |
+
```http
|
| 44 |
+
POST /v1/chat/completions
|
| 45 |
+
```
|
| 46 |
|
| 47 |
+
### Example Request
|
| 48 |
+
|
| 49 |
+
```json
|
| 50 |
+
{
|
| 51 |
+
"model": "KORA",
|
| 52 |
+
"stream": true,
|
| 53 |
+
"messages": [
|
| 54 |
+
{
|
| 55 |
+
"role": "user",
|
| 56 |
+
"content": "Who created KORA?"
|
| 57 |
+
}
|
| 58 |
+
]
|
| 59 |
+
}
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Project Structure
|
| 63 |
|
| 64 |
```text
|
| 65 |
+
app/
|
| 66 |
+
βββ routes/
|
| 67 |
+
βββ services/
|
| 68 |
+
βββ utils/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
βββ prompts/
|
|
|
|
| 70 |
βββ knowledge/
|
|
|
|
|
|
|
| 71 |
βββ main.py
|
| 72 |
+
βββ requirements.txt
|
| 73 |
+
βββ Dockerfile
|
| 74 |
```
|
| 75 |
|
| 76 |
## Environment Variables
|
| 77 |
|
|
|
|
|
|
|
| 78 |
```bash
|
| 79 |
+
APP_NAME="KORA AI"
|
| 80 |
APP_ENV="production"
|
| 81 |
LOG_LEVEL="INFO"
|
| 82 |
+
|
| 83 |
MODEL_NAME="microsoft/Phi-3-mini-4k-instruct"
|
| 84 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
DEFAULT_TEMPERATURE=0.7
|
| 86 |
DEFAULT_TOP_P=0.9
|
| 87 |
DEFAULT_MAX_TOKENS=512
|
|
|
|
| 88 |
|
| 89 |
+
MAX_INPUT_TOKENS=3072
|
| 90 |
|
| 91 |
+
TRUST_REMOTE_CODE=true
|
| 92 |
+
LOW_CPU_MEM_USAGE=true
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
```
|
| 94 |
|
| 95 |
+
## Deployment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
This Space is configured as a Docker Space and automatically starts the KORA API service when deployed.
|
| 98 |
|
| 99 |
+
The application listens on the port provided by Hugging Face:
|
| 100 |
|
| 101 |
```bash
|
| 102 |
uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}
|
| 103 |
```
|
| 104 |
|
| 105 |
+
## Vision
|
| 106 |
|
| 107 |
+
KORA serves as the intelligence layer of the Kontyra ecosystem and is being developed to support future products including:
|
| 108 |
|
| 109 |
+
* DevOS
|
| 110 |
+
* VUX
|
| 111 |
+
* Kontyra Jobs
|
| 112 |
+
* Tech Visionaries Network (TVN)
|
| 113 |
+
* Kontyra Learn
|
| 114 |
+
* Kontyra Projects
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
## Author
|
| 117 |
|
| 118 |
+
**Heritage Oluwalonimi Oladoye**
|
| 119 |
+
|
| 120 |
+
Founder of Kontyra
|
|
|
|
| 121 |
|
| 122 |
+
Building technology that creates impact across Nigeria, Africa, and the world.
|
requirements.txt
CHANGED
|
@@ -9,5 +9,4 @@ torch==2.5.1+cpu
|
|
| 9 |
accelerate==1.2.1
|
| 10 |
sentencepiece==0.2.0
|
| 11 |
python-dotenv==1.0.1
|
| 12 |
-
peft=
|
| 13 |
-
|
|
|
|
| 9 |
accelerate==1.2.1
|
| 10 |
sentencepiece==0.2.0
|
| 11 |
python-dotenv==1.0.1
|
| 12 |
+
peft>=0.12.0
|
|
|