Skip to content

Commit da32ac1

Browse files
committed
Implement LLM-based error fixing in _fix_errors_with_llm method
1 parent 4ebe7ce commit da32ac1

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

app/mcp_service.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,37 @@ def _store_successful_fix(self, original_code: str, fixed_files: Dict[str, str],
312312
}
313313
)
314314
except Exception as e:
315-
print(f"Failed to store error fix in vector DB: {e}")
315+
print(f"Failed to store error fix in vector DB: {e}")
316+
317+
def _fix_errors_with_llm(self, error_output, current_files, description, project_reference=None):
318+
"""Use LLM to fix compilation errors"""
319+
if not self.llm_client:
320+
print("Warning: No LLM client available, returning original files")
321+
return current_files
322+
323+
try:
324+
# Create prompt for error fixing
325+
prompt = self.prompt_generator.generate_error_fix_prompt(
326+
error_output=error_output,
327+
current_files=current_files,
328+
description=description,
329+
project_reference=project_reference
330+
)
331+
332+
# Get LLM response
333+
response = self.llm_client.generate_text(
334+
prompt=prompt,
335+
system_message="You are an expert Rust developer fixing compilation errors.",
336+
max_tokens=4000,
337+
temperature=0.2 # Lower temperature for more precise fixes
338+
)
339+
340+
# Parse response into fixed files
341+
fixed_files = self.parser.parse_response(response)
342+
343+
# Return the fixed files
344+
return fixed_files
345+
except Exception as e:
346+
print(f"Error fixing with LLM: {str(e)}")
347+
# Return original files if LLM fails
348+
return current_files

0 commit comments

Comments
 (0)