A Guide to Setting Up Python, Anaconda, and Visual Studio Code for Google's Gemini Generative AI Model
n the ever-evolving landscape of artificial intelligence, the development of multimodal models has marked a pivotal moment. The quest for AI models capable of understanding and processing information from diverse sources has led to the evolution of multimodal AI. Google's Gemini, a testament to this evolution, represents a significant leap forward in addressing the complexities associated with different types of data—text, code, audio, images, and video.
To begin with, we need to install the Python programming language.
Install Python:
Install Visual Studio Code:
Install Anaconda:
Next we need to install Anaconda that helps to create and manage virtual environment(s) for different projects.
Creating a Conda Environment in VS Code:
Install Gemini:
Within the activated environment, install Gemini using the command
pip install Gemini
Setup your Google API key
Vist Google AI studio https://makersuite.google.com/app/apikey to get your API key.
Testing the Setup
领英推荐
Create conda environment
Type the following command to create a virtual environment with conda ?named "venv" inside a work folder.
conda create -n venv python=3.11? # Replace 3.8 with your desired Python version
The virtual environment is venv ?in this case. Press “y” button whenever it asks you to proceed.
Activate the virtual environment using the below command:
conda activate venv
google-generativeai
python-dotenv
3. At terminal install these libraries using > pip install -r requirsments.txt
4. create an geminiAI.py file and write all the code and then run the code using
python geminiAI.py command
# my first program
import os
## GenerativeModel
import google.generativeai as genai
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
## Function to load OpenAI model and get respones
def get_gemini_response(question):
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(question)
return response.text
prompt = "Write a poem about a beautiful sunset."
response = get_gemini_response(prompt)
print(response)