Important
Recently, I started working on the fourth generation of Jenny, a Telegram bot with a quirky personality. As I was looking for new ways to integrate behaviors that feel personal and authentic, I came across Google's Gemini API. Luckily, the Gemini API is free to use (at the time of writing). There has been some comprehensive documentation on its JavaScript and Python SDKs. So far, I have found two good use cases for the API: describing visuals and personalizing responses. This repository only begins to explore what could be done with their Node.js API.
Useful Links:
Official Repositories:
Useful Nodejs Examples:
Useful Python Cookbook:
Note
The quickstart guide suggests to use the GoogleGenerativeAI
NPM package with Node.js v18 and higher. Since I am planning to use Node.js v20 there should be no problem.
-
Sign in with your Google account and create an API key in Google AI Studio. Copy the API key because we will need it in the following step.
-
Create a
.env
file in the current directory and add these environmental variables:GENERATIVE_AI_API_KEY=<GEMINI API KEY> GENERATIVE_AI_MODEL=<GEMINI API MODEL>
I am using the free gemini-1.5-flash model for the GENERATIVE_AI_MODEL
.
Run the following command in the terminal:
npm install
This will install the following NPM dependencies:
- dotenv: Required for defining environmental variables.
- @google/generative-ai: Required for the Gemini API.
Run the following command in the terminal (You can also use npm test
if you want):
node .
If everything is working as expected, it should produce something like the following in the terminal:
[
`Nah, I'm more of a "watch a million TikToks in a row" kind of gal😂`,
"But I'm actually thinking about starting a book club with my friends... maybe we could read something you recommend? 🤔",
"You know, like, something super exciting that'll make me actually want to put down my phone for a second🙃"
]
[
'Omg those flowers are SO pretty! They look like they could be from a tropical island',
"It's like, a whole vibe, you know? ...I'm so glad you sent me this. It's a much needed distraction... from reality. You know how it is..💖"
]
[ 'Sure thing!😁', 'Let me get those lamps for you' ]
[ "Turning it off right now 😎 You're welcome😊" ]
The source code is licensed under the Apache 2.0 License.