Spaces:
Sleeping
Sleeping
File size: 1,328 Bytes
5900202 200227d 2b461c6 200227d 2b461c6 200227d 2b461c6 200227d 5900202 fc0d268 5900202 200227d 2b461c6 200227d 5900202 fc0d268 200227d 5900202 2b461c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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()
|