Closed ogallagher closed 4 months ago
If we deploy the server to Google Cloud run, will we be able to deploy a credentials file, or set environment variables? I assume yes.
Local server demo with logging to show it can fetch the gemini api key from a .env
file.
.../gemini_noname_server % python main.py
DEBUG gemini-noname-server: attached cli log handler [@init_logging #30]
DEBUG gemini-noname-server: attached file log handler writing to logs/2024-06-15T16-49-40.740671.log [@init_logging #41]
DEBUG gemini-noname-server: get static credentials from dot-env [@get_credentials #52]
INFO gemini-noname-server: env_is_local=True [@main #81]
INFO gemini-noname-server: test gemini API credentials with a simple gemini prompt [@main #90]
INFO gemini-client: logged into gemini api [@login #23]
INFO gemini-noname-server: prompt gemini - tell me a one sentence joke about a tiger's favorite music [@main #98]
DEBUG gemini-client: received reply from gemini [@prompt #38]
A tiger's favorite music is anything with a good "roar" quality.
INFO gemini-noname-server: end main [@main #104]
Decided to also do a more interesting example with a longer reply, and using streaming.
.../gemini_noname_server % python main.py
DEBUG gemini-noname-server: attached cli log handler [@init_logging #30]
DEBUG gemini-noname-server: attached file log handler writing to logs/2024-06-15T17-05-24.612940.log [@init_logging #41]
DEBUG gemini-noname-server: get static credentials from dot-env [@get_credentials #52]
INFO gemini-noname-server: env_is_local=True [@main #81]
INFO gemini-noname-server: test gemini API credentials with a simple gemini prompt [@main #90]
INFO gemini-client: logged into gemini api [@login #23]
INFO gemini-noname-server: prompt gemini - tell me 15 different one sentence jokes about a tiger's favorite music, each on a separate line [@main #99]
DEBUG gemini-client: received reply from gemini [@prompt #38]
DEBUG gemini-client: fetch gemini reply part-0 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-1 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-2 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-3 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-4 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-5 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-6 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-7 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-8 [@prompt #42]
DEBUG gemini-client: fetch gemini reply part-9 [@prompt #42]
1. A tiger's favorite music? Anything with a good "roar"chestra!
2. A tiger's favorite band? The "Stripes" of course!
3. What kind of music does a tiger like? "Jungle" beats!
4. A tiger's favorite genre? "Prowl" and roll!
5. A tiger's favorite singer? "Roar"y the Lion!
6. A tiger's favorite instrument? A "claw"net!
7. What's a tiger's favorite song? "Roar" by Katy Perry!
8. A tiger's favorite musical? "The Lion King" of course!
9. What kind of music does a tiger listen to on the way to work? "Paw-p" music!
10. A tiger's favorite music app? "Spot-ify"!
11. A tiger's favorite dance move? The "tiger" tango!
12. A tiger's favorite karaoke song? "I'm a Little Teapot" (but he roars the lyrics!)
13. A tiger's favorite music festival? The "Roar-chella"!
14. A tiger's favorite band to listen to while stalking prey? The "Stealth"y Hunters!
15. What kind of music does a tiger listen to in the jungle? "Jungle" music, duh!
INFO gemini-noname-server: end main [@main #105]
I prefer not to close this until it's proven that the frontend can access these gemini app credentials by deploying the server #3 and connecting the frontend #14.
I was able to send a request to /apikey/gemini
from the frontend to the backend server deployed in google cloud run today. See https://github.com/hoanghm/Proact/issues/12#issuecomment-2184038778
primary branch =
feature/backend-gemini
Regardless of whether we prompt Gemini from the server or webpage, the app credentials will probably limit direct access to the server (ex. server generates API tokens).