Spaces:
Running
Running
Qalam (via Manus) commited on
Commit ·
aafc2da
1
Parent(s): 5a002e9
Fix: Python 3.13 compatibility, audioop issues, and env var alignment
Browse files- .env.template +1 -1
- Dockerfile +1 -0
- README.md +4 -3
- app.py +10 -1
- core/nuclear_intelligence.py +2 -1
- requirements.txt +2 -1
- requirements_enhanced.txt +7 -1
- scripts/keep_alive.py +2 -1
- scripts/run_operation_cycle.py +2 -2
- scripts/sync_huggingface.py +2 -2
.env.template
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# OpenAI Configuration
|
| 2 |
OPENAI_API_KEY=your-openai-api-key
|
| 3 |
OPENAI_API_BASE=https://api.openai.com/v1
|
| 4 |
-
LLM_MODEL=gpt-
|
| 5 |
|
| 6 |
# Hugging Face Configuration
|
| 7 |
HUGGINGFACE_API_KEY=your-huggingface-api-key
|
|
|
|
| 1 |
# OpenAI Configuration
|
| 2 |
OPENAI_API_KEY=your-openai-api-key
|
| 3 |
OPENAI_API_BASE=https://api.openai.com/v1
|
| 4 |
+
LLM_MODEL=gpt-4o
|
| 5 |
|
| 6 |
# Hugging Face Configuration
|
| 7 |
HUGGINGFACE_API_KEY=your-huggingface-api-key
|
Dockerfile
CHANGED
|
@@ -13,6 +13,7 @@ RUN apt-get update && apt-get install -y \
|
|
| 13 |
libportaudiocpp0 \
|
| 14 |
portaudio19-dev \
|
| 15 |
ffmpeg \
|
|
|
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
# Copy requirements and install
|
|
|
|
| 13 |
libportaudiocpp0 \
|
| 14 |
portaudio19-dev \
|
| 15 |
ffmpeg \
|
| 16 |
+
libavcodec-extra \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
# Copy requirements and install
|
README.md
CHANGED
|
@@ -231,11 +231,12 @@ nuclear-intelligence/
|
|
| 231 |
|
| 232 |
| Variable | Description | Default |
|
| 233 |
|----------|-------------|---------|
|
| 234 |
-
| `HF_TOKEN` | Hugging Face API token | - |
|
| 235 |
| `GITHUB_TOKEN` | GitHub personal access token | - |
|
| 236 |
| `OPENAI_API_KEY` | OpenAI API key | - |
|
| 237 |
-
| `
|
| 238 |
-
| `
|
|
|
|
| 239 |
| `FEATURE_HUMAN_IN_THE_LOOP` | Enable human review | true |
|
| 240 |
| `API_HOST` | API server host | 0.0.0.0 |
|
| 241 |
| `API_PORT` | API server port | 8000 |
|
|
|
|
| 231 |
|
| 232 |
| Variable | Description | Default |
|
| 233 |
|----------|-------------|---------|
|
| 234 |
+
| `HF_TOKEN` | Hugging Face API token (fallback: `HUGGINGFACE_API_KEY`) | - |
|
| 235 |
| `GITHUB_TOKEN` | GitHub personal access token | - |
|
| 236 |
| `OPENAI_API_KEY` | OpenAI API key | - |
|
| 237 |
+
| `LLM_MODEL` | Large LLM model | gpt-4-turbo |
|
| 238 |
+
| `OPERATION_LOOP_INTERVAL_MINUTES` | Operation loop interval | 30 |
|
| 239 |
+
| `SCIENTIFIC_ACCURACY_THRESHOLD` | Min accuracy for minting | 93 |
|
| 240 |
| `FEATURE_HUMAN_IN_THE_LOOP` | Enable human review | true |
|
| 241 |
| `API_HOST` | API server host | 0.0.0.0 |
|
| 242 |
| `API_PORT` | API server port | 8000 |
|
app.py
CHANGED
|
@@ -14,9 +14,18 @@ from core.operation_loop import OperationLoop, OperationLoopConfig
|
|
| 14 |
|
| 15 |
# Initialize System
|
| 16 |
logger.info("Initializing Nuclear Intelligence System...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
core = NuclearIntelligenceCore()
|
| 18 |
ledger = VirtualLedger()
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
__all__ = ['demo', 'core', 'ledger', 'op_loop']
|
| 22 |
|
|
|
|
| 14 |
|
| 15 |
# Initialize System
|
| 16 |
logger.info("Initializing Nuclear Intelligence System...")
|
| 17 |
+
|
| 18 |
+
# Load configuration from environment
|
| 19 |
+
accuracy_threshold = float(os.getenv("SCIENTIFIC_ACCURACY_THRESHOLD", 93.0))
|
| 20 |
+
loop_interval = int(os.getenv("OPERATION_LOOP_INTERVAL_MINUTES", 30))
|
| 21 |
+
|
| 22 |
core = NuclearIntelligenceCore()
|
| 23 |
ledger = VirtualLedger()
|
| 24 |
+
config = OperationLoopConfig(
|
| 25 |
+
min_accuracy=accuracy_threshold,
|
| 26 |
+
interval_minutes=loop_interval
|
| 27 |
+
)
|
| 28 |
+
op_loop = OperationLoop(core, ledger, config=config)
|
| 29 |
|
| 30 |
__all__ = ['demo', 'core', 'ledger', 'op_loop']
|
| 31 |
|
core/nuclear_intelligence.py
CHANGED
|
@@ -71,9 +71,10 @@ class KnowledgeGraph:
|
|
| 71 |
class NuclearIntelligenceCore:
|
| 72 |
def __init__(
|
| 73 |
self,
|
| 74 |
-
model_name: str =
|
| 75 |
vector_db_path: str = "knowledge_base/faiss_index"
|
| 76 |
):
|
|
|
|
| 77 |
self.llm = ChatOpenAI(model=model_name, temperature=0.7)
|
| 78 |
self.embeddings = OpenAIEmbeddings()
|
| 79 |
self.vector_db_path = vector_db_path
|
|
|
|
| 71 |
class NuclearIntelligenceCore:
|
| 72 |
def __init__(
|
| 73 |
self,
|
| 74 |
+
model_name: str = None,
|
| 75 |
vector_db_path: str = "knowledge_base/faiss_index"
|
| 76 |
):
|
| 77 |
+
model_name = model_name or os.getenv("LLM_MODEL", "gpt-4o")
|
| 78 |
self.llm = ChatOpenAI(model=model_name, temperature=0.7)
|
| 79 |
self.embeddings = OpenAIEmbeddings()
|
| 80 |
self.vector_db_path = vector_db_path
|
requirements.txt
CHANGED
|
@@ -54,4 +54,5 @@ loguru>=0.7.2
|
|
| 54 |
# Audio and System
|
| 55 |
pydub>=0.25.1
|
| 56 |
PyAudio>=0.2.13
|
| 57 |
-
|
|
|
|
|
|
| 54 |
# Audio and System
|
| 55 |
pydub>=0.25.1
|
| 56 |
PyAudio>=0.2.13
|
| 57 |
+
audioop-lts>=0.2.1 # For Python 3.13 compatibility
|
| 58 |
+
pyaudioop-compatible>=1.0.0; python_version >= "3.13"
|
requirements_enhanced.txt
CHANGED
|
@@ -50,9 +50,15 @@ matplotlib==3.8.2
|
|
| 50 |
|
| 51 |
# Hugging Face Integration
|
| 52 |
huggingface-hub==0.19.4
|
| 53 |
-
|
| 54 |
|
| 55 |
# Utilities
|
| 56 |
tenacity==8.2.3
|
| 57 |
tqdm==4.66.1
|
| 58 |
loguru==0.7.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# Hugging Face Integration
|
| 52 |
huggingface-hub==0.19.4
|
| 53 |
+
datasets==2.16.1
|
| 54 |
|
| 55 |
# Utilities
|
| 56 |
tenacity==8.2.3
|
| 57 |
tqdm==4.66.1
|
| 58 |
loguru==0.7.2
|
| 59 |
+
|
| 60 |
+
# Audio and System
|
| 61 |
+
pydub>=0.25.1
|
| 62 |
+
PyAudio>=0.2.13
|
| 63 |
+
audioop-lts>=0.2.1 # For Python 3.13 compatibility
|
| 64 |
+
pyaudioop-compatible>=1.0.0; python_version >= "3.13"
|
scripts/keep_alive.py
CHANGED
|
@@ -5,7 +5,8 @@ import logging
|
|
| 5 |
logging.basicConfig(level=logging.INFO)
|
| 6 |
logger = logging.getLogger(__name__)
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
def ping_space():
|
| 11 |
try:
|
|
|
|
| 5 |
logging.basicConfig(level=logging.INFO)
|
| 6 |
logger = logging.getLogger(__name__)
|
| 7 |
|
| 8 |
+
import os
|
| 9 |
+
URL = os.getenv("SPACE_URL", "https://huggingface.co/spaces/Qalam/Nuclear-Intelligence")
|
| 10 |
|
| 11 |
def ping_space():
|
| 12 |
try:
|
scripts/run_operation_cycle.py
CHANGED
|
@@ -42,8 +42,8 @@ def main():
|
|
| 42 |
|
| 43 |
# Configure the operation loop
|
| 44 |
op_config = OperationLoopConfig(
|
| 45 |
-
min_accuracy=float(os.getenv("
|
| 46 |
-
interval_minutes=int(os.getenv("
|
| 47 |
)
|
| 48 |
|
| 49 |
logging.info("Initializing Operation Loop...")
|
|
|
|
| 42 |
|
| 43 |
# Configure the operation loop
|
| 44 |
op_config = OperationLoopConfig(
|
| 45 |
+
min_accuracy=float(os.getenv("SCIENTIFIC_ACCURACY_THRESHOLD", "93.0")),
|
| 46 |
+
interval_minutes=int(os.getenv("OPERATION_LOOP_INTERVAL_MINUTES", "30"))
|
| 47 |
)
|
| 48 |
|
| 49 |
logging.info("Initializing Operation Loop...")
|
scripts/sync_huggingface.py
CHANGED
|
@@ -24,9 +24,9 @@ def main():
|
|
| 24 |
"""Sync with Hugging Face."""
|
| 25 |
logger.info("Starting Hugging Face synchronization...")
|
| 26 |
|
| 27 |
-
hf_token = os.getenv("HF_TOKEN")
|
| 28 |
if not hf_token:
|
| 29 |
-
logger.warning("HF_TOKEN not set, skipping sync")
|
| 30 |
return 0
|
| 31 |
|
| 32 |
try:
|
|
|
|
| 24 |
"""Sync with Hugging Face."""
|
| 25 |
logger.info("Starting Hugging Face synchronization...")
|
| 26 |
|
| 27 |
+
hf_token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_API_KEY")
|
| 28 |
if not hf_token:
|
| 29 |
+
logger.warning("HF_TOKEN or HUGGINGFACE_API_KEY not set, skipping sync")
|
| 30 |
return 0
|
| 31 |
|
| 32 |
try:
|