CoolFace
Apppublic

Klin12/my-personal-assistant

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

OpenClaw on Hugging Face Spaces - Smart Auto-Detection System

๐ŸŽฏ What This Does

This is an intelligent OpenClaw deployment that automatically detects the best way to run OpenClaw in Docker and uses it. No manual configuration needed!

The Smart System

Docker Build Time:
  โ†“
Install OpenClaw
  โ†“
Investigate its structure
  โ†’ Check for SDK exports
  โ†’ Find server files  
  โ†’ Map available APIs
  โ†“
Save investigation results

Runtime:
  โ†“
Smart Gateway starts
  โ†“
Method 1: Try OpenClaw SDK
  โ†“ (if fails)
Method 2: Try direct server execution
  โ†“ (if fails)
Method 3: Enhanced custom fallback
  โ†“
โœ“ Gateway running!

โœจ Key Features

๐Ÿ” Auto-Detection

  • โ€”Investigates OpenClaw during Docker build
  • โ€”Tries multiple methods to run it
  • โ€”Automatically falls back if needed
  • โ€”You get the best possible implementation

๐ŸŽจ Multiple Modes

Mode 1: OpenClaw SDK (Best)

  • โ€”โœ… Full OpenClaw features
  • โ€”โœ… Multi-channel support
  • โ€”โœ… Plugin system
  • โ€”โœ… Native UI

Mode 2: Direct Execution (Good)

  • โ€”โœ… Most OpenClaw features
  • โ€”โœ… Direct server access
  • โ€”โš ๏ธ May have limited APIs

Mode 3: Enhanced Custom (Fallback)

  • โ€”โœ… Core chat functionality
  • โ€”โœ… Conversation history
  • โ€”โœ… Persistent storage
  • โ€”โŒ Web-only (no Telegram/Discord)

๐Ÿš€ Quick Setup

1. Required Secrets

Go to Space Settings โ†’ Variables and secrets, add:

Secret NameValueHow to Get
HF_TOKENhf_xxxxxhttps://huggingface.co/settings/tokens (Write access)
STORAGE_DATASET_REPOKlin12/openclaw-dataYour dataset repo name
GOOGLE_API_KEYAIzaSyxxxxxhttps://aistudio.google.com/app/apikey
GATEWAY_AUTH_TOKENRandom 32+ charsopenssl rand -hex 32

2. Files Already Uploaded โœ“

These files should already be in your Space:

  • โ€”โœ… Dockerfile - Investigates & installs OpenClaw
  • โ€”โœ… smart-gateway.js - Auto-detecting gateway
  • โ€”โœ… storage-adapter.js - HF Dataset sync
  • โ€”โœ… start.sh - Startup script
  • โ€”โœ… README.md - This file

3. Access Your Assistant

Once the Space builds (3-5 minutes), access at:

https://Klin12-my-personal-assistant.hf.space

๐Ÿ” How to Check What's Running

During Build (Check Logs Tab)

Look for investigation results:

=== OpenClaw Investigation Results ===
Package.json main entry: dist/index.js
Module exports: { success: true, ... }

During Runtime (Check Logs Tab)

Look for success messages:

OpenClaw SDK mode:

[Method 1] โœ“โœ“โœ“ SUCCESS! OpenClaw Gateway started via SDK

Direct execution mode:

[Method 2] โœ“โœ“โœ“ SUCCESS! Server started from direct file

Custom fallback mode:

[Method 3] โœ“โœ“โœ“ Enhanced custom gateway running on port 7860

In the Web Interface

The badge shows which implementation is running:

  • โ€”๐ŸŸข "OpenClaw SDK" = Full OpenClaw features
  • โ€”๐ŸŸก "Enhanced Custom Gateway" = Fallback mode

Via API

bash
curl -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  https://Klin12-my-personal-assistant.hf.space/api/status

๐Ÿ“Š What You Get

Best Case: Method 1 Success ๐ŸŽ‰

  • โ€”โœ… Full OpenClaw features
  • โ€”โœ… Multi-channel support (Telegram, Discord, Slack)
  • โ€”โœ… Plugin system
  • โ€”โœ… Advanced conversation management
  • โ€”โœ… Tool use capabilities

Good Case: Method 2 Success ๐Ÿ‘

  • โ€”โœ… Most OpenClaw features
  • โ€”โœ… Direct server access
  • โ€”โœ… Core functionality
  • โ€”โš ๏ธ Some advanced features may be limited

Fallback Case: Method 3 ๐Ÿ’ช

  • โ€”โœ… Web chat interface (modern, responsive)
  • โ€”โœ… Conversation history (persistent)
  • โ€”โœ… Multi-turn context preservation
  • โ€”โœ… Google Gemini AI integration
  • โ€”โœ… Auto-sync to HF Dataset
  • โ€”โŒ Web-only (no Telegram/Discord)
  • โ€”โŒ No plugin system

Either way, you get a fully functional AI assistant!

๐ŸŽจ Customization

Change AI Model

Add to Space secrets:

bash
GEMINI_MODEL=gemini-2.5-pro  # More powerful
# or
GEMINI_MODEL=gemini-2.0-flash  # Faster

