File size: 1,304 Bytes
f32ded3
81f7e58
7a6eb82
 
 
 
 
 
 
 
 
 
 
d2ece60
81f7e58
7a6eb82
81f7e58
7a6eb82
 
 
 
81f7e58
 
 
7a6eb82
81f7e58
 
 
 
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
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()