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: 10,333 Bytes
67efd99 | 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 | """
Cloud Services Integration for COSMOS
Enables optional Azure, IBM, and other cloud APIs while maintaining local-first design.
Users can input their own credentials and model references.
"""
import os
import json
from pathlib import Path
from typing import Optional, Dict, Any
class CloudConfig:
"""Manage cloud service credentials and configuration."""
def __init__(self, config_path: str = "cloud_config.json"):
self.config_path = Path(config_path)
self.config = self._load_config()
def _load_config(self) -> Dict[str, Any]:
"""Load cloud config from file or create template."""
if self.config_path.exists():
with open(self.config_path, 'r') as f:
return json.load(f)
# Default template
return {
"enabled": False,
"default_provider": "ollama", # ollama, azure, ibm, custom
"providers": {
"azure": {
"enabled": False,
"api_key": "", # Set via env: COSMOS_AZURE_KEY
"api_endpoint": "", # https://{resource}.openai.azure.com/
"deployment_name": "", # Model deployment name
"model_blob": "gpt-4", # Vision: gpt-4-vision, etc.
"temperature": 0.7,
"timeout": 30
},
"ibm": {
"enabled": False,
"api_key": "", # Set via env: COSMOS_IBM_KEY
"api_endpoint": "", # https://api.us-south.watson-platform.net/instances/...
"model_name": "granite-13b-chat-v2", # or custom model ID
"model_blob": "ibm/granite",
"temperature": 0.7,
"timeout": 30
},
"ollama": {
"enabled": True, # Local by default
"api_endpoint": "http://localhost:11434",
"model_name": "cosmos-q4:latest",
"timeout": 60
}
}
}
def save(self):
"""Save configuration to file."""
# Don't save API keys to disk — they must come from env vars
safe_config = json.loads(json.dumps(self.config))
safe_config["providers"]["azure"]["api_key"] = "[SET_VIA_ENV]"
safe_config["providers"]["ibm"]["api_key"] = "[SET_VIA_ENV]"
with open(self.config_path, 'w') as f:
json.dump(safe_config, f, indent=2)
def load_credentials_from_env(self):
"""Load API credentials from environment variables (secure method)."""
self.config["providers"]["azure"]["api_key"] = os.getenv("COSMOS_AZURE_KEY", "")
self.config["providers"]["ibm"]["api_key"] = os.getenv("COSMOS_IBM_KEY", "")
def enable_provider(self, provider: str, enabled: bool = True):
"""Enable/disable a cloud provider."""
if provider in self.config["providers"]:
self.config["providers"][provider]["enabled"] = enabled
def set_provider_endpoint(self, provider: str, endpoint: str):
"""Set API endpoint for a provider."""
if provider in self.config["providers"]:
self.config["providers"][provider]["api_endpoint"] = endpoint
def set_provider_model(self, provider: str, model_name: str, model_blob: str = None):
"""Set model name and optional blob reference."""
if provider in self.config["providers"]:
self.config["providers"][provider]["model_name"] = model_name
if model_blob:
self.config["providers"][provider]["model_blob"] = model_blob
def get_active_provider(self) -> str:
"""Get the currently active provider."""
return self.config.get("default_provider", "ollama")
def set_default_provider(self, provider: str):
"""Set default provider for requests."""
if provider in self.config["providers"]:
self.config["default_provider"] = provider
def get_provider_config(self, provider: str) -> Dict[str, Any]:
"""Get full config for a specific provider."""
return self.config["providers"].get(provider, {})
class CloudRouter:
"""Route requests to appropriate cloud service."""
def __init__(self, config: CloudConfig):
self.config = config
self.config.load_credentials_from_env()
def generate(self, prompt: str, provider: Optional[str] = None, **kwargs) -> str:
"""Generate response from configured provider."""
provider = provider or self.config.get_active_provider()
if provider == "azure":
return self._generate_azure(prompt, **kwargs)
elif provider == "ibm":
return self._generate_ibm(prompt, **kwargs)
elif provider == "ollama":
return self._generate_ollama(prompt, **kwargs)
else:
raise ValueError(f"Unknown provider: {provider}")
def _generate_azure(self, prompt: str, **kwargs) -> str:
"""Call Azure OpenAI API."""
try:
import openai
except ImportError:
raise ImportError("Install openai: pip install openai")
cfg = self.config.get_provider_config("azure")
if not cfg["enabled"] or not cfg["api_key"]:
raise ValueError("Azure not enabled or API key not set (use COSMOS_AZURE_KEY env var)")
client = openai.AzureOpenAI(
api_key=cfg["api_key"],
api_version="2024-02-15-preview",
azure_endpoint=cfg["api_endpoint"]
)
response = client.chat.completions.create(
model=cfg["deployment_name"],
messages=[{"role": "user", "content": prompt}],
temperature=cfg.get("temperature", 0.7),
timeout=cfg.get("timeout", 30)
)
return response.choices[0].message.content
def _generate_ibm(self, prompt: str, **kwargs) -> str:
"""Call IBM Watsonx API."""
try:
from ibm_cloud_sdk_core import Authenticator, IAMAuthenticator
from ibm_platform_services import WatsonxAiAnalyticsV1
except ImportError:
raise ImportError("Install IBM SDK: pip install ibm-cloud-sdk-core ibm-cloud-sdk-watsonx")
cfg = self.config.get_provider_config("ibm")
if not cfg["enabled"] or not cfg["api_key"]:
raise ValueError("IBM not enabled or API key not set (use COSMOS_IBM_KEY env var)")
authenticator = IAMAuthenticator(apikey=cfg["api_key"])
service = WatsonxAiAnalyticsV1(
version="2024-01-01",
authenticator=authenticator,
service_url=cfg["api_endpoint"]
)
response = service.generate(
input=prompt,
model_id=cfg["model_name"],
parameters={
"temperature": cfg.get("temperature", 0.7),
"max_tokens": 512
}
).get_result()
return response["results"][0]["generated_text"]
def _generate_ollama(self, prompt: str, **kwargs) -> str:
"""Call local Ollama API."""
try:
import requests
except ImportError:
raise ImportError("Install requests: pip install requests")
cfg = self.config.get_provider_config("ollama")
response = requests.post(
f"{cfg['api_endpoint']}/api/generate",
json={
"model": cfg["model_name"],
"prompt": prompt,
"stream": False
},
timeout=cfg.get("timeout", 60)
)
if response.status_code == 200:
return response.json()["response"]
else:
raise RuntimeError(f"Ollama error: {response.text}")
def vision(self, image_path: str, prompt: str, provider: Optional[str] = None) -> str:
"""Process image with vision model (Azure/IBM only)."""
provider = provider or self.config.get_active_provider()
if provider == "azure":
return self._vision_azure(image_path, prompt)
elif provider == "ibm":
return self._vision_ibm(image_path, prompt)
else:
raise ValueError(f"Vision not supported on {provider} provider")
def _vision_azure(self, image_path: str, prompt: str) -> str:
"""Azure vision analysis."""
import base64
from pathlib import Path
import openai
cfg = self.config.get_provider_config("azure")
client = openai.AzureOpenAI(
api_key=cfg["api_key"],
api_version="2024-02-15-preview",
azure_endpoint=cfg["api_endpoint"]
)
# Read and encode image
with open(image_path, "rb") as img_file:
image_data = base64.standard_b64encode(img_file.read()).decode("utf-8")
ext = Path(image_path).suffix.lower()
media_type = {"jpg": "image/jpeg", "jpeg": "image/jpeg", "png": "image/png", "gif": "image/gif", "webp": "image/webp"}.get(ext[1:], "image/jpeg")
response = client.chat.completions.create(
model=cfg["deployment_name"],
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": prompt},
{
"type": "image_url",
"image_url": {"url": f"data:{media_type};base64,{image_data}"}
}
]
}
]
)
return response.choices[0].message.content
def _vision_ibm(self, image_path: str, prompt: str) -> str:
"""IBM vision analysis."""
raise NotImplementedError("IBM vision support coming soon")
# Export
__all__ = ["CloudConfig", "CloudRouter"]
|