Spaces:
Sleeping
Sleeping
Download app.py from dine24/ITSM_Automation: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/dine24/ITSM_Automation/resolve/main/app.py
- Command line
-
hf download hf://spaces/dine24/ITSM_Automation/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dine24/ITSM_Automation/resolve/main/app.py
1.22 kB
| 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() |