kasoumya/JavaCodeReviewAssistant
0
1import gradio as gr2from transformers import pipeline3 4# Load instruction model5generator = pipeline(6 "text2text-generation"7)8 9 10def review_java_code(code):11 12 if not code.strip():13 return "Please paste Java code."14 15 prompt = f"""16You are a Senior Java Architect.17 18Review the following Java code.19 20Provide:21 221. Summary232. Bugs243. Performance Issues254. Security Issues265. Java Best Practices276. Rating out of 1028 29Java Code:30 31{code}32"""33 34 result = generator(35 prompt,36 max_new_tokens=300,37 do_sample=False38 )39 40 return result[0]["generated_text"]41 42 43demo = gr.Interface(44 fn=review_java_code,45 inputs=gr.Code(46 language="java",47 label="Paste Java Code"48 ),49 outputs=gr.Textbox(50 label="AI Review",51 lines=2052 ),53 title="☕ Java Code Review Assistant",54 description="""55Paste any Java code and receive an AI-generated review covering:56 57• Bugs58• Performance59• Security60• Best Practices61• Overall Rating62"""63)64 65if __name__ == "__main__":66 demo.launch()