Skip to content

Commit 620fe9a

Browse files
committed
Fix README formatting and update project examples for clarity
Signed-off-by: Acuspeedster <[email protected]>
2 parents 43091b0 + 02aff0c commit 620fe9a

File tree

1 file changed

+97
-91
lines changed

1 file changed

+97
-91
lines changed

README.md

Lines changed: 97 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Or, if you want to run the services directly on your own computer:
2525

2626
- **Python 3.8+** 🐍
2727
- **Rust Compiler and cargo tools** 🦀
28-
- **Rust Compiler and cargo tools** 🦀
2928

3029
---
3130

@@ -114,21 +113,21 @@ The API provides the following endpoints:
114113

115114
#### 📤 Response:
116115

117-
```
118-
[filename: Cargo.toml]
119-
[package]
120-
name = "calculator"
121-
version = "0.1.0"
122-
edition = "2021"
123-
124-
[dependencies]
125-
... ...
116+
The `combined_text` field contains the flat text output of Rust project files that can be used as input for `/compile` and `/compile-and-fix` API calls.
126117

127-
[filename: src/main.rs]
128-
fn main() {
129-
// Calculator implementation
118+
```
119+
{
120+
"success": true,
121+
"message":"Project generated successfully",
122+
"combined_text":"[filename: Cargo.toml]\n[package]\nname = \"calculator\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nclap = { version = \"4.5\", features = [\"derive\"] }\n\n[filename: src/main.rs]\nuse std::io;\nuse clap::Parser;\n\n#[derive(Parser, Debug)]\n#[command(author, version, about, long_about = None)]\nstruct Args {\n /// The first number\n #[arg(required = true)]\n num1: f64,\n /// Operator (+, -, *, /)\n #[arg(required = true, value_parser = clap::value_parser!(f64))]\n operator: String,\n /// The second number\n #[arg(required = true)]\n num2: f64,\n}\n\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let args = Args::parse();\n\n match args.operator.as_str() {\n \"+\" => {\n println!(\"{}\", args.num1 + args.num2);\n }\n \"-\" => {\n println!(\"{}\", args.num1 - args.num2);\n }\n \"*\" => {\n println!(\"{}\", args.num1 * args.num2);\n }\n \"/\" => {\n if args.num2 == 0.0 {\n eprintln!(\"Error: Cannot divide by zero.\");\n std::process::exit(1);\n }\n println!(\"{}\", args.num1 / args.num2);\n }\n _ => {\n eprintln!(\"Error: Invalid operator. Use +, -, *, or /\");\n std::process::exit(1);\n }\n }\n\n Ok(())\n}\n\n[filename: README.md]\n# Calculator\n\nA simple command-line calculator written in Rust. Supports addition, subtraction, multiplication, and division.\n\n## Usage\n\nRun the program with two numbers and an operator as arguments:\n\n```bash\ncargo run <num1> <operator> <num2>\n```\n\nWhere `<operator>` is one of `+`, `-`, `*`, or `/`.\n\n**Example:**\n\n```bash\ncargo run 5 + 3\n# Output: 8\n\ncargo run 10 / 2\n# Output: 5\n\ncargo run 7 * 4\n# Output: 28\n```\n\n## Error Handling\n\nThe calculator handles division by zero and invalid operator inputs. Error messages are printed to standard error, and the program exits with a non-zero exit code in case of an error.\n\n\n# Build succeeded",
123+
"files":{
124+
"Cargo.toml":"[package]\nname = \"calculator\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nclap = { version = \"4.5\", features = [\"derive\"] }",
125+
"src/main.rs":"use std::io;\nuse clap::Parser;\n\n#[derive(Parser, Debug)]\n#[command(author, version, about, long_about = None)]\nstruct Args {\n /// The first number\n #[arg(required = true)]\n num1: f64,\n /// Operator (+, -, *, /)\n #[arg(required = true, value_parser = clap::value_parser!(f64))]\n operator: String,\n /// The second number\n #[arg(required = true)]\n num2: f64,\n}\n\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let args = Args::parse();\n\n match args.operator.as_str() {\n \"+\" => {\n println!(\"{}\", args.num1 + args.num2);\n }\n \"-\" => {\n println!(\"{}\", args.num1 - args.num2);\n }\n \"*\" => {\n println!(\"{}\", args.num1 * args.num2);\n }\n \"/\" => {\n if args.num2 == 0.0 {\n eprintln!(\"Error: Cannot divide by zero.\");\n std::process::exit(1);\n }\n println!(\"{}\", args.num1 / args.num2);\n }\n _ => {\n eprintln!(\"Error: Invalid operator. Use +, -, *, or /\");\n std::process::exit(1);\n }\n }\n\n Ok(())\n}",
126+
"README.md":"# Calculator\n\nA simple command-line calculator written in Rust. Supports addition, subtraction, multiplication, and division.\n\n## Usage\n\nRun the program with two numbers and an operator as arguments:\n\n```bash\ncargo run <num1> <operator> <num2>\n```\n\nWhere `<operator>` is one of `+`, `-`, `*`, or `/`.\n\n**Example:**\n\n```bash\ncargo run 5 + 3\n# Output: 8\n\ncargo run 10 / 2\n# Output: 5\n\ncargo run 7 * 4\n# Output: 28\n```\n\n## Error Handling\n\nThe calculator handles division by zero and invalid operator inputs. Error messages are printed to standard error, and the program exits with a non-zero exit code in case of an error."
127+
},
128+
"build_output":null,
129+
"build_success":true
130130
}
131-
... ...
132131
```
133132

134133
### 🛠 Compile a Project
@@ -177,7 +176,7 @@ curl -X POST http://localhost:8000/compile \
177176
curl -X POST http://localhost:8000/compile-and-fix \
178177
-H "Content-Type: application/json" \
179178
-d '{
180-
"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis\n}",
179+
"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n print \"Hello, World!\" \n}",
181180
"description": "A simple hello world program",
182181
"max_attempts": 3
183182
}'
@@ -187,37 +186,41 @@ curl -X POST http://localhost:8000/compile-and-fix \
187186

188187
```
189188
{
190-
"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis\n}",
189+
"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n print \"Hello, World!\" \n}",
191190
"description": "A simple hello world program",
192191
"max_attempts": 3
193192
}
194193
```
195194
196195
#### 📤 Response:
197196

197+
The `combined_text` field contains the flat text output of Rust project files that is in the same format as the input `code` field.
198+
198199
```
199200
{
200-
"success": true,
201-
"attempts": [
202-
{
203-
"attempt": 1,
204-
"success": false,
205-
"output": " Compiling hello_world v0.1.0 (/tmp/tmpk_0n65md)\nerror: mismatched closing delimiter: `}`\n --> src/main.rs:2:13\n |\n1 | fn main() {\n | - closing delimiter possibly meant for this\n2 | println!(\"Hello, World!\" // Missing closing parenthesis\n | ^ unclosed delimiter\n3 | }\n | ^ mismatched closing delimiter\n\nerror: could not compile `hello_world` (bin \"hello_world\") due to 1 previous error\n"
206-
},
207-
{
208-
"attempt": 2,
209-
"success": true,
210-
"output": null
211-
}
212-
],
213-
"final_files": {
214-
"Cargo.toml": "[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]",
215-
"src/main.rs": "fn main() {\n println!(\"Hello, World!\");\n}"
216-
},
217-
"build_output": "Build successful",
218-
"run_output": "Hello, World!\n",
219-
"similar_project_used": false,
220-
"combined_text": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}"
201+
"success": true,
202+
"message":"Code fixed and compiled successfully",
203+
"attempts":[
204+
{
205+
"attempt":1,
206+
"success":false,
207+
"output":" Compiling hello_world v0.1.0 (/tmp/tmpbgeg4x_e)\nerror: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `\"Hello, World!\"`\n --> src/main.rs:2:11\n |\n2 | print \"Hello, World!\" \n | ^^^^^^^^^^^^^^^ expected one of 8 possible tokens\n\nerror: could not compile `hello_world` (bin \"hello_world\") due to 1 previous error\n"
208+
},
209+
{
210+
"attempt":2,
211+
"success":true,
212+
"output":null
213+
}
214+
],
215+
"combined_text":"[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}\n\n[filename: README.md]\n# Hello World\n\nThis is a simple \"Hello, World!\" program in Rust. It prints the message \"Hello, World!\" to the console.\n\nTo run it:\n\n1. Make sure you have Rust installed ([https://www.rust-lang.org/](https://www.rust-lang.org/)).\n2. Save the code as `src/main.rs`.\n3. Run `cargo run` in the terminal from the project directory.",
216+
"files":{
217+
"Cargo.toml":"[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]",
218+
"src/main.rs":"fn main() {\n println!(\"Hello, World!\");\n}",
219+
"README.md":"# Hello World\n\nThis is a simple \"Hello, World!\" program in Rust. It prints the message \"Hello, World!\" to the console.\n\nTo run it:\n\n1. Make sure you have Rust installed ([https://www.rust-lang.org/](https://www.rust-lang.org/)).\n2. Save the code as `src/main.rs`.\n3. Run `cargo run` in the terminal from the project directory."
220+
},
221+
"build_output":"Build successful",
222+
"run_output":"Hello, World!\n",
223+
"build_success":true
221224
}
222225
```
223226

@@ -366,8 +369,6 @@ Rust_coder_lfx/
366369
│ ├── llm_tools.py # Tools for LLM interactions
367370
│ ├── load_data.py # Data loading utilities
368371
│ ├── main.py # FastAPI application & endpoints
369-
│ ├── mcp_server.py # MCP server implementation
370-
│ ├── mcp_service.py # Model-Compiler-Processor service
371372
│ ├── mcp_tools.py # MCP-specific tools
372373
│ ├── prompt_generator.py # LLM prompt generation
373374
│ ├── response_parser.py # Parse LLM responses into files
@@ -378,15 +379,6 @@ Rust_coder_lfx/
378379
│ └── project_examples/ # Project examples for vector search
379380
├── docker-compose.yml # Docker Compose configuration
380381
├── Dockerfile # Docker configuration
381-
├── examples/ # Example scripts for using the API
382-
│ ├── compile_endpoint.txt # Example for compile endpoint
383-
│ ├── compile_and_fix_endpoint.txt # Example for compile-and-fix endpoint
384-
│ ├── mcp_client_example.py # Example MCP client usage
385-
│ └── run_mcp_server.py # Example for running MCP server
386-
├── templates/ # Prompt templates
387-
│ └── project_prompts.txt # Templates for project generation
388-
├── mcp-proxy-config.json # MCP proxy configuration
389-
├── parse_and_save_qna.py # Q&A parsing utility
390382
├── requirements.txt # Python dependencies
391383
└── .env # Environment variables
392384
```
@@ -404,7 +396,7 @@ Compilation Feedback Loop: Automatically compiles, detects errors, and fixes the
404396

