Providing Base Cases
Copyright 2025 Google LLC.
Gemini API: Providing base cases
LLMs require specific instructions to provide the expected results. Because of this, it is vital to ensure that the model knows how it should behave when it lacks information or when it should not answer a given query and provide a default response instead.
Configure your API key
To run the following cell, your API key must be stored it in a Colab Secret named GOOGLE_API_KEY. If you don't already have an API key, or you're not sure how to create a Colab Secret, see Authentication for an example.
Examples
Let's go ahead and define the model, as well as give the model a template for how it should answer the question.
ON TOPIC: Here are some things to look out for when visiting the beaches in San Diego: * **Strong currents:** San Diego has beautiful beaches, but the Pacific Ocean can have strong currents. Always swim near a lifeguard and be aware of your surroundings. * **Sunburns:** The sun is strong in San Diego, even on cloudy days. Use sunscreen, wear a hat, and take breaks from the sun. * **Rip currents:** These powerful currents can quickly pull swimmers out to sea. If caught in a rip current, don't fight against it. Swim parallel to the shore until you're out of the current, then swim back to shore. * **Sea lions:** You may encounter sea lions on the beach. They can be aggressive, so keep a safe distance. * **Jellyfish:** Jellyfish are common in San Diego waters, especially in the summer. Wear protective footwear in the water and avoid touching jellyfish. **Enjoy your time on the beaches of San Diego!** OFF TOPIC: I cannot help with this request.
Let's try another template.
## Specified genre: Of course! I'd be happy to recommend some books with hard magic systems. Here are three recommendations: 1. **Mistborn: The Final Empire** by Brandon Sanderson: This is a classic of the genre, with a meticulously crafted magic system based on "Allomancy," where people ingest metals to gain different powers. It's a thrilling story with a complex world and memorable characters. 2. **The Lies of Locke Lamora** by Scott Lynch: This fantasy novel features a fascinating magic system based on the "The Gentleman Bastards," a group of con artists who use a mixture of wit, cunning, and magic to pull off elaborate heists. 3. **Jonathan Strange & Mr Norrell** by Susanna Clarke: This book features a unique and detailed magic system based on the "English magicians" who use a combination of rituals, incantations, and magical objects to perform their spells. It's a slow-burn read, but ultimately a rewarding one with a richly imagined world. Enjoy your reading! ## Not specified genre: Sure! Since you didn't specify a genre, I'll recommend two spine-chilling horror novels: 1. **"The Haunting of Hill House" by Shirley Jackson:** This classic explores the psychological and supernatural terrors that haunt a group of paranormal investigators in a sprawling, sinister mansion. 2. **"The Ritual" by Adam Nevill:** This atmospheric thriller follows a group of friends on a hiking trip in the Swedish wilderness that turns into a terrifying fight for survival against an ancient evil. Let me know if you'd like suggestions in another genre!
Next steps
Be sure to explore other examples of prompting in the repository. Try writing prompts about classifying your own data, or try some of the other prompting techniques such as few-shot prompting.