You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+97-91Lines changed: 97 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,6 @@ Or, if you want to run the services directly on your own computer:
25
25
26
26
-**Python 3.8+** 🐍
27
27
-**Rust Compiler and cargo tools** 🦀
28
-
-**Rust Compiler and cargo tools** 🦀
29
28
30
29
---
31
30
@@ -114,21 +113,21 @@ The API provides the following endpoints:
114
113
115
114
#### 📤 Response:
116
115
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.
126
117
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\"] }",
"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
130
130
}
131
-
... ...
132
131
```
133
132
134
133
### 🛠 Compile a Project
@@ -177,7 +176,7 @@ curl -X POST http://localhost:8000/compile \
177
176
curl -X POST http://localhost:8000/compile-and-fix \
"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]",
"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
221
224
}
222
225
```
223
226
@@ -366,8 +369,6 @@ Rust_coder_lfx/
366
369
│ ├── llm_tools.py # Tools for LLM interactions
367
370
│ ├── load_data.py # Data loading utilities
368
371
│ ├── main.py # FastAPI application & endpoints
369
-
│ ├── mcp_server.py # MCP server implementation
370
-
│ ├── mcp_service.py # Model-Compiler-Processor service
371
372
│ ├── mcp_tools.py # MCP-specific tools
372
373
│ ├── prompt_generator.py # LLM prompt generation
373
374
│ ├── response_parser.py # Parse LLM responses into files
@@ -378,15 +379,6 @@ Rust_coder_lfx/
378
379
│ └── project_examples/ # Project examples for vector search
Compilation Pipeline (app/compiler.py): Handles Rust code compilation, error detection, and provides feedback for fixing.
418
410
419
-
####Process Flow
411
+
### Process Flow
420
412
421
413
Project Generation:
422
414
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
428
420
429
421
Error Fixing:
430
422
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
436
428
437
429
---
438
430
439
-
## 📊 Adding to the Vector Database
431
+
## 📊 Enhancing Performance with Vector Search
440
432
441
433
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:
442
434
443
435
### 🔧 Creating Vector Collections
444
436
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:
446
438
447
439
```bash
448
-
# Create project_examples collection with 1536 dimensions (default)
440
+
# Create project_examples collection with 768 dimensions (default)
449
441
curl -X PUT "http://localhost:6333/collections/project_examples" \
450
442
-H "Content-Type: application/json" \
451
443
-d '{
452
444
"vectors": {
453
-
"size": 1536,
445
+
"size": 768,
454
446
"distance": "Cosine"
455
447
}
456
448
}'
457
449
458
-
# Create error_examples collection with 1536 dimensions (default)
450
+
# Create error_examples collection with 768 dimensions (default)
459
451
curl -X PUT "http://localhost:6333/collections/error_examples" \
460
452
-H "Content-Type: application/json" \
461
453
-d '{
462
454
"vectors": {
463
-
"size": 1536,
455
+
"size": 768,
464
456
"distance": "Cosine"
465
457
}
466
458
}'
467
459
```
468
-
Note: If you've configured a different embedding size via ```LLM_EMBED_SIZE``` environment variable, replace 1536 with that value.
469
460
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.
*`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
593
596
- Ensure you have a running Qdrant instance (via Docker Compose or standalone)
594
597
- Create the collections as shown above
595
598
596
599
## 🤝 Contributing
600
+
597
601
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:
598
602
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:
605
611
606
-
The -s flag will automatically add a signed-off-by line to your commit message:
0 commit comments