Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
009288e
1
Parent(s): c70065c
Claude Code: fix brain_minimal import path in app.py
Browse files- Add sys.path setup to import from openclaw package
- Fix get_brain_response() to use proper package import
- Add __init__.py to .openclaw for package structure
- Remove unused BRAIN_MODULE constant
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- .openclaw/__init__.py +3 -0
- app.py +6 -5
.openclaw/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
OpenClaw - HuggingClaw Agent Framework
|
| 3 |
+
"""
|
app.py
CHANGED
|
@@ -8,8 +8,12 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
| 8 |
from pydantic import BaseModel
|
| 9 |
import json
|
| 10 |
import os
|
|
|
|
| 11 |
from datetime import datetime
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
app = FastAPI(title="HuggingClaw - Cain", version="1.0.0")
|
| 14 |
|
| 15 |
# CORS enabled for frontend access
|
|
@@ -24,7 +28,6 @@ app.add_middleware(
|
|
| 24 |
# Paths
|
| 25 |
OPENCLAW_DIR = "/app/.openclaw"
|
| 26 |
STATUS_FILE = f"{OPENCLAW_DIR}/agents/cain_status.json"
|
| 27 |
-
BRAIN_MODULE = f"{OPENCLAW_DIR}/agents/brain_minimal.py"
|
| 28 |
|
| 29 |
|
| 30 |
class ChatMessage(BaseModel):
|
|
@@ -47,10 +50,8 @@ def get_cain_status() -> dict:
|
|
| 47 |
def get_brain_response(message: str) -> str:
|
| 48 |
"""Route message to brain_minimal.py and return response."""
|
| 49 |
try:
|
| 50 |
-
# Import brain module
|
| 51 |
-
import
|
| 52 |
-
sys.path.insert(0, os.path.dirname(BRAIN_MODULE))
|
| 53 |
-
from brain_minimal import BrainMinimal
|
| 54 |
|
| 55 |
# Create brain instance for Cain
|
| 56 |
brain = BrainMinimal(agent_name="cain", legacy_mode=True)
|
|
|
|
| 8 |
from pydantic import BaseModel
|
| 9 |
import json
|
| 10 |
import os
|
| 11 |
+
import sys
|
| 12 |
from datetime import datetime
|
| 13 |
|
| 14 |
+
# Add /app to sys.path for proper package imports
|
| 15 |
+
sys.path.insert(0, "/app")
|
| 16 |
+
|
| 17 |
app = FastAPI(title="HuggingClaw - Cain", version="1.0.0")
|
| 18 |
|
| 19 |
# CORS enabled for frontend access
|
|
|
|
| 28 |
# Paths
|
| 29 |
OPENCLAW_DIR = "/app/.openclaw"
|
| 30 |
STATUS_FILE = f"{OPENCLAW_DIR}/agents/cain_status.json"
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
class ChatMessage(BaseModel):
|
|
|
|
| 50 |
def get_brain_response(message: str) -> str:
|
| 51 |
"""Route message to brain_minimal.py and return response."""
|
| 52 |
try:
|
| 53 |
+
# Import brain module from openclaw package
|
| 54 |
+
from openclaw.agents.brain_minimal import BrainMinimal
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Create brain instance for Cain
|
| 57 |
brain = BrainMinimal(agent_name="cain", legacy_mode=True)
|