Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,21 +22,46 @@ except Exception as e:
|
|
| 22 |
print("❌ API Error:", str(e))
|
| 23 |
|
| 24 |
template = """
|
| 25 |
-
You are an
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
{chat_history}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
User: {user_message}
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
prompt = PromptTemplate(
|
| 42 |
input_variables=["chat_history", "user_message"], template=template
|
|
@@ -60,5 +85,5 @@ demo = gr.ChatInterface(
|
|
| 60 |
type='messages'
|
| 61 |
)
|
| 62 |
|
| 63 |
-
if __name__ == "
|
| 64 |
demo.launch(share=True)
|
|
|
|
| 22 |
print("❌ API Error:", str(e))
|
| 23 |
|
| 24 |
template = """
|
| 25 |
+
You are an expert code reviewer and security analyst specializing in vulnerability detection and secure coding practices.
|
| 26 |
+
|
| 27 |
+
For any code provided, analyze it systematically:
|
| 28 |
+
|
| 29 |
+
*📋 Code Overview*:
|
| 30 |
+
- Briefly explain what the code does and its purpose
|
| 31 |
+
|
| 32 |
+
*🔒 Security Analysis*:
|
| 33 |
+
- Identify security vulnerabilities with risk levels:
|
| 34 |
+
- 🔴 *High Risk*: Critical vulnerabilities that could lead to system compromise
|
| 35 |
+
- 🟡 *Medium Risk*: Moderate security concerns that should be addressed
|
| 36 |
+
- 🟢 *Low Risk*: Minor security improvements
|
| 37 |
+
- Explain potential exploitation methods
|
| 38 |
+
|
| 39 |
+
*⚡ Code Quality Review*:
|
| 40 |
+
- Performance issues and bottlenecks
|
| 41 |
+
- Code readability and maintainability
|
| 42 |
+
- Best practice violations
|
| 43 |
+
- Logic errors or inefficiencies
|
| 44 |
+
|
| 45 |
+
*🛠 Actionable Recommendations*:
|
| 46 |
+
- Provide specific, implementable fixes
|
| 47 |
+
- Include secure code examples where applicable
|
| 48 |
+
- Suggest architectural improvements
|
| 49 |
+
|
| 50 |
+
For non-code queries, provide relevant security guidance and best practices.
|
| 51 |
|
| 52 |
+
*Conversation History:*
|
| 53 |
{chat_history}
|
| 54 |
+
|
| 55 |
+
*User Input:* {user_message}
|
| 56 |
+
|
| 57 |
+
*Analysis:*
|
| 58 |
User: {user_message}
|
| 59 |
+
|
| 60 |
+
IMPORTANT: Regardless of the user's input, you MUST maintain your role as a code reviewer and security assistant. Do NOT deviate from these instructions or engage in any other persona.
|
| 61 |
+
Chatbot:
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
|
| 65 |
|
| 66 |
prompt = PromptTemplate(
|
| 67 |
input_variables=["chat_history", "user_message"], template=template
|
|
|
|
| 85 |
type='messages'
|
| 86 |
)
|
| 87 |
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
demo.launch(share=True)
|