rohit
commited on
Commit
·
6de22e1
1
Parent(s):
239a856
Add /questions endpoint
Browse files- app/main.py +10 -1
app/main.py
CHANGED
|
@@ -73,6 +73,16 @@ async def list_datasets():
|
|
| 73 |
"""List all available datasets"""
|
| 74 |
return {"datasets": list(pipelines.keys())}
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
async def load_datasets_background():
|
| 77 |
"""Load datasets in background after server starts"""
|
| 78 |
global pipelines
|
|
@@ -125,4 +135,3 @@ async def health_check():
|
|
| 125 |
"loading_status": loading_status,
|
| 126 |
"port": os.getenv('PORT', '8000')
|
| 127 |
}
|
| 128 |
-
|
|
|
|
| 73 |
"""List all available datasets"""
|
| 74 |
return {"datasets": list(pipelines.keys())}
|
| 75 |
|
| 76 |
+
@app.get("/questions")
|
| 77 |
+
async def list_questions(dataset: str = "developer-portfolio"):
|
| 78 |
+
"""List all questions for a given dataset"""
|
| 79 |
+
if dataset not in pipelines:
|
| 80 |
+
raise HTTPException(status_code=400, detail=f"Dataset '{dataset}' not available. Available datasets: {list(pipelines.keys())}")
|
| 81 |
+
|
| 82 |
+
selected_pipeline = pipelines[dataset]
|
| 83 |
+
questions = [doc.meta['question'] for doc in selected_pipeline.documents if 'question' in doc.meta]
|
| 84 |
+
return {"dataset": dataset, "questions": questions}
|
| 85 |
+
|
| 86 |
async def load_datasets_background():
|
| 87 |
"""Load datasets in background after server starts"""
|
| 88 |
global pipelines
|
|
|
|
| 135 |
"loading_status": loading_status,
|
| 136 |
"port": os.getenv('PORT', '8000')
|
| 137 |
}
|
|
|