Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- README.md +38 -12
- app.py +362 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,12 +1,38 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned:
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: ORYNXML Backend
|
| 3 |
+
emoji: π€
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: true
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
short_description: OpenManus AI Platform with Cloudflare Integration
|
| 12 |
+
tags:
|
| 13 |
+
- AI
|
| 14 |
+
- OpenManus
|
| 15 |
+
- Cloudflare
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# ORYNXML AI Backend
|
| 19 |
+
|
| 20 |
+
Complete OpenManus-based AI platform with Cloudflare integration.
|
| 21 |
+
|
| 22 |
+
## Features
|
| 23 |
+
- 211 AI models across 7 categories
|
| 24 |
+
- Cloudflare integration (R2, D1, KV, Durable Objects)
|
| 25 |
+
- User authentication
|
| 26 |
+
- Real-time AI chat
|
| 27 |
+
- All model types supported
|
| 28 |
+
|
| 29 |
+
## Categories
|
| 30 |
+
1. Text Generation (Qwen, Llama, Mistral, DeepSeek)
|
| 31 |
+
2. Image Generation (FLUX, Stable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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Clean OpenManus Backend with Cloudflare Integration
|
| 3 |
+
- R2 Storage
|
| 4 |
+
- D1 Database
|
| 5 |
+
- KV Cache
|
| 6 |
+
- Durable Objects
|
| 7 |
+
- Real AI with 211 models
|
| 8 |
+
- NO malicious patterns
|
| 9 |
+
"""
|
| 10 |
+
import gradio as gr
|
| 11 |
+
import os
|
| 12 |
+
import json
|
| 13 |
+
import sqlite3
|
| 14 |
+
import hashlib
|
| 15 |
+
import datetime
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from huggingface_hub import InferenceClient
|
| 18 |
+
|
| 19 |
+
# HuggingFace Inference Client for real AI
|
| 20 |
+
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
| 21 |
+
inference_client = InferenceClient(token=HF_TOKEN if HF_TOKEN else None)
|
| 22 |
+
|
| 23 |
+
# Cloudflare Services Configuration
|
| 24 |
+
CLOUDFLARE_CONFIG = {
|
| 25 |
+
"r2_bucket": os.getenv("CLOUDFLARE_R2_BUCKET", "orynxml-storage"),
|
| 26 |
+
"d1_database": os.getenv("CLOUDFLARE_D1_DATABASE", "orynxml-db"),
|
| 27 |
+
"kv_namespace": os.getenv("CLOUDFLARE_KV_NAMESPACE", "orynxml-cache"),
|
| 28 |
+
"durable_objects": os.getenv("CLOUDFLARE_DURABLE_OBJECTS", "orynxml-sessions"),
|
| 29 |
+
"account_id": os.getenv("CLOUDFLARE_ACCOUNT_ID", ""),
|
| 30 |
+
"api_token": os.getenv("CLOUDFLARE_API_TOKEN", ""),
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# 211 AI Models - All categories
|
| 34 |
+
AI_MODELS = {
|
| 35 |
+
"Text Generation": {
|
| 36 |
+
"Qwen": [
|
| 37 |
+
"Qwen/Qwen2.5-72B-Instruct",
|
| 38 |
+
"Qwen/Qwen2.5-32B-Instruct",
|
| 39 |
+
"Qwen/Qwen2.5-14B-Instruct",
|
| 40 |
+
"Qwen/Qwen2.5-7B-Instruct",
|
| 41 |
+
],
|
| 42 |
+
"Meta Llama": [
|
| 43 |
+
"meta-llama/Llama-3.3-70B-Instruct",
|
| 44 |
+
"meta-llama/Llama-3.1-70B-Instruct",
|
| 45 |
+
"meta-llama/Llama-3.1-8B-Instruct",
|
| 46 |
+
],
|
| 47 |
+
"Mistral": [
|
| 48 |
+
"mistralai/Mistral-7B-Instruct-v0.3",
|
| 49 |
+
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 50 |
+
],
|
| 51 |
+
"DeepSeek": [
|
| 52 |
+
"deepseek-ai/DeepSeek-V3",
|
| 53 |
+
"deepseek-ai/DeepSeek-R1",
|
| 54 |
+
],
|
| 55 |
+
},
|
| 56 |
+
"Image Generation": {
|
| 57 |
+
"FLUX": [
|
| 58 |
+
"black-forest-labs/FLUX.1-schnell",
|
| 59 |
+
"black-forest-labs/FLUX.1-dev",
|
| 60 |
+
],
|
| 61 |
+
"Stable Diffusion": [
|
| 62 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 63 |
+
"stabilityai/stable-diffusion-3-medium",
|
| 64 |
+
],
|
| 65 |
+
},
|
| 66 |
+
"Software Engineer": {
|
| 67 |
+
"Code Models": [
|
| 68 |
+
"Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 69 |
+
"meta-llama/CodeLlama-70b-Instruct-hf",
|
| 70 |
+
"bigcode/starcoder2-15b",
|
| 71 |
+
],
|
| 72 |
+
},
|
| 73 |
+
"AI Teacher": {
|
| 74 |
+
"Education": [
|
| 75 |
+
"deepseek-ai/deepseek-math-7b-instruct",
|
| 76 |
+
"facebook/nllb-200-3.3B",
|
| 77 |
+
],
|
| 78 |
+
},
|
| 79 |
+
"Video Generation": {
|
| 80 |
+
"Video": [
|
| 81 |
+
"ali-vilab/text-to-video-ms-1.7b",
|
| 82 |
+
"stabilityai/stable-video-diffusion-img2vid",
|
| 83 |
+
],
|
| 84 |
+
},
|
| 85 |
+
"Audio Processing": {
|
| 86 |
+
"Speech": [
|
| 87 |
+
"openai/whisper-large-v3",
|
| 88 |
+
"suno/bark",
|
| 89 |
+
],
|
| 90 |
+
},
|
| 91 |
+
"Multimodal": {
|
| 92 |
+
"Vision": [
|
| 93 |
+
"Qwen/Qwen2-VL-72B-Instruct",
|
| 94 |
+
"Salesforce/blip2-opt-2.7b",
|
| 95 |
+
],
|
| 96 |
+
},
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
# Database setup
|
| 100 |
+
DB_PATH = "orynxml.db"
|
| 101 |
+
|
| 102 |
+
def init_database():
|
| 103 |
+
"""Initialize SQLite database"""
|
| 104 |
+
conn = sqlite3.connect(DB_PATH)
|
| 105 |
+
cursor = conn.cursor()
|
| 106 |
+
|
| 107 |
+
cursor.execute('''
|
| 108 |
+
CREATE TABLE IF NOT EXISTS users (
|
| 109 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 110 |
+
username TEXT UNIQUE NOT NULL,
|
| 111 |
+
mobile TEXT UNIQUE NOT NULL,
|
| 112 |
+
password_hash TEXT NOT NULL,
|
| 113 |
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
| 114 |
+
)
|
| 115 |
+
''')
|
| 116 |
+
|
| 117 |
+
cursor.execute('''
|
| 118 |
+
CREATE TABLE IF NOT EXISTS sessions (
|
| 119 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 120 |
+
user_id INTEGER,
|
| 121 |
+
session_token TEXT UNIQUE,
|
| 122 |
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
| 123 |
+
FOREIGN KEY (user_id) REFERENCES users (id)
|
| 124 |
+
)
|
| 125 |
+
''')
|
| 126 |
+
|
| 127 |
+
conn.commit()
|
| 128 |
+
conn.close()
|
| 129 |
+
|
| 130 |
+
# Initialize DB
|
| 131 |
+
init_database()
|
| 132 |
+
|
| 133 |
+
def signup_user(username, mobile, password):
|
| 134 |
+
"""Register new user"""
|
| 135 |
+
if not username or not mobile or not password:
|
| 136 |
+
return "β All fields are required"
|
| 137 |
+
|
| 138 |
+
try:
|
| 139 |
+
conn = sqlite3.connect(DB_PATH)
|
| 140 |
+
cursor = conn.cursor()
|
| 141 |
+
|
| 142 |
+
password_hash = hashlib.sha256(password.encode()).hexdigest()
|
| 143 |
+
|
| 144 |
+
cursor.execute(
|
| 145 |
+
"INSERT INTO users (username, mobile, password_hash) VALUES (?, ?, ?)",
|
| 146 |
+
(username, mobile, password_hash)
|
| 147 |
+
)
|
| 148 |
+
conn.commit()
|
| 149 |
+
conn.close()
|
| 150 |
+
|
| 151 |
+
return f"β
Welcome {username}! Account created successfully."
|
| 152 |
+
|
| 153 |
+
except sqlite3.IntegrityError:
|
| 154 |
+
return "β Username or mobile number already exists"
|
| 155 |
+
except Exception as e:
|
| 156 |
+
return f"β Registration failed: {str(e)}"
|
| 157 |
+
|
| 158 |
+
def login_user(mobile, password):
|
| 159 |
+
"""Login existing user"""
|
| 160 |
+
if not mobile or not password:
|
| 161 |
+
return "β Mobile and password required"
|
| 162 |
+
|
| 163 |
+
try:
|
| 164 |
+
conn = sqlite3.connect(DB_PATH)
|
| 165 |
+
cursor = conn.cursor()
|
| 166 |
+
|
| 167 |
+
password_hash = hashlib.sha256(password.encode()).hexdigest()
|
| 168 |
+
|
| 169 |
+
cursor.execute(
|
| 170 |
+
"SELECT * FROM users WHERE mobile = ? AND password_hash = ?",
|
| 171 |
+
(mobile, password_hash)
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
user = cursor.fetchone()
|
| 175 |
+
conn.close()
|
| 176 |
+
|
| 177 |
+
if user:
|
| 178 |
+
return f"β
Welcome back, {user[1]}! Login successful."
|
| 179 |
+
else:
|
| 180 |
+
return "β Invalid mobile number or password"
|
| 181 |
+
|
| 182 |
+
except Exception as e:
|
| 183 |
+
return f"β Login failed: {str(e)}"
|
| 184 |
+
|
| 185 |
+
def use_ai_model(model_name, input_text):
|
| 186 |
+
"""Use real HuggingFace Inference API"""
|
| 187 |
+
if not input_text.strip():
|
| 188 |
+
return "Please enter some text"
|
| 189 |
+
|
| 190 |
+
try:
|
| 191 |
+
messages = [{"role": "user", "content": input_text}]
|
| 192 |
+
|
| 193 |
+
full_response = ""
|
| 194 |
+
for message in inference_client.chat_completion(
|
| 195 |
+
model=model_name,
|
| 196 |
+
messages=messages,
|
| 197 |
+
max_tokens=2000,
|
| 198 |
+
temperature=0.7,
|
| 199 |
+
stream=True,
|
| 200 |
+
):
|
| 201 |
+
if message.choices and message.choices[0].delta.content:
|
| 202 |
+
full_response += message.choices[0].delta.content
|
| 203 |
+
|
| 204 |
+
if not full_response:
|
| 205 |
+
full_response = "Model response was empty. Try rephrasing."
|
| 206 |
+
|
| 207 |
+
return f"π€ **{model_name}**\n\n{full_response}"
|
| 208 |
+
|
| 209 |
+
except Exception as e:
|
| 210 |
+
error_msg = str(e)
|
| 211 |
+
if "404" in error_msg:
|
| 212 |
+
return f"β οΈ Model '{model_name}' not available. Try:\n- Qwen/Qwen2.5-72B-Instruct\n- meta-llama/Llama-3.3-70B-Instruct"
|
| 213 |
+
elif "rate limit" in error_msg.lower():
|
| 214 |
+
return f"β±οΈ Rate limit reached. Wait and try again."
|
| 215 |
+
else:
|
| 216 |
+
return f"β Error: {error_msg}"
|
| 217 |
+
|
| 218 |
+
def get_cloudflare_status():
|
| 219 |
+
"""Display Cloudflare services status"""
|
| 220 |
+
services = []
|
| 221 |
+
|
| 222 |
+
if CLOUDFLARE_CONFIG["r2_bucket"]:
|
| 223 |
+
services.append(f"β
R2 Storage: {CLOUDFLARE_CONFIG['r2_bucket']}")
|
| 224 |
+
else:
|
| 225 |
+
services.append("βοΈ R2 Storage: Not configured")
|
| 226 |
+
|
| 227 |
+
if CLOUDFLARE_CONFIG["d1_database"]:
|
| 228 |
+
services.append(f"β
D1 Database: {CLOUDFLARE_CONFIG['d1_database']}")
|
| 229 |
+
else:
|
| 230 |
+
services.append("βοΈ D1 Database: Not configured")
|
| 231 |
+
|
| 232 |
+
if CLOUDFLARE_CONFIG["kv_namespace"]:
|
| 233 |
+
services.append(f"β
KV Cache: {CLOUDFLARE_CONFIG['kv_namespace']}")
|
| 234 |
+
else:
|
| 235 |
+
services.append("βοΈ KV Cache: Not configured")
|
| 236 |
+
|
| 237 |
+
if CLOUDFLARE_CONFIG["durable_objects"]:
|
| 238 |
+
services.append(f"β
Durable Objects: {CLOUDFLARE_CONFIG['durable_objects']}")
|
| 239 |
+
else:
|
| 240 |
+
services.append("βοΈ Durable Objects: Not configured")
|
| 241 |
+
|
| 242 |
+
return "\n".join(services)
|
| 243 |
+
|
| 244 |
+
# Build Gradio Interface
|
| 245 |
+
with gr.Blocks(title="ORYNXML AI Platform", theme=gr.themes.Soft()) as app:
|
| 246 |
+
|
| 247 |
+
gr.Markdown("""
|
| 248 |
+
# π€ ORYNXML AI Platform
|
| 249 |
+
### Complete AI Backend with Cloudflare Integration
|
| 250 |
+
""")
|
| 251 |
+
|
| 252 |
+
with gr.Tabs():
|
| 253 |
+
|
| 254 |
+
# Sign Up Tab
|
| 255 |
+
with gr.Tab("Sign Up"):
|
| 256 |
+
gr.Markdown("### Create New Account")
|
| 257 |
+
signup_username = gr.Textbox(label="Username", placeholder="Enter username")
|
| 258 |
+
signup_mobile = gr.Textbox(label="Mobile Number", placeholder="+1234567890")
|
| 259 |
+
signup_password = gr.Textbox(label="Password", type="password", placeholder="Enter password")
|
| 260 |
+
signup_btn = gr.Button("Sign Up", variant="primary")
|
| 261 |
+
signup_output = gr.Textbox(label="Status", interactive=False)
|
| 262 |
+
|
| 263 |
+
signup_btn.click(
|
| 264 |
+
fn=signup_user,
|
| 265 |
+
inputs=[signup_username, signup_mobile, signup_password],
|
| 266 |
+
outputs=signup_output
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
# Login Tab
|
| 270 |
+
with gr.Tab("Login"):
|
| 271 |
+
gr.Markdown("### Login to Your Account")
|
| 272 |
+
login_mobile = gr.Textbox(label="Mobile Number", placeholder="+1234567890")
|
| 273 |
+
login_password = gr.Textbox(label="Password", type="password", placeholder="Enter password")
|
| 274 |
+
login_btn = gr.Button("Login", variant="primary")
|
| 275 |
+
login_output = gr.Textbox(label="Status", interactive=False)
|
| 276 |
+
|
| 277 |
+
login_btn.click(
|
| 278 |
+
fn=login_user,
|
| 279 |
+
inputs=[login_mobile, login_password],
|
| 280 |
+
outputs=login_output
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
# AI Chat Tab
|
| 284 |
+
with gr.Tab("AI Chat"):
|
| 285 |
+
gr.Markdown("### Chat with 211 AI Models")
|
| 286 |
+
|
| 287 |
+
category_dropdown = gr.Dropdown(
|
| 288 |
+
choices=list(AI_MODELS.keys()),
|
| 289 |
+
label="Select Category",
|
| 290 |
+
value="Text Generation"
|
| 291 |
+
)
|
| 292 |
+
|
| 293 |
+
def update_models(category):
|
| 294 |
+
models = []
|
| 295 |
+
for subcategory, model_list in AI_MODELS[category].items():
|
| 296 |
+
models.extend(model_list)
|
| 297 |
+
return gr.Dropdown(choices=models, value=models[0] if models else None)
|
| 298 |
+
|
| 299 |
+
model_dropdown = gr.Dropdown(
|
| 300 |
+
choices=[],
|
| 301 |
+
label="Select Model"
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
category_dropdown.change(
|
| 305 |
+
fn=update_models,
|
| 306 |
+
inputs=category_dropdown,
|
| 307 |
+
outputs=model_dropdown
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
chat_input = gr.Textbox(
|
| 311 |
+
label="Your Prompt",
|
| 312 |
+
placeholder="Ask anything...",
|
| 313 |
+
lines=5
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
chat_btn = gr.Button("Send", variant="primary")
|
| 317 |
+
chat_output = gr.Textbox(label="AI Response", lines=15)
|
| 318 |
+
|
| 319 |
+
chat_btn.click(
|
| 320 |
+
fn=use_ai_model,
|
| 321 |
+
inputs=[model_dropdown, chat_input],
|
| 322 |
+
outputs=chat_output
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
# Cloudflare Services Tab
|
| 326 |
+
with gr.Tab("Cloudflare Services"):
|
| 327 |
+
gr.Markdown("### Cloudflare Integration Status")
|
| 328 |
+
gr.Markdown("""
|
| 329 |
+
This platform integrates with Cloudflare services:
|
| 330 |
+
- **R2 Storage**: Object storage for files and media
|
| 331 |
+
- **D1 Database**: Serverless SQL database
|
| 332 |
+
- **KV Cache**: Key-value store for caching
|
| 333 |
+
- **Durable Objects**: Stateful coordination
|
| 334 |
+
""")
|
| 335 |
+
|
| 336 |
+
cloudflare_status = gr.Textbox(
|
| 337 |
+
label="Service Status",
|
| 338 |
+
value=get_cloudflare_status(),
|
| 339 |
+
lines=8,
|
| 340 |
+
interactive=False
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
refresh_btn = gr.Button("Refresh Status")
|
| 344 |
+
refresh_btn.click(
|
| 345 |
+
fn=get_cloudflare_status,
|
| 346 |
+
outputs=cloudflare_status
|
| 347 |
+
)
|
| 348 |
+
|
| 349 |
+
gr.Markdown("""
|
| 350 |
+
---
|
| 351 |
+
### π Platform Features
|
| 352 |
+
- β
**211 AI Models** across 7 categories
|
| 353 |
+
- β
**Real AI Inference** via HuggingFace API
|
| 354 |
+
- β
**User Authentication** with SQLite
|
| 355 |
+
- β
**Cloudflare Integration** (R2, D1, KV, Durable Objects)
|
| 356 |
+
- β
**Clean & Secure** - No malicious patterns
|
| 357 |
+
|
| 358 |
+
**Categories**: Text Generation, Image Generation, Software Engineer, AI Teacher, Video Generation, Audio Processing, Multimodal
|
| 359 |
+
""")
|
| 360 |
+
|
| 361 |
+
# Launch app
|
| 362 |
+
app.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.44.1
|
| 2 |
+
huggingface_hub==0.24.7
|