ayushraj2349-2 commited on
Commit
fb0b25a
·
verified ·
1 Parent(s): 4881da1

Delete app,py

Browse files
Files changed (1) hide show
  1. app,py +0 -36
app,py DELETED
@@ -1,36 +0,0 @@
1
- from transformers import AutoModelForCausalLM, AutoTokenizer
2
- import gradio as gr
3
-
4
- # Load Hugging Face's CodeGen model
5
- model_name = "Salesforce/codegen-2B-multi"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
8
-
9
- # Function to review Python code
10
- def review_code(code_snippet):
11
- inputs = tokenizer(code_snippet, return_tensors="pt")
12
- outputs = model.generate(**inputs, max_length=512)
13
- reviewed_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
- return reviewed_code
15
-
16
- # Function to handle UI logic
17
- def check_code(input_code):
18
- reviewed_code = review_code(input_code)
19
- return input_code, reviewed_code, reviewed_code # Return all for UI & download
20
-
21
- # Gradio UI with Side-by-Side Comparison & Download Option
22
- interface = gr.Interface(
23
- fn=check_code,
24
- inputs=gr.Textbox(label="Enter Python Code"),
25
- outputs=[
26
- gr.Textbox(label="Original Code", interactive=False), # Left side
27
- gr.Textbox(label="Reviewed Code", interactive=False), # Right side
28
- gr.File(label="Download Reviewed Code") # Download button
29
- ],
30
- title="AI Code Reviewer",
31
- description="📌 Enter Python code and get a reviewed version. Download the reviewed code as a file.",
32
- allow_flagging="never"
33
- )
34
-
35
- # Launch the app
36
- interface.launch(share=True) # share=True allows public access