ProfessorCEO commited on
Commit
ad99445
Β·
1 Parent(s): 93ad15b

Fix PEFT and update README

Browse files
Files changed (2) hide show
  1. README.md +82 -73
  2. requirements.txt +1 -2
README.md CHANGED
@@ -1,113 +1,122 @@
1
  ---
2
- title: Kora API
3
- emoji: πŸš€
4
- colorFrom: blue
5
- colorTo: purple
 
6
  sdk: docker
7
- pinned: false
8
  ---
9
- # KORA API Backend (FastAPI + Transformers)
10
 
11
- Production-ready AI backend scaffold for KORA, optimized for Docker and Hugging Face Docker Spaces.
 
 
 
 
 
 
 
 
 
12
 
13
  ## Features
14
 
15
- - OpenAI-compatible endpoint: `POST /v1/chat/completions`
16
- - Streaming token responses using SSE
17
- - CPU-safe Transformers + PyTorch runtime with `microsoft/Phi-3-mini-4k-instruct`
18
- - Automatic KORA system-prompt injection on every request
19
- - KONTYRA knowledge-base context injection
20
- - Async architecture with centralized logging
21
- - Environment-driven configuration
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- ## Folder Structure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ```text
26
- apps/api/
27
- β”œβ”€β”€ app/
28
- β”‚ β”œβ”€β”€ routes/
29
- β”‚ β”‚ └── chat.py
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
- └── requirements.txt
 
42
  ```
43
 
44
  ## Environment Variables
45
 
46
- Create `.env` in `apps/api/` (optional):
47
-
48
  ```bash
49
- APP_NAME="KORA AI Backend"
50
  APP_ENV="production"
51
  LOG_LEVEL="INFO"
 
52
  MODEL_NAME="microsoft/Phi-3-mini-4k-instruct"
53
- TRUST_REMOTE_CODE=true
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
- ## Local Setup
64
 
65
- ```bash
66
- cd apps/api
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
- ## Docker Build + Run
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
- ## Hugging Face Docker Spaces Startup
85
 
86
- Use the included `Dockerfile`. Hugging Face sets `PORT`, and the container starts with:
87
 
88
  ```bash
89
  uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}
90
  ```
91
 
92
- ## API Example
93
 
94
- ### Request
95
 
96
- ```json
97
- {
98
- "model": "microsoft/Phi-3-mini-4k-instruct",
99
- "stream": true,
100
- "messages": [
101
- {"role": "user", "content": "Who created KORA?"}
102
- ]
103
- }
104
- ```
105
 
106
- ### Endpoint
107
 
108
- ```http
109
- POST /v1/chat/completions
110
- Content-Type: application/json
111
- ```
112
 
113
- Streaming responses are returned as SSE `data:` events compatible with OpenAI-style chunk consumption.
 
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==0.11.1
13
-
 
9
  accelerate==1.2.1
10
  sentencepiece==0.2.0
11
  python-dotenv==1.0.1
12
+ peft>=0.12.0