Spaces:
Sleeping
Sleeping
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() |