tensorgirl/CodeReviewAutomation
0
1from langchain_groq import ChatGroq2 3llm = ChatGroq(4 temperature=0,5 groq_api_key = "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",6 model_name="llama3-8b-8192"7)8 9from crewai import Agent, Task, Crew10import os11 12def 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 = llm33 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 result = crew.kickoff(inputs=item.dict())58 return result59 