test / app.py
Luca Latini
refactor enrollment rule creator to accept any non-empty text input fields without validation
7a6eb82
import gradio as gr
def create_enrollment_rule(rule_code: str, rule_name: str, group: str, courses: str) -> dict:
# Just return the inputs as a dictionary without any validation.
# Accept any non-empty text as input. Assume courses is a comma-separated string.
# Convert courses string to a list by splitting on commas (optional).
courses_list = [c.strip() for c in courses.split(",")] if courses.strip() else []
return {
"rule_code": rule_code.strip(),
"rule_name": rule_name.strip(),
"group": group.strip(),
"courses": courses_list
}
demo = gr.Interface(
fn=create_enrollment_rule,
inputs=[
gr.Textbox(label="Rule Code", placeholder="Unique identifier for the rule, e.g. 'rule_001'"),
gr.Textbox(label="Rule Name", placeholder="Descriptive name for the rule, e.g. 'New Hire Onboarding'"),
gr.Textbox(label="Group", placeholder="Group to apply the rule to, e.g. 'Onboarding'"),
gr.Textbox(label="Courses", placeholder="Courses separated by commas, e.g. 'Company Culture and Values, Product Knowledge and Features'")
],
outputs="json",
title="Enrollment Rule Creator",
description="Create an enrollment rule based on the parameters you provide.",
allow_flagging="never"
)
demo.launch()