File size: 2,341 Bytes
547c66d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddb8c24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from langchain_groq import ChatGroq

llm = ChatGroq(
    temperature=0,
    groq_api_key = "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",
    model_name="llama3-8b-8192"
)

from crewai import Agent, Task, Crew
import os

Code_Quality_agent = Agent(
    role="Senior Software Engineer",
    goal="Provide the best support quality assurance to the code written by the member in your team",
    backstory="You work in a financial organization. The Goal is to identify bugs,"
    " security should be a top concern. Look for common Look for common"
    " vulnerabilities like SQL injection, cross-site scripting (XSS), "
    "and insecure data handling practices.Ensure the code adheres to"
    " secure coding standards established by the organization or "
    "industry.Scrutinize how the code validates user input to prevent"
    " malicious attacks.For code involving financial calculations"
    " (e.g., interest rates, risk assessments), double-check the formulas"
    " and logic for accuracy. Consider edge cases and ensure the code behave"
    "s as intended under various scenarios.Verify that the code maintains data"
    " integrity throughout processing. This includes checking for potential"
    " data loss, corruption, or unauthorized access.Ensure the code complies"
    " with relevant industry standards and regulations.",
    verbose=True,
    allow_delegation=False,
    llm = llm
    
)

Code_Review = Task(expected_output=(
        "You would be given code as an input for the code review {code}. "
        "Make sure to use everything you know to provide the best support possible."
        "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."
    ),
    description=(
        "You would be given a code as an input for the code review {code}."
        "Make sure to use everything you know to provide the best support possible."
        "You must strive to provide a complete and accurate response."
    ),
    llm = llm,
    agent= Code_Quality_agent,
)

crew = Crew(
    agents=[Code_Quality_agent],
    tasks=[Code_Review],
    verbose=2,
)

def predict(item):
	input = {code:item['code']}
	result = crew.kickoff(inputs=inputs)
	return result