Spaces:
Running
Running
import gradio as gr | |
def evaluate_code(language, question, code): | |
# Check if code is provided | |
if not code.strip(): | |
return "Error: No code provided. Please enter your solution code." | |
# Dummy evaluation logic based on language. | |
# Replace this with your TinyLlama integration later. | |
if language.lower() == "c": | |
return "C evaluation: The code meets basic criteria but may need improvements." | |
elif language.lower() == "python": | |
return "Python evaluation: Code is correct and follows best practices." | |
elif language.lower() == "java": | |
return "Java evaluation: Good structure, but consider error handling improvements." | |
else: | |
return "Unsupported language. Please select C, Python, or Java." | |
iface = gr.Interface( | |
fn=evaluate_code, | |
inputs=[ | |
gr.Dropdown(choices=["C", "Python", "Java"], label="Language"), | |
gr.Textbox(lines=2, placeholder="Enter the problem question here...", label="Question"), | |
gr.Code(label="Your Code (if any)") # No placeholder property here. | |
], | |
outputs=gr.Textbox(label="Evaluation Result"), | |
title="Code Evaluator", | |
description="Enter a coding question and your solution (if available) to get AI-powered feedback. Supports C, Python, and Java." | |
) | |
if __name__ == "__main__": | |
iface.launch() | |