Save LLM response for debugging
(self, provider: str, prompt: str, response: str)
| 517 | return "Mock LLM response for testing purposes." |
| 518 | |
| 519 | def _save_debug_response(self, provider: str, prompt: str, response: str): |
| 520 | """Save LLM response for debugging""" |
| 521 | try: |
| 522 | import hashlib |
| 523 | from datetime import datetime |
| 524 | |
| 525 | # Create a hash of the prompt for filename |
| 526 | prompt_hash = hashlib.md5(prompt.encode()).hexdigest()[:8] |
| 527 | timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") |
| 528 | filename = f"{provider}_{timestamp}_{prompt_hash}.json" |
| 529 | |
| 530 | debug_data = { |
| 531 | "timestamp": datetime.now().isoformat(), |
| 532 | "provider": provider, |
| 533 | "prompt": prompt[:500] + "..." if len(prompt) > 500 else prompt, |
| 534 | "response": response, |
| 535 | "full_prompt_length": len(prompt), |
| 536 | } |
| 537 | |
| 538 | debug_file = Path(self.raw_responses_dir) / filename |
| 539 | with open(debug_file, "w", encoding="utf-8") as f: |
| 540 | json.dump(debug_data, f, indent=2, ensure_ascii=False) |
| 541 | |
| 542 | except Exception as e: |
| 543 | self.logger.warning(f"Failed to save debug response: {e}") |
| 544 | |
| 545 | def get_all_repo_files(self, repo_path: Path) -> List[Path]: |
| 546 | """Recursively get all supported files in a repository""" |