Pranav1908 commited on
Commit
964e707
1 Parent(s): 1cad5e9

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +58 -0
  2. main.py +17 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_groq import ChatGroq
2
+
3
+ llm = ChatGroq(
4
+ temperature=0,
5
+ groq_api_key = "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",
6
+ model_name="llama3-8b-8192"
7
+ )
8
+
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=2,
52
+ )
53
+
54
+ def predict(code):
55
+ input = {code:code}
56
+ result = crew.kickoff(inputs=inputs)
57
+ return result
58
+
main.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from app import predict
3
+ import os
4
+ from huggingface_hub import login
5
+
6
+ os.environ['HF_HOME'] = '/hug/cache/'
7
+ os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
8
+
9
+ app = FastAPI()
10
+
11
+ @app.get("/")
12
+ async def root():
13
+ return {"Code Review Automation":"Version 1.0 'First Draft'"}
14
+
15
+ @app.post("/AutomateReview/")
16
+ def predict(input_json: str):
17
+ return predict(input_json)