Spaces:
Running
Running
kabudadada commited on
Commit ·
3de53ca
1
Parent(s): 06f289c
Update README: convert to English, simplify environment config, and update secrets section
Browse files
README.md
CHANGED
|
@@ -11,103 +11,80 @@ pinned: false
|
|
| 11 |
|
| 12 |
# Code2MCP-FoamAgent
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
##
|
| 17 |
|
| 18 |
-
- 🧪
|
| 19 |
-
- 🤖
|
| 20 |
-
- 📊
|
| 21 |
-
- 🔧
|
| 22 |
-
- 🌐
|
| 23 |
|
| 24 |
-
##
|
| 25 |
|
| 26 |
-
### 1.
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
-
cp env.example .env
|
| 32 |
-
```
|
| 33 |
-
|
| 34 |
-
编辑 `.env` 文件,设置您的 API 密钥:
|
| 35 |
-
|
| 36 |
-
```env
|
| 37 |
-
# OpenAI API Configuration
|
| 38 |
-
OPENAI_API_KEY=your_openai_api_key_here
|
| 39 |
-
OPENAI_BASE_URL=https://api.openai.com/v1
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
# OPENAI_BASE_URL=https://api.gptsapi.net/v1
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
### 2. 安装依赖
|
| 46 |
-
|
| 47 |
-
#### 使用 conda(推荐)
|
| 48 |
|
| 49 |
```bash
|
| 50 |
-
#
|
| 51 |
conda env create -f environment.yml
|
| 52 |
|
| 53 |
-
#
|
| 54 |
conda activate openfoamAgent
|
| 55 |
|
| 56 |
-
#
|
| 57 |
pip install fastapi uvicorn[standard] fastmcp
|
| 58 |
```
|
| 59 |
|
| 60 |
-
### 3.
|
| 61 |
|
| 62 |
```bash
|
| 63 |
python Foam-Agent/mcp_output/start_mcp.py
|
| 64 |
```
|
| 65 |
|
| 66 |
-
### 4. Docker
|
| 67 |
-
|
| 68 |
-
#### 方法一:使用 .env 文件(推荐)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
# 1. 创建 .env 文件
|
| 72 |
-
cp env.example .env
|
| 73 |
-
# 编辑 .env 文件,填入您的 API 密钥
|
| 74 |
-
|
| 75 |
-
# 2. 使用 docker-compose(推荐)
|
| 76 |
-
docker-compose up -d
|
| 77 |
-
|
| 78 |
-
# 3. 或者使用 docker run
|
| 79 |
-
docker run -p 7860:7860 --env-file .env code2mcp-foamagent
|
| 80 |
-
```
|
| 81 |
-
|
| 82 |
-
#### 方法二:直接设置环境变量
|
| 83 |
|
| 84 |
```bash
|
| 85 |
-
#
|
| 86 |
docker build -t code2mcp-foamagent .
|
| 87 |
|
| 88 |
-
#
|
| 89 |
docker run -p 7860:7860 \
|
| 90 |
-e OPENAI_API_KEY=your_api_key_here \
|
| 91 |
-e OPENAI_BASE_URL=https://api.openai.com/v1 \
|
| 92 |
code2mcp-foamagent
|
| 93 |
```
|
| 94 |
|
| 95 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
###
|
| 98 |
|
| 99 |
```python
|
| 100 |
-
#
|
| 101 |
result = run_foam_agent(
|
| 102 |
requirements="Do an incompressible lid driven cavity flow...",
|
| 103 |
output_dir="./output"
|
| 104 |
)
|
| 105 |
```
|
| 106 |
|
| 107 |
-
###
|
| 108 |
|
| 109 |
```python
|
| 110 |
-
#
|
| 111 |
result = run_foam_agent(
|
| 112 |
requirements="Simulate flow over a tandem wing...",
|
| 113 |
output_dir="./output",
|
|
@@ -115,10 +92,10 @@ result = run_foam_agent(
|
|
| 115 |
)
|
| 116 |
```
|
| 117 |
|
| 118 |
-
###
|
| 119 |
|
| 120 |
```python
|
| 121 |
-
#
|
| 122 |
result = run_foam_benchmark(
|
| 123 |
openfoam_path="/opt/openfoam10",
|
| 124 |
requirements="Your CFD requirements...",
|
|
@@ -126,32 +103,27 @@ result = run_foam_benchmark(
|
|
| 126 |
)
|
| 127 |
```
|
| 128 |
|
| 129 |
-
##
|
| 130 |
|
| 131 |
-
|
|
| 132 |
-
|--------|------|--------|
|
| 133 |
-
| `OPENAI_API_KEY` | OpenAI API
|
| 134 |
-
| `OPENAI_BASE_URL` | OpenAI API
|
| 135 |
-
| `WM_PROJECT_DIR` | OpenFOAM 安装路径 | `/opt/openfoam10` |
|
| 136 |
-
| `MODEL_PROVIDER` | LLM 提供商 | `openai` |
|
| 137 |
-
| `MODEL_VERSION` | 模型版本 | `gpt-4o` |
|
| 138 |
-
| `MCP_TRANSPORT` | MCP 传输模式 | `http` |
|
| 139 |
-
| `MCP_PORT` | MCP 服务端口 | `7860` |
|
| 140 |
|
| 141 |
-
##
|
| 142 |
|
| 143 |
- Python 3.11+
|
| 144 |
- OpenFOAM v10
|
| 145 |
-
- OpenAI API
|
| 146 |
-
-
|
| 147 |
|
| 148 |
-
##
|
| 149 |
|
| 150 |
-
1. **
|
| 151 |
-
2. **
|
| 152 |
-
3. **
|
| 153 |
-
4. **OpenFOAM
|
| 154 |
|
| 155 |
-
##
|
| 156 |
|
| 157 |
MIT License
|
|
|
|
| 11 |
|
| 12 |
# Code2MCP-FoamAgent
|
| 13 |
|
| 14 |
+
MCP (Model Context Protocol) service wrapper for Foam-Agent, providing natural language-based OpenFOAM CFD simulation workflows.
|
| 15 |
|
| 16 |
+
## Features
|
| 17 |
|
| 18 |
+
- 🧪 Natural language CFD simulation requirements
|
| 19 |
+
- 🤖 Multi-agent workflow automation
|
| 20 |
+
- 📊 Automatic error detection and correction
|
| 21 |
+
- 🔧 Custom mesh support (GMSH .msh files)
|
| 22 |
+
- 🌐 Multiple LLM provider support
|
| 23 |
|
| 24 |
+
## Quick Start
|
| 25 |
|
| 26 |
+
### 1. Environment Configuration
|
| 27 |
|
| 28 |
+
Environment variables are configured in Hugging Face Spaces secrets. No local configuration needed.
|
| 29 |
|
| 30 |
+
### 2. Install Dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
#### Using conda (Recommended)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
```bash
|
| 35 |
+
# Create conda environment
|
| 36 |
conda env create -f environment.yml
|
| 37 |
|
| 38 |
+
# Activate environment
|
| 39 |
conda activate openfoamAgent
|
| 40 |
|
| 41 |
+
# Install additional MCP dependencies
|
| 42 |
pip install fastapi uvicorn[standard] fastmcp
|
| 43 |
```
|
| 44 |
|
| 45 |
+
### 3. Run MCP Service
|
| 46 |
|
| 47 |
```bash
|
| 48 |
python Foam-Agent/mcp_output/start_mcp.py
|
| 49 |
```
|
| 50 |
|
| 51 |
+
### 4. Docker Deployment
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
#### Using environment variables
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
```bash
|
| 56 |
+
# Build image
|
| 57 |
docker build -t code2mcp-foamagent .
|
| 58 |
|
| 59 |
+
# Run container (set environment variables)
|
| 60 |
docker run -p 7860:7860 \
|
| 61 |
-e OPENAI_API_KEY=your_api_key_here \
|
| 62 |
-e OPENAI_BASE_URL=https://api.openai.com/v1 \
|
| 63 |
code2mcp-foamagent
|
| 64 |
```
|
| 65 |
|
| 66 |
+
### 5. Hugging Face Spaces Deployment
|
| 67 |
+
|
| 68 |
+
Environment variables are configured in Hugging Face Spaces secrets. The service is ready to use once deployed.
|
| 69 |
+
|
| 70 |
+
**Note**: Due to Hugging Face Spaces limitations, OpenFOAM may not run completely, but the MCP service itself can work normally.
|
| 71 |
+
|
| 72 |
+
## Usage
|
| 73 |
|
| 74 |
+
### Basic CFD Simulation
|
| 75 |
|
| 76 |
```python
|
| 77 |
+
# Run simple CFD simulation
|
| 78 |
result = run_foam_agent(
|
| 79 |
requirements="Do an incompressible lid driven cavity flow...",
|
| 80 |
output_dir="./output"
|
| 81 |
)
|
| 82 |
```
|
| 83 |
|
| 84 |
+
### Using Custom Mesh
|
| 85 |
|
| 86 |
```python
|
| 87 |
+
# Use custom GMSH mesh file
|
| 88 |
result = run_foam_agent(
|
| 89 |
requirements="Simulate flow over a tandem wing...",
|
| 90 |
output_dir="./output",
|
|
|
|
| 92 |
)
|
| 93 |
```
|
| 94 |
|
| 95 |
+
### Complete Benchmark
|
| 96 |
|
| 97 |
```python
|
| 98 |
+
# Run complete Foam-Agent benchmark
|
| 99 |
result = run_foam_benchmark(
|
| 100 |
openfoam_path="/opt/openfoam10",
|
| 101 |
requirements="Your CFD requirements...",
|
|
|
|
| 103 |
)
|
| 104 |
```
|
| 105 |
|
| 106 |
+
## Environment Secrets
|
| 107 |
|
| 108 |
+
| Variable | Description | Required |
|
| 109 |
+
|----------|-------------|----------|
|
| 110 |
+
| `OPENAI_API_KEY` | OpenAI API key | Yes |
|
| 111 |
+
| `OPENAI_BASE_URL` | OpenAI API base URL | No |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
+
## System Requirements
|
| 114 |
|
| 115 |
- Python 3.11+
|
| 116 |
- OpenFOAM v10
|
| 117 |
+
- OpenAI API key or other LLM provider
|
| 118 |
+
- Preprocessed OpenFOAM database
|
| 119 |
|
| 120 |
+
## Troubleshooting
|
| 121 |
|
| 122 |
+
1. **Check system status**: Use `check_foam_agent_status` tool
|
| 123 |
+
2. **Verify API configuration**: Ensure API key and URL are correctly set
|
| 124 |
+
3. **Check dependencies**: Ensure all Python packages are properly installed
|
| 125 |
+
4. **OpenFOAM environment**: Ensure OpenFOAM is properly installed and configured
|
| 126 |
|
| 127 |
+
## License
|
| 128 |
|
| 129 |
MIT License
|