LangChain-Lernreise: Python und Gemini einrichten
Ein Frontend-Entwickler dokumentiert seinen Weg von den Grundlagen von LangChain bis zu einem AI-gestützten Assistenten für Angular-Entwickler und erklärt die Einrichtung von Python und Gemini.

My journey from learning the fundamentals of LangChain to building an AI-powered Angular Developer Assistant.
I've been working with frontend technologies, particularly Angular, and I've always been interested in understanding how AI can make software development more productive.
AI-powered applications are becoming increasingly common. From chatbots and coding assistants to intelligent agents that can use tools and perform tasks, there are many possibilities to explore.
I wanted to understand how these applications are built rather than just using existing AI tools.
That's what motivated me to start learning LangChain.
My goal wasn't to jump straight into building an advanced AI application. Instead, I wanted to start with the fundamentals, understand each concept, implement it through practical exercises, and gradually build something useful.
For this learning journey, I decided to use:
Eventually, my goal was to build an AI assistant specifically designed to help with Angular development.
But before getting there, I needed to prepare my development environment.
Before writing any LangChain code, I wanted to make sure my development environment was properly configured.
I divided the setup into a few small steps.
Since LangChain supports Python, I first needed a working Python installation.
I used Python 3.11+ for this learning project.
After installation, I verified Python from the terminal:
python --version Enter fullscreen mode Exit fullscreen mode This confirmed that Python was available and ready to use.
I wanted to keep all my learning exercises and project files organized in one place.
D:\langchain-learning Enter fullscreen mode Exit fullscreen mode Then I opened this directory in VS Code.
Keeping a dedicated project directory made it easier to organize lessons, exercises, configuration files, and the practical project that I would build later.
One thing I wanted to understand early was why Python projects use virtual environments.
A virtual environment provides an isolated Python environment for a particular project.
Without it, installing packages globally can create dependency conflicts between different projects.
For example, one project might require a particular version of LangChain, while another project might depend on a different version.
A virtual environment helps keep those dependencies separate.
python -m venv.venv Enter fullscreen mode Exit fullscreen mode This created a.venv directory inside my project.
Since I was using Windows, I activated it with:
.venv\Scripts\activate Enter fullscreen mode Exit fullscreen mode After activation, my terminal displayed:
(.venv) D:\langchain-learning> Enter fullscreen mode Exit fullscreen mode The (.venv) prefix confirmed that the virtual environment was active.
Now that the environment was ready, I needed to install the packages required for the project.
pip install langchain pip install langchain-google-genai pip install python-dotenv Enter fullscreen mode Exit fullscreen mode Here's what each package does.
I wanted to keep the initial setup simple and avoid installing packages that I didn't need yet.
I would introduce additional concepts and dependencies as the learning journey progressed.
To interact with Google's Gemini models, I needed an API key.
I obtained one through Google AI Studio.
The API key allows my Python application to authenticate with Google's Gemini API.
However, I didn't want to put the API key directly inside my Python source code.
Hardcoding credentials is a bad practice because source files can accidentally be shared, uploaded to GitHub, or committed to a public repository.
Instead, I decided to use environment variables.
I created a.env file in the project root:
D:\langchain-learning\.env Enter fullscreen mode Exit fullscreen mode Inside it, I added:
GOOGLE_API_KEY = your_actual_gemini_api_key Enter fullscreen mode Exit fullscreen mode Important: Replace the placeholder with your actual API key. Never publish your real key in a blog post, source repository, or screenshot.
Installing python-dotenv allowed me to load the environment variables from the.env file.
from dotenv import load_dotenv import os load_dotenv ( ) google_api_key = os. getenv ( "GOOGLE_API_KEY" ) if not google_api_key: raise ValueError ( "GOOGLE_API_KEY is missing from.env file." ) Enter fullscreen mode Exit fullscreen mode Let's understand what's happening.
This was the most exciting part of the setup.
I had Python installed, my virtual environment configured, the required packages installed, and my Gemini API key ready.
Now I wanted to verify that everything worked together.
I created a file called main.py in the project root.
from dotenv import load_dotenv from langchain_google_genai import ChatGoogleGenerativeAI load_dotenv ( ) llm = ChatGoogleGenerativeAI ( model = "gemini-3.5-flash-lite" ) response = llm. invoke ( "Explain what LangChain is in simple terms." ) print ( response. content ) Enter fullscreen mode Exit fullscreen mode Let's break down the important parts.
from langchain_google_genai import ChatGoogleGenerativeAI Enter fullscreen mode Exit fullscreen mode This class provides the integration between LangChain and Google's Gemini chat models.
Instead of directly calling the Gemini API, I can interact with the model through LangChain's chat model interface.
llm = ChatGoogleGenerativeAI ( model = "gemini-3.5-flash-lite" ) Enter fullscreen mode Exit fullscreen mode Here, I initialized a Gemini chat model.
The model parameter specifies which Gemini model I want to use.
response = llm. invoke ( "Explain what LangChain is in simple terms." ) Enter fullscreen mode Exit fullscreen mode The invoke() method sends the input to the model and returns its response.
print ( response. content ) Enter fullscreen mode Exit fullscreen mode The response is a LangChain message object. Its content property contains the generated response.
I ran the application from the project root:
python main.py Enter fullscreen mode Exit fullscreen mode When Gemini returned a response, I knew the basic integration was working.
At this stage, my project was still small.
langchain-learning/ │ ├──.venv/ │ ├──.env │ ├── main.py │ └── requirements.txt Enter fullscreen mode Exit fullscreen mode As the course progressed, I would add separate directories for lessons, exercises, and the practical Angular assistant project.
I also added a.gitignore file to prevent sensitive and generated files from being committed.
.env.env.*!.env.example.venv/ venv/ __pycache__/ *.py[cod].vscode/.pytest_cache/.coverage htmlcov/ Enter fullscreen mode Exit fullscreen mode I also created an.env.example file containing a placeholder:
GOOGLE_API_KEY = your_google_api_key_here Enter fullscreen mode Exit fullscreen mode This allows someone else to understand which environment variable is required without exposing my actual credentials.
Although this phase was mostly about environment setup, I learned several important things that would become useful throughout the course.
There wasn't a major technical issue during the initial setup, but a few things became important as I continued learning.
These small details helped me establish good development practices from the beginning.
I now had a working Python environment, LangChain installed, Gemini configured, and a simple Python application successfully communicating with the AI model.
It wasn't an advanced AI application yet, but it was an important starting point.
I wanted to understand what was happening behind the scenes, so my next step was to explore LangChain itself.
I planned to learn how chat models work, how messages are structured, and how to build a chatbot that could interact with users through the terminal.
Understanding LangChain Fundamentals: Messages, Chat Models, and My First Chatbot.
This is just the beginning of my LangChain learning journey!
Series: My LangChain Learning Journey: From Beginner to Building an AI Agent