Spaces:
Building
Building
Commit
Β·
35d830a
1
Parent(s):
f33e2be
π Initial Commit: Rebuilt Quantum-API with FastAPI + Streamlit + HuggingFace Space Support
Browse files
README.md
CHANGED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Quantum-API
|
3 |
+
emoji: π
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: docker
|
7 |
+
python_version: 3.11
|
8 |
+
sdk_version: latest
|
9 |
+
suggested_hardware: cpu-basic
|
10 |
+
suggested_storage: small
|
11 |
+
app_file: app.py
|
12 |
+
app_port: 7860
|
13 |
+
base_path: /
|
14 |
+
fullWidth: true
|
15 |
+
header: default
|
16 |
+
short_description: Quantum-AI API for machine learning and quantum computing.
|
17 |
+
models:
|
18 |
+
- openai-community/gpt2
|
19 |
+
datasets:
|
20 |
+
- mozilla-foundation/common_voice_13_0
|
21 |
+
tags:
|
22 |
+
- quantum-ai
|
23 |
+
- machine-learning
|
24 |
+
- fastapi
|
25 |
+
- streamlit
|
26 |
+
- huggingface-spaces
|
27 |
+
- docker
|
28 |
+
thumbnail: >-
|
29 |
+
https://cdn-uploads.huggingface.co/production/uploads/66ee940c0989ae1ac1383839/MseLCVmNge3tBJzqDbN1c.jpeg
|
30 |
+
pinned: true
|
31 |
+
hf_oauth: false
|
32 |
+
disable_embedding: false
|
33 |
+
startup_duration_timeout: 30m
|
34 |
+
custom_headers:
|
35 |
+
cross-origin-embedder-policy: require-corp
|
36 |
+
cross-origin-opener-policy: same-origin
|
37 |
+
cross-origin-resource-policy: cross-origin
|
38 |
+
preload_from_hub:
|
39 |
+
- openai-community/gpt2 config.json
|
40 |
+
license: mit
|
41 |
+
---
|
42 |
+
|
43 |
+
# π Quantum-API
|
44 |
+
|
45 |
+
## π¬ Overview
|
46 |
+
|
47 |
+
**Quantum-API** is a hybrid **FastAPI** + **Streamlit** web application that serves as a unified interface for quantum computing tasks. It integrates **PennyLane**, **PyTorch**, and **OpenAI models** via Hugging Face. Optimized for resource-constrained systems and cloud deployments such as Hugging Face Spaces.
|
48 |
+
|
49 |
+
> βοΈ Quantum-AI API for machine learning and quantum computing, powered by FastAPI, Streamlit, and PennyLane.
|
50 |
+
|
51 |
+
---
|
52 |
+
|
53 |
+
## β‘ Features
|
54 |
+
|
55 |
+
- π **FastAPI Backend**: RESTful endpoints for quantum ML processing.
|
56 |
+
- π§ **Streamlit Frontend**: Interactive quantum interface on `port 7861`.
|
57 |
+
- π§ͺ **Quantum Computation**: Process quantum logic with PennyLane.
|
58 |
+
- π¦ **Docker & HuggingFace Compatible**: Pre-configured for Spaces deployment.
|
59 |
+
- π‘οΈ **Health Check**: System status endpoint.
|
60 |
+
- βοΈ **Hybrid Quantum-Classical AI**: Combines classical ML with quantum gates.
|
61 |
+
|
62 |
+
---
|
63 |
+
|
64 |
+
## π οΈ Installation
|
65 |
+
|
66 |
+
### 1. Clone the Repository
|
67 |
+
```bash
|
68 |
+
git clone https://github.com/subatomicERROR/Quantum-API.git
|
69 |
+
cd Quantum-API
|
70 |
+
|
71 |
+
2. Create a Virtual Environment (Recommended)
|
72 |
+
|
73 |
+
python3 -m venv qvenv
|
74 |
+
source qvenv/bin/activate # For Linux/macOS
|
75 |
+
# OR
|
76 |
+
qvenv\Scripts\activate # For Windows
|
77 |
+
|
78 |
+
3. Install Requirements
|
79 |
+
|
80 |
+
pip install -r requirements.txt
|
81 |
+
|
82 |
+
π Running the App Locally
|
83 |
+
1. Start the Backend (FastAPI)
|
84 |
+
|
85 |
+
uvicorn api.endpoints.codelama:app --host 0.0.0.0 --port 7860 --reload
|
86 |
+
|
87 |
+
Accessible at: http://localhost:7860
|
88 |
+
2. Start the Frontend (Streamlit)
|
89 |
+
|
90 |
+
streamlit run app/app.py --server.port 7861
|
91 |
+
|
92 |
+
Accessible at: http://localhost:7861
|
93 |
+
π API Endpoints
|
94 |
+
π Root
|
95 |
+
|
96 |
+
GET /
|
97 |
+
|
98 |
+
Returns an SEO-optimized HTML homepage.
|
99 |
+
|
100 |
+
βοΈ Quantum Endpoint
|
101 |
+
|
102 |
+
POST /quantum-endpoint
|
103 |
+
|
104 |
+
Request Body:
|
105 |
+
|
106 |
+
{
|
107 |
+
"data": "your_data_here",
|
108 |
+
"quantum_factor": 1.0
|
109 |
+
}
|
110 |
+
|
111 |
+
Response:
|
112 |
+
|
113 |
+
{
|
114 |
+
"status": "success",
|
115 |
+
"quantum_result": "Processed your_data_here with quantum factor 1.0"
|
116 |
+
}
|
117 |
+
|
118 |
+
β€οΈ Health Check
|
119 |
+
|
120 |
+
GET /health
|
121 |
+
|
122 |
+
Returns API status.
|
123 |
+
π Streamlit Frontend
|
124 |
+
|
125 |
+
An interactive interface to interact with the quantum backend.
|
126 |
+
|
127 |
+
streamlit run app/app.py --server.port 7861
|
128 |
+
|
129 |
+
URL: http://localhost:7861
|
130 |
+
π¦ Deployment: Hugging Face Spaces
|
131 |
+
|
132 |
+
To deploy on Hugging Face:
|
133 |
+
|
134 |
+
Ensure the following in your repo:
|
135 |
+
|
136 |
+
requirements.txt
|
137 |
+
|
138 |
+
app/app.py (Streamlit entrypoint)
|
139 |
+
|
140 |
+
api/endpoints/codelama.py (FastAPI backend)
|
141 |
+
|
142 |
+
Use a Docker-based Space with this command in Dockerfile or runtime:
|
143 |
+
|
144 |
+
uvicorn api.endpoints.codelama:app --host 0.0.0.0 --port 7860 & \
|
145 |
+
streamlit run app/app.py --server.port 7861
|
146 |
+
|
147 |
+
Push your repo to Hugging Face:
|
148 |
+
|
149 |
+
git remote add hf https://huggingface.co/spaces/subatomicERROR/Quantum-API
|
150 |
+
git push hf main
|
151 |
+
|
152 |
+
π File Structure
|
153 |
+
|
154 |
+
Quantum-API/
|
155 |
+
βββ api/
|
156 |
+
β βββ endpoints/
|
157 |
+
β βββ codelama.py # FastAPI main app
|
158 |
+
βββ app/
|
159 |
+
β βββ app.py # Streamlit UI
|
160 |
+
βββ requirements.txt
|
161 |
+
βββ README.md
|
162 |
+
βββ .huggingface/README.md # Optional Space ReadMe
|
163 |
+
|
164 |
+
π§ Author
|
165 |
+
|
166 |
+
Built with β + βοΈ by subatomicERROR (Yash R)
|
167 |
+
Email: [email protected]
|
168 |
+
𧬠Branding & Philosophy
|
169 |
+
|
170 |
+
Part of the .ERROR brand β combining ancient wisdom, futuristic design, and quantum intelligence.
|
171 |
+
|
172 |
+
This system is part of the Quantum-AI Stack including:
|
173 |
+
|
174 |
+
Quantum-ML β Model & training backend.
|
175 |
+
|
176 |
+
Quantum-API β This API gateway.
|
177 |
+
|
178 |
+
Quantum-Compute β Quantum computation engine.
|
179 |
+
|
180 |
+
π License
|
181 |
+
|
182 |
+
MIT License
|
183 |
+
|
184 |
+
πͺ Exploring the quantum realm with AI...
|
185 |
+
...one entangled bit at a time.
|