System Set up with first calls to LLMs
-
Goal:
- Basic code to connect to llms on Google Cloud
-
Softwares required
- python
- Git
- Visual studio code
- Google Cloud SDK
- AWS CLI
- Azure CLI
- UV
- Configurations
- Google Cloud SDK
- AWS CLI
- Azure CLI
-
Sample code if this works your system is good to go.
-
Installation Prompt
On my windows 11 laptop i want to install below softwares using winget
* python
* Git
* Visual studio code
* Google Cloud SDK
* AWS CLI
* Azure CLI
* UV
- Cloud CLI Prompt
I have gcloud sdk installed on my windows laptop
Give me steps to configure cli so that i can use gcloud vertex ai with python or langchain
I just need authentication and authorization steps not code
- Solution
gcloud init
gcloud auth application-default login
Test code
- create a new directory and cd into it
mkdir learning
cd learning
uv init .
uv add langchain langchain-google-genai python-dotenv
code .
- In vscode select interpretor
ctrl+shift+p=>python: select interpretor - In main.py copy the following code
from langchain.agents import create_agent
from langchain_google_genai import ChatGoogleGenerativeAI
from dotenv import load_dotenv
import os
load_dotenv()
def main():
model = ChatGoogleGenerativeAI(
model="gemini-3.5-flash",
project=os.getenv('PROJECT_ID')
)
result = model.invoke("What is capital of France")
result.pretty_print()
if __name__ == "__main__":
main()
- Create a file called as
.envwith following content
PROJECT_ID='<your gcp project id>'
- RUn
uv run main.py
