Skip to content

Commit 4dc9d6e

Browse files
committed
Refactor project generation logic to remove mock LLM response and initialize variables early to prevent reference errors
1 parent 632b42f commit 4dc9d6e

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

app/main.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -498,26 +498,6 @@ async def generate_project_sync(request: ProjectRequest):
498498
Generate a Rust project synchronously and return all files in text format.
499499
This endpoint will wait for the full generation process to complete.
500500
"""
501-
if USE_MOCK_LLM:
502-
# Return mock response
503-
return """[filename: Cargo.toml]
504-
[package]
505-
name = "hello_world"
506-
version = "0.1.0"
507-
edition = "2021"
508-
509-
[dependencies]
510-
511-
[filename: src/main.rs]
512-
fn main() {
513-
println!("Hello, World!");
514-
}
515-
516-
[filename: README.md]
517-
# Hello World
518-
519-
This is a simple Rust program that prints "Hello, World!".
520-
"""
521501
try:
522502
# Create temporary directory for generation
523503
with tempfile.TemporaryDirectory() as temp_dir:
@@ -527,10 +507,14 @@ async def generate_project_sync(request: ProjectRequest):
527507
"message": "Generating project code"
528508
}
529509

510+
# Initialize these variables early to avoid "referenced before assignment" errors
511+
example_text = ""
512+
error_context = {"full_error": ""}
513+
similar_errors = []
514+
530515
# Skip vector search if environment variable is set
531516
skip_vector_search = os.getenv("SKIP_VECTOR_SEARCH", "").lower() == "true"
532517

533-
example_text = ""
534518
if not skip_vector_search:
535519
try:
536520
# Check for similar projects in vector DB

0 commit comments

Comments
 (0)