Available models:

  • โ€”gemini-2.5-flash - Latest, fast (default)
  • โ€”gemini-2.5-pro - Most capable
  • โ€”gemini-2.0-flash - Fast and efficient

Adjust Sync Frequency

bash
SYNC_INTERVAL=30000  # 30 seconds (default: 10000)

Force Fallback Mode (for testing)

bash
FORCE_CUSTOM_GATEWAY=true

๐Ÿ› ๏ธ Troubleshooting

Build Fails

Check:

  1. 1.All 4 secrets are set correctly
  2. 2.Dataset repository exists
  3. 3.HF_TOKEN has write permissions

Fix:

  • โ€”Review build logs for specific errors
  • โ€”Verify all files are uploaded
  • โ€”Check Space settings

Can't Access Web Interface

Check:

  1. 1.Build completed successfully (Status: "Running")
  2. 2.No errors in Logs tab
  3. 3.URL is correct: https://Klin12-my-personal-assistant.hf.space

Fix:

  • โ€”Wait for build to complete
  • โ€”Force rebuild by editing README (add a space)
  • โ€”Check firewall/VPN settings

Gateway Not Responding

Check:

  1. 1.GOOGLEAPIKEY is set and valid
  2. 2.Auth token matches in request
  3. 3.Logs show gateway started successfully

Fix:

  • โ€”Verify API key at https://aistudio.google.com/app/apikey
  • โ€”Check you haven't exceeded API quota (1000 req/day free)
  • โ€”Restart Space if needed

Data Not Syncing

Check:

  1. 1.HF_TOKEN has write permissions
  2. 2.Dataset repo is accessible
  3. 3.No rate limiting errors in logs

Fix:

  • โ€”Increase SYNC_INTERVAL to reduce API calls
  • โ€”Verify token permissions
  • โ€”Check dataset repo commits tab

๐Ÿ“ˆ Understanding the System

Why This Approach?

The Problem:

  • โ€”OpenClaw CLI uses systemctl for service management
  • โ€”Docker containers don't have systemd
  • โ€”Can't run openclaw gateway start normally

The Solution:

  1. 1.Investigate OpenClaw's structure during build
  2. 2.Find how to run it without systemctl
  3. 3.Try multiple methods in order
  4. 4.Use whichever works!

What Makes It Smart?

  • โ€”โœ… Adapts automatically to OpenClaw's structure
  • โ€”โœ… Works with future updates without manual changes
  • โ€”โœ… Tries multiple approaches for maximum compatibility
  • โ€”โœ… Always provides a working gateway
  • โ€”โœ… Transparent - shows exactly what it's doing

Investigation Report

During build, creates:

  • โ€”/app/investigation/exports.json - Module analysis
  • โ€”/app/investigation/package.json - OpenClaw metadata
  • โ€”/app/investigation/tree.txt - Directory structure
  • โ€”/app/investigation/js-files.txt - JavaScript files
  • โ€”/app/investigation/gateway-search.txt - Gateway locations
  • โ€”/app/investigation/server-search.txt - Server code locations

๐Ÿ’ก Pro Tips

  1. 1.Check build logs to see investigation results
  2. 2.Monitor runtime logs to see which method succeeded
  3. 3.Use status API to verify mode and features
  4. 4.Bookmark your Space URL for quick access
  5. 5.Set dataset to Private for sensitive conversations

๐Ÿ”— Resources

  • โ€”Your Space: https://huggingface.co/spaces/Klin12/my-personal-assistant
  • โ€”Your Dataset: https://huggingface.co/datasets/Klin12/openclaw-data
  • โ€”Space Settings: https://huggingface.co/spaces/Klin12/my-personal-assistant/settings
  • โ€”Google AI Studio: https://aistudio.google.com/app/apikey
  • โ€”HF Tokens: https://huggingface.co/settings/tokens

๐Ÿ“Š Cost Breakdown

ItemCost
HF Space (CPU basic)FREE
Dataset storageFREE
Google Gemini API (1000 req/day)FREE
Total$0/month

Perfect for personal use! For production or high-volume, consider upgrading.

๐ŸŽฏ Next Steps

  1. 1.โœ… Secrets are configured
  2. 2.โœ… Files are uploaded
  3. 3.โณ Wait for build (3-5 min)
  4. 4.๐Ÿ” Check logs to see which mode
  5. 5.๐ŸŽ‰ Start chatting with your assistant!

โ“ FAQ

Q: Which mode will I get? A: Depends on OpenClaw's structure. The system will automatically use the best available method. Check logs to see!

Q: Can I force a specific mode? A: Yes, set FORCE_CUSTOM_GATEWAY=true to use fallback mode.

Q: Will this work with future OpenClaw updates? A: Yes! The investigation system adapts automatically.

Q: What if all methods fail? A: Very unlikely - Method 3 is guaranteed to work.

Q: How do I get full OpenClaw features? A: Hope for Method 1 or 2 success! Check build logs to see what the investigation found.


This is the smartest way to run OpenClaw in Docker! ๐Ÿง ๐Ÿฆž

The system handles all the complexity of Docker compatibility, so you can focus on using your AI assistant!