File size: 1,219 Bytes
eb50036
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
import gradio as gr
import pandas as pd
import pickle

# Load models
with open("xgb_issue_type_model.pkl", "rb") as f:
    issue_model = pickle.load(f)

with open("xgb_priority_model.pkl", "rb") as f:
    priority_model = pickle.load(f)

# Prediction function
def predict_ticket(issue_title, description):
    df = pd.DataFrame([[issue_title, description]], columns=["Issue", "Description"])
    df["combined"] = df["Issue"] + " " + df["Description"]

    # Vectorization logic if needed (adjust as per model input)
    issue_pred = issue_model.predict(df["combined"])[0]
    priority_pred = priority_model.predict(df["combined"])[0]

    return f"Issue Type: {issue_pred}", f"Priority: {priority_pred}"

# Gradio Interface
iface = gr.Interface(
    fn=predict_ticket,
    inputs=[
        gr.Textbox(lines=1, label="Issue Title"),
        gr.Textbox(lines=3, label="Description")
    ],
    outputs=[
        gr.Text(label="Predicted Issue Type"),
        gr.Text(label="Predicted Priority")
    ],
    title="ITSM Ticket Predictor",
    description="Enter the issue and description to get predictions for issue type and priority."
)

if __name__ == "__main__":
    iface.launch()