Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +21 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the model using CPU (optimized for 8GB RAM)
|
| 5 |
+
generator = pipeline("text2text-generation", model="Salesforce/codet5p-220m", device=-1)
|
| 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 Generator (Lite)",
|
| 20 |
+
description="Paste your function and get test cases using a small AI model. Optimized for 8GB RAM."
|
| 21 |
+
).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|