Please start topping up any guinea pig that is not eating properly and losing weight asap with syringe feed. Your prompt home care can be as important in getting a piggy through a rough patch as any medication. Please always switch from weighing weekly to weighing daily at the same time when suspect that something is not quite right; it helps you can developing problems early on.
Complete Syringe Feeding Guide
It is down to your vet to find out what is causing the problem; some things are easily addressable, others aren't. The symptoms you mentioning are too vague to venture any guesses and require a thorough check through.
Facing the mortality of a beloved piggy is always a tough moment; it often comes as quite a shock to the system. It is not something that you want to contemplate when you fall in love with your pets and when you enjoy your cuddles!
However, there inevitably comes the time to say goodbye. The first time and those times you have a special bond are always the worst although it never gets any easier - just how you deal with the grieving afterwards if you have a succession of pets.
The most important thing is that while the length of time a piggy has to live is out of your control, giving it a happy life during the time with you and if necessary a kind end to its life, so you are not left with any more regrets than unavoidable.
Best of luck - I hope that it is something that is failry straight forward and that you can enjoy your piggy's company for a good while yet!