Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -8,7 +8,8 @@ except:
|
|
| 8 |
# Fallback if that specific model isn't on free tier right now
|
| 9 |
client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
|
| 10 |
|
| 11 |
-
def analyze_code(code, language):
|
|
|
|
| 12 |
system_prompt = f"""You are a Senior Application Security Engineer and Expert Code Reviewer.
|
| 13 |
Analyze the following {language} code.
|
| 14 |
1. Identify any security vulnerabilities (OWASP Top 10, Injection, etc.).
|
|
@@ -22,7 +23,9 @@ Structure your response in Markdown with clear headings for 'Vulnerabilities', '
|
|
| 22 |
{"role": "user", "content": f"```{language}\n{code}\n```"}
|
| 23 |
]
|
| 24 |
try:
|
|
|
|
| 25 |
response = client.chat_completion(messages, max_tokens=1500)
|
|
|
|
| 26 |
return response.choices[0].message.content
|
| 27 |
except Exception as e:
|
| 28 |
return f"⚠️ **Error connecting to Analysis Engine**: {str(e)}"
|
|
|
|
| 8 |
# Fallback if that specific model isn't on free tier right now
|
| 9 |
client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
|
| 10 |
|
| 11 |
+
def analyze_code(code, language, progress=gr.Progress()):
|
| 12 |
+
progress(0.2, desc="Initializing Security Audit...")
|
| 13 |
system_prompt = f"""You are a Senior Application Security Engineer and Expert Code Reviewer.
|
| 14 |
Analyze the following {language} code.
|
| 15 |
1. Identify any security vulnerabilities (OWASP Top 10, Injection, etc.).
|
|
|
|
| 23 |
{"role": "user", "content": f"```{language}\n{code}\n```"}
|
| 24 |
]
|
| 25 |
try:
|
| 26 |
+
progress(0.4, desc="Analyzing codebase and generating report (This takes a few seconds)...")
|
| 27 |
response = client.chat_completion(messages, max_tokens=1500)
|
| 28 |
+
progress(1.0, desc="Audit Complete!")
|
| 29 |
return response.choices[0].message.content
|
| 30 |
except Exception as e:
|
| 31 |
return f"⚠️ **Error connecting to Analysis Engine**: {str(e)}"
|