# openclaw-python
**Repository Path**: x55/openclaw-python
## Basic Information
- **Project Name**: openclaw-python
- **Description**: Python implementation of OpenClaw - Personal AI Assistant
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-03-29
- **Last Updated**: 2026-03-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 🦞 OpenClaw Python - Personal AI Assistant
[English](#english) | [中文](#中文)
---
## English Version
A Python implementation of OpenClaw - your personal AI assistant that runs on your own devices.
## Features
- **Modern Web Interface** - Beautiful, dark-themed chat interface with real-time streaming
- **WebSocket Gateway** - Fast, real-time communication
- **AI Agent Integration** - Support for OpenAI models (GPT-4, GPT-3.5, etc.)
- **Session Management** - Persistent chat sessions with SQLite database
- **Command Line Interface** - Powerful CLI for managing and chatting
- **Configurable** - Customizable settings and configurations
## Quick Start
### Prerequisites
- Python 3.10 or higher
- OpenAI API key
### Installation
1. Navigate to the project directory:
```bash
cd python-openclaw
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Set your OpenAI API key:
```bash
export OPENAI_API_KEY="your-api-key-here"
```
Or create a `.env` file:
```
OPENCLAW_OPENAI_API_KEY=your-api-key-here
```
### Starting the Gateway
Start the web interface:
```bash
python -m openclaw.main
```
Or use the CLI:
```bash
openclaw gateway
```
Then open your browser and navigate to: `http://localhost:18789`
### Using the CLI
The OpenClaw Python CLI provides powerful commands:
```bash
# Check status
openclaw status
# Create a new session
openclaw session-new --name "My Chat"
# List all sessions
openclaw session-list
# Chat with an existing session
openclaw chat "Hello, how are you?" --stream
# Quick chat (creates a new session automatically)
openclaw quick-chat "Explain Python to me" --stream
# Configuration
openclaw config-set agent.model "gpt-4"
openclaw config-get agent.model
```
## Project Structure
```
python-openclaw/
├── openclaw/
│ ├── __init__.py # Package initialization
│ ├── main.py # FastAPI application entry point
│ ├── cli.py # CLI commands
│ ├── core/ # Core types and models
│ │ ├── __init__.py
│ │ └── types.py # Pydantic models
│ ├── config/ # Configuration management
│ │ ├── __init__.py
│ │ └── settings.py # Settings and config manager
│ ├── db/ # Database models and storage
│ │ ├── __init__.py
│ │ ├── models.py # SQLAlchemy models
│ │ └── store.py # Session storage
│ ├── agent/ # AI Agent and LLM integration
│ │ ├── __init__.py
│ │ └── agent.py # LLM providers and agent
│ ├── gateway/ # Gateway API and WebSocket
│ │ ├── __init__.py
│ │ ├── api.py # REST API routes
│ │ └── websocket.py # WebSocket manager
│ ├── static/ # Static files
│ │ ├── css/
│ │ │ └── style.css # Modern dark theme
│ │ └── js/
│ │ └── app.js # Frontend logic
│ └── templates/ # HTML templates
│ └── index.html # Main chat interface
├── pyproject.toml # Poetry configuration
├── requirements.txt # Pip requirements
└── README.md # This file
```
## Configuration
OpenClaw Python can be configured via environment variables or a config file.
### Environment Variables
```bash
OPENCLAW_GATEWAY_HOST=127.0.0.1
OPENCLAW_GATEWAY_PORT=18789
OPENCLAW_GATEWAY_DEBUG=true
OPENCLAW_OPENAI_API_KEY=your-api-key
OPENCLAW_DEFAULT_MODEL=gpt-4
```
### Config File
The config file is stored at `~/.openclaw-python/config.json`
## Development
### Using Poetry (Optional)
```bash
# Install dependencies
poetry install
# Run the gateway
poetry run python -m openclaw.main
# Or run via CLI
poetry run openclaw gateway
```
### Project Stack
- **FastAPI** - Modern, fast web framework
- **SQLAlchemy** - Async ORM for database
- **Pydantic** - Data validation and settings management
- **OpenAI Python** - LLM integration
- **Rich** - Beautiful CLI output
- **Click** - Command line interface creation
## API Endpoints
### REST API
- `GET /` - Web interface
- `GET /health` - Health check
- `GET /api/status` - Gateway status
- `GET /api/sessions` - List sessions
- `POST /api/sessions` - Create session
- `GET /api/sessions/{id}` - Get session
- `PUT /api/sessions/{id}` - Update session
- `DELETE /api/sessions/{id}` - Delete session
- `GET /api/sessions/{id}/messages` - Get messages
- `POST /api/sessions/{id}/messages` - Send message
### WebSocket
- `WS /api/ws` - Real-time communication
## License
MIT License - same as the original OpenClaw project.
## Acknowledgments
This is a Python reimplementation of the amazing [OpenClaw](https://github.com/openclaw/openclaw) project by Peter Steinberger and the OpenClaw community. 🦞
---
## 中文版
# 🦞 OpenClaw Python - 个人AI助手
OpenClaw的Python实现 - 运行在你自己设备上的个人AI助手。
## 功能特性
- **现代化Web界面** - 美观的深色主题聊天界面,支持实时流式响应
- **WebSocket网关** - 快速、实时的通信
- **AI代理集成** - 支持OpenAI模型(GPT-4、GPT-3.5等)
- **会话管理** - 使用SQLite数据库持久化聊天会话
- **命令行界面** - 强大的CLI工具,用于管理和聊天
- **可配置** - 可自定义的设置和配置
## 快速开始
### 前置要求
- Python 3.10或更高版本
- OpenAI API密钥
### 安装
1. 进入项目目录:
```bash
cd python-openclaw
```
2. 安装依赖:
```bash
pip install -r requirements.txt
```
3. 设置OpenAI API密钥:
```bash
export OPENAI_API_KEY="你的-api-key-在这里"
```
或创建 `.env` 文件:
```
OPENCLAW_OPENAI_API_KEY=你的-api-key-在这里
```
### 启动网关
启动Web界面:
```bash
python -m openclaw.main
```
或使用CLI:
```bash
openclaw gateway
```
然后打开浏览器并访问:`http://localhost:18789`
### 使用CLI
OpenClaw Python CLI提供了强大的命令:
```bash
# 查看状态
openclaw status
# 创建新会话
openclaw session-new --name "我的聊天"
# 列出所有会话
openclaw session-list
# 与现有会话聊天
openclaw chat <会话-id> "你好,你好吗?" --stream
# 快速聊天(自动创建新会话)
openclaw quick-chat "给我解释一下Python" --stream
# 配置管理
openclaw config-set agent.model "gpt-4"
openclaw config-get agent.model
```
## 项目结构
```
python-openclaw/
├── openclaw/
│ ├── __init__.py # 包初始化
│ ├── main.py # FastAPI应用入口点
│ ├── cli.py # CLI命令
│ ├── core/ # 核心类型和模型
│ │ ├── __init__.py
│ │ └── types.py # Pydantic模型
│ ├── config/ # 配置管理
│ │ ├── __init__.py
│ │ └── settings.py # 设置和配置管理器
│ ├── db/ # 数据库模型和存储
│ │ ├── __init__.py
│ │ ├── models.py # SQLAlchemy模型
│ │ └── store.py # 会话存储
│ ├── agent/ # AI代理和LLM集成
│ │ ├── __init__.py
│ │ └── agent.py # LLM提供商和代理
│ ├── gateway/ # 网关API和WebSocket
│ │ ├── __init__.py
│ │ ├── api.py # REST API路由
│ │ └── websocket.py # WebSocket管理器
│ ├── static/ # 静态文件
│ │ ├── css/
│ │ │ └── style.css # 现代深色主题
│ │ └── js/
│ │ └── app.js # 前端逻辑
│ └── templates/ # HTML模板
│ └── index.html # 主聊天界面
├── pyproject.toml # Poetry配置
├── requirements.txt # Pip依赖
└── README.md # 本文件
```
## 配置
OpenClaw Python可以通过环境变量或配置文件进行配置。
### 环境变量
```bash
OPENCLAW_GATEWAY_HOST=127.0.0.1
OPENCLAW_GATEWAY_PORT=18789
OPENCLAW_GATEWAY_DEBUG=true
OPENCLAW_OPENAI_API_KEY=你的-api-key
OPENCLAW_DEFAULT_MODEL=gpt-4
```
### 配置文件
配置文件存储在 `~/.openclaw-python/config.json`
## 开发
### 使用Poetry(可选)
```bash
# 安装依赖
poetry install
# 运行网关
poetry run python -m openclaw.main
# 或通过CLI运行
poetry run openclaw gateway
```
### 项目技术栈
- **FastAPI** - 现代化、快速的Web框架
- **SQLAlchemy** - 用于数据库的异步ORM
- **Pydantic** - 数据验证和设置管理
- **OpenAI Python** - LLM集成
- **Rich** - 美观的CLI输出
- **Click** - 命令行界面创建
## API端点
### REST API
- `GET /` - Web界面
- `GET /health` - 健康检查
- `GET /api/status` - 网关状态
- `GET /api/sessions` - 列出会话
- `POST /api/sessions` - 创建会话
- `GET /api/sessions/{id}` - 获取会话
- `PUT /api/sessions/{id}` - 更新会话
- `DELETE /api/sessions/{id}` - 删除会话
- `GET /api/sessions/{id}/messages` - 获取消息
- `POST /api/sessions/{id}/messages` - 发送消息
### WebSocket
- `WS /api/ws` - 实时通信
## 许可证
MIT许可证 - 与原始OpenClaw项目相同。
## 致谢
这是由Peter Steinberger和OpenClaw社区创建的惊人[OpenClaw](https://github.com/openclaw/openclaw)项目的Python重新实现。🦞