Spaces:
Runtime error
Runtime error
File size: 1,054 Bytes
2680bc9 b32bf91 2680bc9 | 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 59 60 61 62 63 64 65 66 | import gradio as gr
from transformers import pipeline
# Load instruction model
generator = pipeline(
"text2text-generation"
)
def review_java_code(code):
if not code.strip():
return "Please paste Java code."
prompt = f"""
You are a Senior Java Architect.
Review the following Java code.
Provide:
1. Summary
2. Bugs
3. Performance Issues
4. Security Issues
5. Java Best Practices
6. Rating out of 10
Java Code:
{code}
"""
result = generator(
prompt,
max_new_tokens=300,
do_sample=False
)
return result[0]["generated_text"]
demo = gr.Interface(
fn=review_java_code,
inputs=gr.Code(
language="java",
label="Paste Java Code"
),
outputs=gr.Textbox(
label="AI Review",
lines=20
),
title="☕ Java Code Review Assistant",
description="""
Paste any Java code and receive an AI-generated review covering:
• Bugs
• Performance
• Security
• Best Practices
• Overall Rating
"""
)
if __name__ == "__main__":
demo.launch() |