In this final project workshop, you will put everything you have learned about Large Language Models, prompting, and developer APIs to use by building a custom context-aware AI Assistant!
Your goal is to build an interactive terminal chatbot in Python using the Google Generative AI library. The chatbot will act as a specialized coding tutor that enforces system-prompt behaviors and maintains conversational context (memory) across multi-turn exchanges.
Rather than manually appending user and assistant history arrays for every prompt, the Gemini SDK provides a convenient chat utility. You start a chat session by callingmodel.start_chat(), optionally passing systemInstruction to lock down behavior, and send messages dynamically with chat.sendMessage():
# Starting a stateful chat session
chat = model.start_chat(
history=[],
system_instruction="You are a strict Python mentor."
)
# Multi-turn interaction
response1 = chat.send_message("What is a list?")
response2 = chat.send_message("Can you give me a coding example?")
Implement the following architectural tasks inside the code panel to build your chatbot script:
system_instruction string that restricts the bot to explain coding tasks only.GenerativeModel and pass your system instruction to it.model.start_chat() to create a stateful conversation object.chat.send_message(), prints the response, and exits on "quit".The starter scaffold is pre-loaded in the code editor on the right.