| 94 | |
| 95 | @router.get('/picture/{file_id}', summary=f"{PLACEHOLDER_PREFIX}assistant_picture_api", description=f"{PLACEHOLDER_PREFIX}assistant_picture_api") |
| 96 | async def picture(file_id: str = Path(description="file_id")): |
| 97 | file_path = SQLBotFileUtils.get_file_path(file_id=file_id) |
| 98 | if not os.path.exists(file_path): |
| 99 | raise HTTPException(status_code=404, detail="File not found") |
| 100 | |
| 101 | if file_id.lower().endswith(".svg"): |
| 102 | media_type = "image/svg+xml" |
| 103 | else: |
| 104 | media_type = "image/jpeg" |
| 105 | |
| 106 | def iterfile(): |
| 107 | with open(file_path, mode="rb") as f: |
| 108 | yield from f |
| 109 | |
| 110 | return StreamingResponse(iterfile(), media_type=media_type) |
| 111 | |
| 112 | |
| 113 | @router.patch('/ui', summary=f"{PLACEHOLDER_PREFIX}assistant_ui_api", description=f"{PLACEHOLDER_PREFIX}assistant_ui_api") |