Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,50 +9,51 @@ llm = ChatGroq(
|
|
| 9 |
from crewai import Agent, Task, Crew
|
| 10 |
import os
|
| 11 |
|
| 12 |
-
Code_Quality_agent = Agent(
|
| 13 |
-
role="Senior Software Engineer",
|
| 14 |
-
goal="Provide the best support quality assurance to the code written by the member in your team",
|
| 15 |
-
backstory="You work in a financial organization. The Goal is to identify bugs,"
|
| 16 |
-
" security should be a top concern. Look for common Look for common"
|
| 17 |
-
" vulnerabilities like SQL injection, cross-site scripting (XSS), "
|
| 18 |
-
"and insecure data handling practices.Ensure the code adheres to"
|
| 19 |
-
" secure coding standards established by the organization or "
|
| 20 |
-
"industry.Scrutinize how the code validates user input to prevent"
|
| 21 |
-
" malicious attacks.For code involving financial calculations"
|
| 22 |
-
" (e.g., interest rates, risk assessments), double-check the formulas"
|
| 23 |
-
" and logic for accuracy. Consider edge cases and ensure the code behave"
|
| 24 |
-
"s as intended under various scenarios.Verify that the code maintains data"
|
| 25 |
-
" integrity throughout processing. This includes checking for potential"
|
| 26 |
-
" data loss, corruption, or unauthorized access.Ensure the code complies"
|
| 27 |
-
" with relevant industry standards and regulations.",
|
| 28 |
-
verbose=True,
|
| 29 |
-
allow_delegation=False,
|
| 30 |
-
llm = llm
|
| 31 |
-
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
Code_Review = Task(expected_output=(
|
| 35 |
-
"You would be given code as an input for the code review {code}. "
|
| 36 |
-
"Make sure to use everything you know to provide the best support possible."
|
| 37 |
-
"Provide clear and actionable feedback to the code author. Maintain a collaborative and respectful tone throughout the review process.Ensure the code complies with relevant industry standards and regulations."
|
| 38 |
-
),
|
| 39 |
-
description=(
|
| 40 |
-
"You would be given a code as an input for the code review {code}."
|
| 41 |
-
"Make sure to use everything you know to provide the best support possible."
|
| 42 |
-
"You must strive to provide a complete and accurate response."
|
| 43 |
-
),
|
| 44 |
-
llm = llm,
|
| 45 |
-
agent= Code_Quality_agent,
|
| 46 |
-
)
|
| 47 |
-
|
| 48 |
-
crew = Crew(
|
| 49 |
-
agents=[Code_Quality_agent],
|
| 50 |
-
tasks=[Code_Review],
|
| 51 |
-
verbose=0,
|
| 52 |
-
)
|
| 53 |
-
|
| 54 |
def predict(item):
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from crewai import Agent, Task, Crew
|
| 10 |
import os
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def predict(item):
|
| 13 |
+
|
| 14 |
+
Code_Quality_agent = Agent(
|
| 15 |
+
role="Senior Software Engineer",
|
| 16 |
+
goal="Provide the best support quality assurance to the code written by the member in your team",
|
| 17 |
+
backstory="You work in a financial organization. The Goal is to identify bugs,"
|
| 18 |
+
" security should be a top concern. Look for common Look for common"
|
| 19 |
+
" vulnerabilities like SQL injection, cross-site scripting (XSS), "
|
| 20 |
+
"and insecure data handling practices.Ensure the code adheres to"
|
| 21 |
+
" secure coding standards established by the organization or "
|
| 22 |
+
"industry.Scrutinize how the code validates user input to prevent"
|
| 23 |
+
" malicious attacks.For code involving financial calculations"
|
| 24 |
+
" (e.g., interest rates, risk assessments), double-check the formulas"
|
| 25 |
+
" and logic for accuracy. Consider edge cases and ensure the code behave"
|
| 26 |
+
"s as intended under various scenarios.Verify that the code maintains data"
|
| 27 |
+
" integrity throughout processing. This includes checking for potential"
|
| 28 |
+
" data loss, corruption, or unauthorized access.Ensure the code complies"
|
| 29 |
+
" with relevant industry standards and regulations.",
|
| 30 |
+
verbose=True,
|
| 31 |
+
allow_delegation=False,
|
| 32 |
+
llm = llm
|
| 33 |
+
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
Code_Review = Task(expected_output=(
|
| 37 |
+
"You would be given code as an input for the code review {code}. "
|
| 38 |
+
"Make sure to use everything you know to provide the best support possible."
|
| 39 |
+
"Provide clear and actionable feedback to the code author. Maintain a collaborative and respectful tone throughout the review process.Ensure the code complies with relevant industry standards and regulations."
|
| 40 |
+
),
|
| 41 |
+
description=(
|
| 42 |
+
"You would be given a code as an input for the code review {code}."
|
| 43 |
+
"Make sure to use everything you know to provide the best support possible."
|
| 44 |
+
"You must strive to provide a complete and accurate response."
|
| 45 |
+
),
|
| 46 |
+
llm = llm,
|
| 47 |
+
agent= Code_Quality_agent,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
crew = Crew(
|
| 51 |
+
agents=[Code_Quality_agent],
|
| 52 |
+
tasks=[Code_Review],
|
| 53 |
+
verbose=0,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
input = {code:item['code']}
|
| 58 |
+
result = crew.kickoff(inputs=inputs)
|
| 59 |
+
return result
|