405397
File Parsing: Converts LLM responses into project files with `response_parser.py`.
406398

407-
#### Architecture
399+
### Architecture
408400

409401
REST API Interface (app/main.py): FastAPI application exposing HTTP endpoints for project generation, compilation, and error fixing.
410402

@@ -416,60 +408,64 @@ LLM Integration (app/llm_client.py): Communicates with LLM APIs (like Gaia nodes
416408

417409
Compilation Pipeline (app/compiler.py): Handles Rust code compilation, error detection, and provides feedback for fixing.
418410

419-
#### Process Flow
411+
### Process Flow
420412

421413
Project Generation:
422414

423-
User provides a description and requirements
424-
System creates a prompt using templates (templates/project_prompts.txt)
425-
LLM generates a complete Rust project
426-
Response is parsed into individual files (app/response_parser.py)
427-
Project is compiled to verify correctness
415+
* User provides a description and requirements
416+
* System creates a prompt using templates
417+
* LLM generates a complete Rust project
418+
* Response is parsed into individual files (`app/response_parser.py`)
419+
* Project is compiled to verify correctness
428420

429421
Error Fixing:
430422

431-
System attempts to compile the provided code
432-
If errors occur, they're extracted and analyzed
433-
Vector search may find similar past errors
434-
LLM receives the errors and original code to generate fixes
435-
Process repeats until successful or max attempts reached
423+
* System attempts to compile the provided code
424+
* If errors occur, they're extracted and analyzed
425+
* Vector search may find similar past errors
426+
* LLM receives the errors and original code to generate fixes
427+
* Process repeats until successful or max attempts reached
436428

437429
---
438430

439-
## 📊 Adding to the Vector Database
431+
## 📊 Enhancing Performance with Vector Search
440432

441433
The system uses vector embeddings to find similar projects and error examples, which helps improve code generation quality. Here's how to add your own examples:
442434

443435
### 🔧 Creating Vector Collections
444436

445-
First, you need to create the necessary collections in Qdrant using these curl commands:
437+
First, you need to create the necessary collections in Qdrant using these `curl` commands:
446438

447439
```bash
448-
# Create project_examples collection with 1536 dimensions (default)
440+
# Create project_examples collection with 768 dimensions (default)
449441
curl -X PUT "http://localhost:6333/collections/project_examples" \
450442
-H "Content-Type: application/json" \
451443
-d '{
452444
"vectors": {
453-
"size": 1536,
445+
"size": 768,
454446
"distance": "Cosine"
455447
}
456448
}'
457449

458-
# Create error_examples collection with 1536 dimensions (default)
450+
# Create error_examples collection with 768 dimensions (default)
459451
curl -X PUT "http://localhost:6333/collections/error_examples" \
460452
-H "Content-Type: application/json" \
461453
-d '{
462454
"vectors": {
463-
"size": 1536,
455+
"size": 768,
464456
"distance": "Cosine"
465457
}
466458
}'
467459
```
468-
Note: If you've configured a different embedding size via ```LLM_EMBED_SIZE``` environment variable, replace 1536 with that value.
469460

470-
### Method 1: Using Python API Directly
461+
> Note: If you've configured a different embedding size via `LLM_EMBED_SIZE` environment variable, replace 768 with that value.
462+
463+
### 🗂️ Adding Data to Vector Collections
464+
465+
#### Method 1: Using Python API Directly
466+
467+
For Project Examples
471468

472-
#### For Project Examples
473469
```python
474470
from app.llm_client import LlamaEdgeClient
475471
from app.vector_store import QdrantStore
@@ -503,6 +499,7 @@ vector_store.add_item(
503499
```
504500

505501
For Error Examples:
502+
506503
```python
507504
from app.llm_client import LlamaEdgeClient
508505
from app.vector_store import QdrantStore
@@ -542,9 +539,11 @@ pip install qdrant-client openai
542539

543540
Place JSON files in the appropriate directories:
544541

545-
Project examples: ```project_examples```
546-
Error examples: ```error_examples```
547-
Format for project examples (with optional project_files field):
542+
* Project examples: `data/project_examples`
543+
* Error examples: `data/error_examples`
544+
545+
Format for project examples (with optional `project_files` field):
546+
548547
```json
549548
{
550549
"query": "Description of the project",
@@ -555,6 +554,7 @@ Format for project examples (with optional project_files field):
555554
}
556555
}
557556
```
557+
558558
Format for error examples:
559559
```json
560560
{
@@ -564,46 +564,51 @@ Format for error examples:
564564
"example": "// Code example showing the fix (optional)"
565565
}
566566
```
567+
567568
Then run the data loading script:
569+
568570
```
569571
python -c "from app.load_data import load_project_examples, load_error_examples; load_project_examples(); load_error_examples()"
570572
```
571573

572-
### Method 3: Using the ```parse_and_save_qna.py``` Script
574+
#### Method 3: Using the `parse_and_save_qna.py` Script
575+
573576
For bulk importing from a Q&A format text file:
574577

575-
Place your Q&A pairs in a text file with format similar to ```QnA_pair.txt```
576-
Modify the ```parse_and_save_qna.py``` script to point to your file
578+
Place your Q&A pairs in a text file with format similar to `QnA_pair.txt`
579+
Modify the `parse_and_save_qna.py` script to point to your file.
577580
Run the script:
581+
578582
```
579583
python parse_and_save_qna.py
580584
```
581585

582586
## ⚙️ Environment Variables for Vector Search
583-
The SKIP_VECTOR_SEARCH environment variable controls whether the system uses vector search:
584587

585-
```SKIP_VECTOR_SEARCH```=true - Disables vector search functionality
586-
```SKIP_VECTOR_SEARCH```=false (or not set) - Enables vector search
587-
In your current .env file, you have:
588-
```
589-
SKIP_VECTOR_SEARCH=true
590-
```
591-
This means vector search is currently disabled. To enable it:
592-
- Change this value to false or remove the line completely
588+
The `SKIP_VECTOR_SEARCH` environment variable controls whether the system uses vector search:
589+
590+
* `SKIP_VECTOR_SEARCH=true` - Disables vector search functionality
591+
* `SKIP_VECTOR_SEARCH=false` (or not set) - Enables vector search
592+
593+
By default, vector search is disabled. To enable it:
594+
595+
- Change to `SKIP_VECTOR_SEARCH=false` in your `.env` file
593596
- Ensure you have a running Qdrant instance (via Docker Compose or standalone)
594597
- Create the collections as shown above
595598

596599
## 🤝 Contributing
600+
597601
Contributions are welcome! This project uses the Developer Certificate of Origin (DCO) to certify that contributors have the right to submit their code. Follow these steps:
598602

599-
Fork the repository
600-
Create your feature branch (git checkout -b feature/amazing-feature)
601-
Make your changes
602-
Commit your changes with a sign-off (git commit -s -m 'Add some amazing feature')
603-
Push to the branch (git push origin feature/amazing-feature)
604-
Open a Pull Request
603+
* Fork the repository
604+
* Create your feature branch `git checkout -b feature/amazing-feature`
605+
* Make your changes
606+
* Commit your changes with a sign-off `git commit -s -m 'Add some amazing feature'`
607+
* Push to the branch `git push origin feature/amazing-feature`
608+
* Open a Pull Request
609+
610+
The `-s` flag will automatically add a signed-off-by line to your commit message:
605611

606-
The -s flag will automatically add a signed-off-by line to your commit message:
607612
```
608613
Signed-off-by: Your Name <[email protected]>
609614
```
@@ -613,6 +618,7 @@ This certifies that you wrote or have the right to submit the code you're contri
613618
---
614619

615620
## 📜 License
621+
616622
Licensed under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
617623

618624

0 commit comments

Comments
 (0)