Dmitry Beresnev commited on
Commit
4e34289
·
1 Parent(s): c6e1970
Files changed (4) hide show
  1. Dockerfile +22 -27
  2. README.md +5 -0
  3. app.py +29 -13
  4. requirements.txt +2 -0
Dockerfile CHANGED
@@ -1,36 +1,31 @@
1
- # Base image
2
- FROM node:20
3
 
4
  WORKDIR /app
5
 
6
- # Install Clawdbot
7
- RUN npm install -g clawdbot
 
 
 
 
 
 
 
 
8
 
9
- # Install Python + Whisper for voice
10
- RUN apt-get update && apt-get install -y python3 python3-pip ffmpeg git
11
- RUN pip3 install openai whisper sentence-transformers transformers
12
 
13
- # Copy config / scripts
14
- COPY . .
15
 
16
- # Expose port for Space UI
17
- EXPOSE 7860
18
-
19
- # Environment variables
20
- ENV LLM_API_BASE="https://researchengineering-agi.hf.space"
21
- ENV LLM_MODEL="deepseek-chat"
22
- #ENV VAULT_REPO="https://researchengineering-agi-assistant.hf.space.git"
23
- ENV VAULT_PATH="/app/vault"
24
 
25
- # Clone vault repo on startup
26
- #RUN git clone $VAULT_REPO $VAULT_PATH
27
 
28
- # Start Clawdbot in HF-compatible mode
29
- #CMD ["clawdbot", "gateway", "--port", "7860", "--vault-path", "/vault"]
30
-
31
- # Make sure vault directory exists
32
- RUN mkdir -p $VAULT_PATH
33
 
34
- # Start Clawdbot
35
- #CMD ["clawdbot", "gateway", "--port", "7860", "--vault-path", "/app/vault"]
36
- CMD ["python3", "app.py"]
 
1
+ FROM python:3.13-slim
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install runtime system packages and Node.js for OpenClaw.
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ curl \
8
+ ca-certificates \
9
+ ffmpeg \
10
+ git \
11
+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
12
+ && apt-get install -y --no-install-recommends nodejs \
13
+ && (npm install -g openclaw || npm install -g clawdbot) \
14
+ && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Python dependencies for the Gradio frontend.
17
+ COPY requirements.txt /app/requirements.txt
18
+ RUN pip install --no-cache-dir -r /app/requirements.txt
19
 
20
+ COPY . /app
 
21
 
22
+ ENV PORT=7860
23
+ ENV OPENCLAW_PORT=8787
24
+ ENV OPENCLAW_BIN=openclaw
25
+ ENV VAULT_PATH=/app/vault
 
 
 
 
26
 
27
+ RUN mkdir -p /app/vault
 
28
 
29
+ EXPOSE 7860
 
 
 
 
30
 
31
+ CMD ["python", "app.py"]
 
 
README.md CHANGED
@@ -11,6 +11,11 @@ short_description: AGI Assistant
11
 
12
  This Space hosts the OpenClaw trading bot (paper-only). The LLM runs in a separate Space that you already have; this repo only contains the bot-side architecture and configs.
13
 
 
 
 
 
 
14
  **Architecture**
15
  - OpenClaw bot Space (this repo) calls an external LLM Space for analysis and signal generation.
16
  - Paper trading via Alpaca API.
 
11
 
12
  This Space hosts the OpenClaw trading bot (paper-only). The LLM runs in a separate Space that you already have; this repo only contains the bot-side architecture and configs.
13
 
14
+ **Hugging Face Space Build Notes**
15
+ - Keep `README.md`, `Dockerfile`, and `app.py` at the repository root used by the Space.
16
+ - For Docker Spaces, the filename must be exactly `Dockerfile` (capital `D`).
17
+ - If you see "missing app file", verify you pushed this folder root (not its parent) to the Space repo.
18
+
19
  **Architecture**
20
  - OpenClaw bot Space (this repo) calls an external LLM Space for analysis and signal generation.
21
  - Paper trading via Alpaca API.
app.py CHANGED
@@ -2,29 +2,45 @@ import gradio as gr
2
  import subprocess
3
  import requests
4
  import os
 
5
 
6
- # Start Clawdbot gateway in background
7
- subprocess.Popen([
8
- "clawdbot",
9
- "gateway",
10
- "--port", "7860",
11
- "--vault-path", "/app/vault"
12
- ])
13
 
14
- def ask_clawdbot(question):
15
- # Call your local Clawdbot API
 
 
 
 
 
 
 
 
 
 
 
 
16
  try:
17
- response = requests.post("http://localhost:7860/ask", json={"query": question})
 
 
 
 
 
18
  return response.json().get("answer", "No answer")
19
  except Exception as e:
20
  return f"Error: {e}"
21
 
22
  iface = gr.Interface(
23
- fn=ask_clawdbot,
24
  inputs="text",
25
  outputs="text",
26
- title="Clawdbot Demo",
27
  description="Ask questions to your notes!"
28
  )
29
 
30
- iface.launch(server_name="0.0.0.0", server_port=7860)
 
2
  import subprocess
3
  import requests
4
  import os
5
+ import shutil
6
 
7
+ HF_PORT = int(os.getenv("PORT", "7860"))
8
+ OPENCLAW_PORT = int(os.getenv("OPENCLAW_PORT", "8787"))
9
+ VAULT_PATH = os.getenv("VAULT_PATH", "/app/vault")
10
+ OPENCLAW_BIN = os.getenv("OPENCLAW_BIN", "openclaw")
11
+ OPENCLAW_BIN = OPENCLAW_BIN if shutil.which(OPENCLAW_BIN) else "clawdbot"
 
 
12
 
13
+ # Run OpenClaw on a different local port than Gradio.
14
+ subprocess.Popen(
15
+ [
16
+ OPENCLAW_BIN,
17
+ "gateway",
18
+ "--port",
19
+ str(OPENCLAW_PORT),
20
+ "--vault-path",
21
+ VAULT_PATH,
22
+ ]
23
+ )
24
+
25
+ def ask_openclaw(question):
26
+ # Call your local OpenClaw API
27
  try:
28
+ response = requests.post(
29
+ f"http://127.0.0.1:{OPENCLAW_PORT}/ask",
30
+ json={"query": question},
31
+ timeout=30,
32
+ )
33
+ response.raise_for_status()
34
  return response.json().get("answer", "No answer")
35
  except Exception as e:
36
  return f"Error: {e}"
37
 
38
  iface = gr.Interface(
39
+ fn=ask_openclaw,
40
  inputs="text",
41
  outputs="text",
42
+ title="OpenClaw Demo",
43
  description="Ask questions to your notes!"
44
  )
45
 
46
+ iface.launch(server_name="0.0.0.0", server_port=HF_PORT)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==4.44.1
2
+ requests==2.32.3