Build your Pair Programming with Gemini Google 🤖

Lesly Zerna
4 min readMar 30, 2024

--

Hello world! Welcome to this blog! Let’s explore the capabilities of GEMINI to have it as our very own PAIR programming. 👩‍💻 In this blog, we’ll see some examples, using some Google tools such as: Gemini (before BARD), Google AI Studio and coding using Gemini API.

Let’s start first with Gemini concept 🤔

BARD says: (Feb 2024)

GEMINI: This is a multimodal generative AI model developed by Google DeepMind. It’s capable of understanding and processing various inputs like text, images, video, or code, and can generate different creative outputs depending on the prompt.

GEMINI Pro: This is an API (Application Programming Interface) that developers can use to access and leverage the capabilities of the GEMINI model within their own applications.

🤖🤖🤖🤖🤖🤖🤖🤖🤖

Gemini says: (March 2024)

I’m Gemini, the best way to directly access Google AI. I’m trained on large amounts of publicly available data and I can communicate and generate human-like text in response to a wide range of questions. Let me know if you’d like to learn more, or just try me out and see what I can do for you.

More details on Gemini on its release, in this edition of #TheBatch (December 2023).

Interaction, at first glance, would be along the chatbot, check the website https://gemini.google.com/ and start asking! 🗣️ the key here (the skill you must develop 🚨) is prompting! How to write really good prompts that not only will give you meaningful results but also in a way you can keep interacting and/or integrate to your project (this could be web, mobile, 🤔) [Spoiler, coming soon, new blog about building great prompts!]

Let’s take the “PAIR programming” as example:

https://g.co/gemini/share/1c627fd8810f

The result seems pretty cool, but let’s move a bit more and see the coding part and where the Gemini API comes 🤔🤔🤔🤔🤔

Welcome to Google AI Studio (formerly known as MakerSuite 💙💚)

https://aistudio.google.com/app/

I’ve (re)started trying when Gemini models were set available here + getting the API Key + exploring different options to start prompting (as you see in the left side Create a new: Freefrom prompt, Structured prompt or Chat prompt).

Let’s take the “PAIR programming” as example:

Same prompt, using Google AI Studio and Gemini 1.5 Pro API

The response seems pretty cool, but if we want to build a PAIR programming a bit more sophisticated we can always try opening a new colab notebook.

First, use Gemini 1.0 (because up to date, we can have this API).

Click in “Get code”, and see it is possible to have code in “Python” (and more!)

However, we might need first the “YOUR_API_KEY” 🫠, no worries, Google AI Studio also helps!

Go to the left side, “Get API Key” and you will be able to Create a new one, which should be related to a Google Cloud Project”.

Let’s move on! and check on my github repo testing-genai-pairprogramming how to get started building more “sophisticated” prompt to start building a PAIR programming. (In that repo, I am using PALM API but also the GEMINI API, so you can test both before PALM API is deprecated).

Check here:

completition = generate_text(
prompt = prompt_template.format(question=question)
)

It is possible to customize the prompt using “question” for example, in that example the question is:

question = """
def func_x(array)
for i in range(len(array)):
print(array[i])
"""

and the prompt_template is:

prompt_template = """
I don't think this code is the best way to do it in Python, can you help me?
{question}
Please, explain, in detail, how you improve it!
"""

and you can keep building with different questions to get an assistant for programming (🤓 check the repo!) I’ll come back with more explanations in a 2nd part of this blog!

The repo and blog was pretty much inspired in the short course: Pair Programming with a Large Language Model

--

--

Lesly Zerna
Lesly Zerna

Written by Lesly Zerna

🤖 enthusiastic explorer | AI + Education | startups

No responses yet