Spaces:
Configuration error
Configuration error
Download tools/code_inspector.py from Zoro-147/MCP-RAG-PDF: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/Zoro-147/MCP-RAG-PDF/resolve/main/tools/code_inspector.py
- Command line
-
hf download hf://spaces/Zoro-147/MCP-RAG-PDF/tools/code_inspector.py
-
curl -L -o code_inspector.py https://huggingface.co/spaces/Zoro-147/MCP-RAG-PDF/resolve/main/tools/code_inspector.py
620 Bytes
| import google.generativeai as genai | |
| def check_code(prompt, model): | |
| code_prefix = "check code:" | |
| if code_prefix in prompt.lower(): | |
| code = prompt.lower().split(code_prefix, 1)[1].strip() | |
| else: | |
| return "Please provide the Python code after 'check code:'." | |
| try: | |
| response = model.generate_content(f"Analyze the following Python code for syntax errors, logical errors, and best practice violations. Provide detailed explanations and suggest fixes:\n\n```python\n{code}\n```") | |
| return response.text | |
| except Exception as e: | |
| return f"Error checking code with Gemini: {e}" |