Text Generation
PyTorch
GGUF
English
quantum
quantum-entropy
from-scratch
char-level
cosmic-synapse-theory
custom-architecture
llama-cpp
continual-learning
reproducible-seed
open-science
null-results
Instructions to use phera-ra/QC67_cosmo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use phera-ra/QC67_cosmo with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: llama cli -hf phera-ra/QC67_cosmo
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: llama cli -hf phera-ra/QC67_cosmo
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: ./llama-cli -hf phera-ra/QC67_cosmo
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: ./build/bin/llama-cli -hf phera-ra/QC67_cosmo
Use Docker
docker model run hf.co/phera-ra/QC67_cosmo
- LM Studio
- Jan
- vLLM
How to use phera-ra/QC67_cosmo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "phera-ra/QC67_cosmo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "phera-ra/QC67_cosmo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/phera-ra/QC67_cosmo
- Ollama
How to use phera-ra/QC67_cosmo with Ollama:
ollama run hf.co/phera-ra/QC67_cosmo
- Unsloth Studio
How to use phera-ra/QC67_cosmo with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for phera-ra/QC67_cosmo to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for phera-ra/QC67_cosmo to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for phera-ra/QC67_cosmo to start chatting
- Docker Model Runner
How to use phera-ra/QC67_cosmo with Docker Model Runner:
docker model run hf.co/phera-ra/QC67_cosmo
- Lemonade
How to use phera-ra/QC67_cosmo with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull phera-ra/QC67_cosmo
Run and chat with the model
lemonade run user.QC67_cosmo-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
File size: 9,342 Bytes
faa70d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | """
COSMOS Cloud Endpoint API
REST API for cloud service integration and configuration.
Allows users to input API credentials and route requests to their cloud providers.
"""
from flask import Flask, request, jsonify, render_template
from cloud_router import CloudConfig, CloudRouter
import os
import json
app = Flask(__name__)
config = CloudConfig()
router = CloudRouter(config)
# ============================================================================
# CONFIGURATION ENDPOINTS
# ============================================================================
@app.route("/api/config", methods=["GET"])
def get_config():
"""Get current cloud configuration (sanitized, no keys)."""
safe_config = json.loads(json.dumps(config.config))
# Strip API keys
for provider in safe_config["providers"].values():
if "api_key" in provider:
provider["api_key"] = "[HIDDEN]"
return jsonify(safe_config)
@app.route("/api/config/provider/<provider>", methods=["GET"])
def get_provider_config(provider):
"""Get config for specific provider."""
cfg = config.get_provider_config(provider)
if not cfg:
return jsonify({"error": f"Unknown provider: {provider}"}), 404
# Sanitize
if "api_key" in cfg:
cfg["api_key"] = "[HIDDEN]"
return jsonify(cfg)
@app.route("/api/config/provider/<provider>", methods=["POST"])
def update_provider_config(provider):
"""Update provider configuration."""
data = request.json
if provider not in config.config["providers"]:
return jsonify({"error": f"Unknown provider: {provider}"}), 404
# Update configuration
if "endpoint" in data:
config.set_provider_endpoint(provider, data["endpoint"])
if "model_name" in data:
model_blob = data.get("model_blob", data["model_name"])
config.set_provider_model(provider, data["model_name"], model_blob)
if "enabled" in data:
config.enable_provider(provider, data["enabled"])
# Save (without keys)
config.save()
return jsonify({"status": "updated", "provider": provider})
@app.route("/api/config/provider/<provider>/enable", methods=["POST"])
def enable_provider(provider):
"""Enable a provider."""
config.enable_provider(provider, True)
config.save()
return jsonify({"status": "enabled", "provider": provider})
@app.route("/api/config/provider/<provider>/disable", methods=["POST"])
def disable_provider(provider):
"""Disable a provider."""
config.enable_provider(provider, False)
config.save()
return jsonify({"status": "disabled", "provider": provider})
@app.route("/api/config/default", methods=["GET"])
def get_default_provider():
"""Get default provider."""
return jsonify({"default_provider": config.get_active_provider()})
@app.route("/api/config/default", methods=["POST"])
def set_default_provider():
"""Set default provider."""
data = request.json
provider = data.get("provider")
if provider not in config.config["providers"]:
return jsonify({"error": f"Unknown provider: {provider}"}), 400
config.set_default_provider(provider)
config.save()
return jsonify({"status": "default_set", "provider": provider})
# ============================================================================
# CREDENTIAL ENDPOINTS (ENVIRONMENT VARIABLE BASED)
# ============================================================================
@app.route("/api/credentials/azure", methods=["POST"])
def set_azure_credentials():
"""Set Azure credentials via environment variable."""
data = request.json
if "api_key" not in data:
return jsonify({"error": "Missing api_key"}), 400
# Set environment variable (in memory only, not persisted)
os.environ["COSMOS_AZURE_KEY"] = data["api_key"]
config.load_credentials_from_env()
return jsonify({"status": "credentials_set", "provider": "azure"})
@app.route("/api/credentials/ibm", methods=["POST"])
def set_ibm_credentials():
"""Set IBM credentials via environment variable."""
data = request.json
if "api_key" not in data:
return jsonify({"error": "Missing api_key"}), 400
# Set environment variable (in memory only, not persisted)
os.environ["COSMOS_IBM_KEY"] = data["api_key"]
config.load_credentials_from_env()
return jsonify({"status": "credentials_set", "provider": "ibm"})
@app.route("/api/credentials/test/<provider>", methods=["POST"])
def test_credentials(provider):
"""Test provider credentials and connectivity."""
try:
response = router.generate("Hello", provider=provider)
return jsonify({"status": "success", "provider": provider, "sample": response[:100]})
except Exception as e:
return jsonify({"status": "error", "provider": provider, "error": str(e)}), 400
# ============================================================================
# GENERATION ENDPOINTS
# ============================================================================
@app.route("/api/generate", methods=["POST"])
def generate():
"""Generate response from configured provider."""
data = request.json
prompt = data.get("prompt")
provider = data.get("provider") # Optional, uses default if not provided
if not prompt:
return jsonify({"error": "Missing prompt"}), 400
try:
response = router.generate(prompt, provider=provider)
return jsonify({"response": response, "provider": provider or config.get_active_provider()})
except Exception as e:
return jsonify({"error": str(e)}), 400
@app.route("/api/vision", methods=["POST"])
def vision():
"""Analyze image with vision model."""
# Expects multipart form with 'image' file and 'prompt' field
if "image" not in request.files:
return jsonify({"error": "Missing image file"}), 400
prompt = request.form.get("prompt", "Describe this image.")
provider = request.form.get("provider")
image_file = request.files["image"]
image_path = f"/tmp/{image_file.filename}"
image_file.save(image_path)
try:
response = router.vision(image_path, prompt, provider=provider)
return jsonify({"response": response, "provider": provider or config.get_active_provider()})
except Exception as e:
return jsonify({"error": str(e)}), 400
finally:
if os.path.exists(image_path):
os.remove(image_path)
# ============================================================================
# STATUS & HEALTH ENDPOINTS
# ============================================================================
@app.route("/api/status", methods=["GET"])
def status():
"""Get system status."""
providers = config.config["providers"]
status_info = {
"default_provider": config.get_active_provider(),
"providers": {
name: {
"enabled": cfg.get("enabled", False),
"endpoint": cfg.get("api_endpoint", "N/A"),
"model": cfg.get("model_name", "N/A"),
"has_credentials": bool(cfg.get("api_key"))
}
for name, cfg in providers.items()
}
}
return jsonify(status_info)
@app.route("/api/health", methods=["GET"])
def health():
"""Health check."""
return jsonify({"status": "healthy", "service": "COSMOS Cloud Router"})
# ============================================================================
# UI ENDPOINTS
# ============================================================================
@app.route("/", methods=["GET"])
def dashboard():
"""Configuration dashboard (simple HTML form)."""
return render_template("dashboard.html")
@app.route("/docs", methods=["GET"])
def docs():
"""API documentation."""
return render_template("api_docs.html")
# ============================================================================
# ERROR HANDLERS
# ============================================================================
@app.errorhandler(404)
def not_found(error):
return jsonify({"error": "Endpoint not found"}), 404
@app.errorhandler(500)
def internal_error(error):
return jsonify({"error": "Internal server error"}), 500
# ============================================================================
# MAIN
# ============================================================================
if __name__ == "__main__":
print("COSMOS Cloud Endpoint Starting...")
print(f"Default provider: {config.get_active_provider()}")
print(f"Enabled providers: {[name for name, cfg in config.config['providers'].items() if cfg.get('enabled')]}")
print("\nAPI Documentation: http://localhost:5000/docs")
print("Configuration Dashboard: http://localhost:5000/")
print("\nEnvironment variables for credentials:")
print(" COSMOS_AZURE_KEY - Azure OpenAI API key")
print(" COSMOS_IBM_KEY - IBM Watsonx API key")
app.run(debug=True, host="0.0.0.0", port=5000)
|