tao-shen's picture
Upload scripts/sync_hf.py with huggingface_hub
e2bd30e verified
Raw
History Blame
1.58 kB
#!/usr/bin/env python3
import sys
import json
import os
import time
# Wait for OpenClaw to initialize
print("Waiting for OpenClaw to initialize...")
time.sleep(5)
# Load OpenClaw configuration
try:
with open('/app/.openclaw/openclaw.json', 'r') as f:
config = json.load(f)
print("OpenClaw configuration loaded successfully")
except Exception as e:
print(f"Error loading OpenClaw config: {e}")
sys.exit(1)
# Check if A2A gateway is available
try:
import a2ag
a2a_available = True
print("A2A Gateway extension is available")
except ImportError:
a2a_available = False
print("A2A Gateway extension not available")
# If A2A is available, initialize it with Cain's configuration
if a2a_available:
try:
# Extract configuration for A2A
a2a_config = {
"telegram": {
"token": config.get("telegram_token", ""),
"allowed_user_ids": config.get("telegram_allowed_ids", [])
},
"llm": {
"provider": config.get("llm_provider", "openai"),
"model": config.get("llm_model", "gpt-3.5-turbo"),
"api_key": config.get("llm_api_key", ""),
"temperature": config.get("llm_temperature", 0.7)
}
}
# Initialize A2A gateway
a2a = a2ag.A2A(a2a_config)
print("A2A Gateway initialized successfully")
except Exception as e:
print(f"Error initializing A2A Gateway: {e}")
sys.exit(1)
print("Sync script completed successfully")
sys.exit(0)