Spaces:
Configuration error
Configuration error
force: manual sync from GitHub [align port 7860]
#5
by Baida-A - opened
- REBUILD_TRIGGER +1 -0
- api/files.py +8 -8
- models/ai_client.py +2 -2
REBUILD_TRIGGER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
rebuild
|
api/files.py
CHANGED
|
@@ -137,20 +137,20 @@ import os
|
|
| 137 |
VFS_OFFLOAD_THRESHOLD_BYTES = 512 * 1024
|
| 138 |
|
| 139 |
async def _offload_to_hf(content: str, filename: str) -> str:
|
| 140 |
-
|
| 141 |
from .hf_storage import hf_append_record
|
| 142 |
record = {
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
}
|
| 148 |
# Usiamo hf_append_record per salvare il file nel dataset
|
| 149 |
-
success = await hf_append_record(
|
| 150 |
if success:
|
| 151 |
# Nota: In produzione qui genereremmo un URL diretto R2 o HF
|
| 152 |
-
return f
|
| 153 |
-
return
|
| 154 |
|
| 155 |
|
| 156 |
@router.post('/api/files')
|
|
|
|
| 137 |
VFS_OFFLOAD_THRESHOLD_BYTES = 512 * 1024
|
| 138 |
|
| 139 |
async def _offload_to_hf(content: str, filename: str) -> str:
|
| 140 |
+
"""Carica il contenuto su HF Storage e restituisce l'URL."""
|
| 141 |
from .hf_storage import hf_append_record
|
| 142 |
record = {
|
| 143 |
+
"filename": filename,
|
| 144 |
+
"content_preview": content[:1000],
|
| 145 |
+
"full_content": content,
|
| 146 |
+
"offloaded_at": int(time.time() * 1000)
|
| 147 |
}
|
| 148 |
# Usiamo hf_append_record per salvare il file nel dataset
|
| 149 |
+
success = await hf_append_record("offloaded_files.jsonl", record)
|
| 150 |
if success:
|
| 151 |
# Nota: In produzione qui genereremmo un URL diretto R2 o HF
|
| 152 |
+
return f"https://huggingface.co/datasets/{os.getenv('HF_DATASET_REPO', 'Arjanit98/agent-memory')}/raw/main/offloaded_files.jsonl"
|
| 153 |
+
return ""
|
| 154 |
|
| 155 |
|
| 156 |
@router.post('/api/files')
|
models/ai_client.py
CHANGED
|
@@ -484,8 +484,8 @@ class AIClient:
|
|
| 484 |
# RF-3: attivo se CF_API_TOKEN + CF_ACCOUNT_ID entrambi presenti.
|
| 485 |
# Endpoint OpenAI-compatible: /accounts/{id}/ai/v1
|
| 486 |
# Free: 10K req/giorno, nessun account separato — usa il token Cloudflare.
|
| 487 |
-
cf_token = os.getenv("CF_API_TOKEN")
|
| 488 |
-
cf_account = os.getenv("CF_ACCOUNT_ID")
|
| 489 |
if cf_token and cf_account and not os.getenv("DISABLE_CF_PROVIDER"):
|
| 490 |
providers.append(ProviderConfig(
|
| 491 |
name="cloudflare",
|
|
|
|
| 484 |
# RF-3: attivo se CF_API_TOKEN + CF_ACCOUNT_ID entrambi presenti.
|
| 485 |
# Endpoint OpenAI-compatible: /accounts/{id}/ai/v1
|
| 486 |
# Free: 10K req/giorno, nessun account separato — usa il token Cloudflare.
|
| 487 |
+
cf_token = os.getenv("CF_API_TOKEN") or os.getenv("CLOUDFLARE_API_TOKEN")
|
| 488 |
+
cf_account = os.getenv("CF_ACCOUNT_ID") or os.getenv("CLOUDFLARE_ACCOUNT_ID")
|
| 489 |
if cf_token and cf_account and not os.getenv("DISABLE_CF_PROVIDER"):
|
| 490 |
providers.append(ProviderConfig(
|
| 491 |
name="cloudflare",
|