Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import gradio as gr
|
|
3 |
import json
|
4 |
from fastapi import FastAPI, Request
|
5 |
from fastapi.responses import JSONResponse
|
6 |
-
from gradio.routes import mount_gradio_app
|
7 |
|
8 |
from retriever import get_relevant_passages
|
9 |
from reranker import rerank
|
@@ -95,14 +94,19 @@ async def recommend_api(request: Request):
|
|
95 |
except Exception as e:
|
96 |
return JSONResponse(content={"error": str(e)}, status_code=500)
|
97 |
|
98 |
-
# --- Gradio UI ---
|
|
|
|
|
|
|
99 |
iface = gr.Interface(
|
100 |
-
fn=
|
101 |
inputs=gr.Textbox(label="Enter Job Description", lines=4),
|
102 |
outputs="json",
|
103 |
title="SHL Assessment Recommender",
|
104 |
description="Paste a job description to get the most relevant SHL assessments."
|
105 |
)
|
106 |
|
107 |
-
#
|
108 |
-
|
|
|
|
|
|
3 |
import json
|
4 |
from fastapi import FastAPI, Request
|
5 |
from fastapi.responses import JSONResponse
|
|
|
6 |
|
7 |
from retriever import get_relevant_passages
|
8 |
from reranker import rerank
|
|
|
94 |
except Exception as e:
|
95 |
return JSONResponse(content={"error": str(e)}, status_code=500)
|
96 |
|
97 |
+
# --- Gradio UI --- (integrating Gradio directly with FastAPI)
|
98 |
+
def gradio_interface(query):
|
99 |
+
return recommend(query)
|
100 |
+
|
101 |
iface = gr.Interface(
|
102 |
+
fn=gradio_interface,
|
103 |
inputs=gr.Textbox(label="Enter Job Description", lines=4),
|
104 |
outputs="json",
|
105 |
title="SHL Assessment Recommender",
|
106 |
description="Paste a job description to get the most relevant SHL assessments."
|
107 |
)
|
108 |
|
109 |
+
# Make sure to launch Gradio on the root path for HuggingFace Spaces
|
110 |
+
@app.on_event("startup")
|
111 |
+
async def startup():
|
112 |
+
iface.launch(inline=True, server_name="0.0.0.0", server_port=7860)
|