mannchauhan commited on
Commit
3d94df2
·
verified ·
1 Parent(s): d7d6324

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +21 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a lightweight test-case generation model
5
+ generator = pipeline("text2text-generation", model="Salesforce/codet5p-770m", max_length=512)
6
+
7
+ def generate_tests(code, instruction):
8
+ prompt = f"Input:\n{code}\n\nInstruction:\n{instruction}"
9
+ result = generator(prompt)[0]["generated_text"]
10
+ return result
11
+
12
+ gr.Interface(
13
+ fn=generate_tests,
14
+ inputs=[
15
+ gr.Textbox(label="Your Code", lines=10, placeholder="Paste your function here..."),
16
+ gr.Textbox(label="Instruction", placeholder="e.g., Generate unit tests using Python unittest.")
17
+ ],
18
+ outputs=gr.Code(language="python"),
19
+ title="🧪 Unit Test & Test Case Generator",
20
+ description="🔧 Paste your function and get auto-generated test cases using a free model from Hugging Face."
21
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch