GaneshNaiknavare's picture
Update app.py
3329b7a verified
import gradio as gr
import sys
import os
# Add the parent directory to sys.path to import from backend
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from multi_layer_operation_predictor.operation_predictor import get_operation_definition
def predict_operation(input_text, language):
"""
Predicts the operation based on user input and selected language
"""
result = get_operation_definition(input_text, language.lower())
if not result:
return "No matching operation found"
return result
# Create the Gradio interface
iface = gr.Interface(
fn=predict_operation,
inputs=[
gr.Textbox(label="Enter your operation description"),
gr.Dropdown(
choices=["python", "javascript", "typescript", "php", "java"],
label="Select Programming Language"
)
],
outputs=gr.Textbox(label="Operation Definition"),
title="Multi-Layer Operation Predictor",
description="Enter a description of the operation you're looking for and select the programming language. The model will find the closest matching operation.",
examples=[
["def addition(a,b)", "python"],
["addition(a,b)", "javascript"],
]
)
if __name__ == "__main__":
iface.launch()