Have you already searched on your Mac for your Photos Library?
If not, try this:
- Launch Photos while holding down the options key ⌥ firmly.
- Release ⌥ when the dialog to select a library appears. If the dialog is showing more than one library try them all in turn.
macOS 14 Sonoma is more restrictive about the location of a Photos Library than the previous system version. While the previous system version let you store your library in folders, that are not save and where the library could get badly damaged, Photos on Sonoma will not even try to open a library in an unsafe location. If your Photos Library is not in your Pictures folder but in a folder on iCloud Drive (for example Documents or or the Desktop) or on a remote mounted volume in your local network, move it back to a local folder, before you try to open it in Photos.
As your photos are all still in iCloud, you could simply create a new empty Photos Library and let it sync with iCloud. This will be the fastest way to get your photos back.
- Launch Photos while holding down the options key ⌥ firmly.
- Release ⌥ when the dialog to select a library appears.
- New use the option to create a New library in your Pictures folder.
- When the new library opens with an empty window, go to the Photos > Settings > General and click "Use as System Photos Library"
- Now go to the Photos > Settings > iCloud and enable iCloud Photos and "Optimize Mac Storage" (you can change this back later if space permits).
- Wait for the photos from iCloud to sync back.
You may want to create the new library on an external drive as described here, if you do not have enough free storage on the internal drive: Move your Photos library to save space on your Mac - Apple Support
But use only an external drive with a wired connection, not a NAS and not a drive used for Time Machine backups.