Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -376,4 +376,23 @@ async def get_annotators():
|
|
376 |
# Convert the Counter to a list of dictionaries
|
377 |
annotators = [{"annotator_id": annotator_id, "prompt_count": count} for annotator_id, count in annotator_counts.items()]
|
378 |
|
379 |
-
return JSONResponse(content=annotators)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
# Convert the Counter to a list of dictionaries
|
377 |
annotators = [{"annotator_id": annotator_id, "prompt_count": count} for annotator_id, count in annotator_counts.items()]
|
378 |
|
379 |
+
return JSONResponse(content=annotators)
|
380 |
+
@app.get("/prompt_by_annotator/{story_id}/{annotator_id}")
|
381 |
+
async def get_prompt_by_annotator(story_id: str, annotator_id: str):
|
382 |
+
print(f"Fetching prompt for story_id: {story_id}, annotator_id: {annotator_id}")
|
383 |
+
prompt = prompts_collection.find_one({"story_id": story_id, "annotator_id": int(annotator_id)})
|
384 |
+
print(f"Prompt retrieved: {prompt}") # Debugging output
|
385 |
+
if prompt:
|
386 |
+
return {"story_id": story_id, "prompt": prompt.get("prompt", "")}
|
387 |
+
else:
|
388 |
+
return {"story_id": story_id, "prompt": ""}
|
389 |
+
|
390 |
+
@app.get("/summary_by_annotator/{story_id}/{annotator_id}")
|
391 |
+
async def get_summary_by_annotator(story_id: str, annotator_id: str):
|
392 |
+
print(f"Fetching summary for story_id: {story_id}, annotator_id: {annotator_id}")
|
393 |
+
summary = summaries_collection.find_one({"story_id": story_id, "annotator_id": int(annotator_id)})
|
394 |
+
print(f"Summary retrieved: {summary}") # Debugging output
|
395 |
+
if summary:
|
396 |
+
return {"story_id": story_id, "summary": summary.get("summary", "")}
|
397 |
+
else:
|
398 |
+
return {"story_id": story_id, "summary": ""}
|