Spaces:
Runtime error
Runtime error
File size: 821 Bytes
c9f63d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
# Load the model using CPU (optimized for 8GB RAM)
generator = pipeline("text2text-generation", model="Salesforce/codet5p-220m", device=-1)
def generate_tests(code, instruction):
prompt = f"Input:\n{code}\n\nInstruction:\n{instruction}"
result = generator(prompt)[0]["generated_text"]
return result
gr.Interface(
fn=generate_tests,
inputs=[
gr.Textbox(label="Your Code", lines=10, placeholder="Paste your function here..."),
gr.Textbox(label="Instruction", placeholder="e.g., Generate unit tests using Python unittest.")
],
outputs=gr.Code(language="python"),
title="🧪 Unit Test Generator (Lite)",
description="Paste your function and get test cases using a small AI model. Optimized for 8GB RAM."
).launch()
|