GenAI For Tester
  • Introduction
  • Session 1: Introduction to Generative AI in Testing
    • 1. Overview of Generative AI
    • 2. Popular AI Models and Their Usage
    • 3. Setting Up AI Tools for Testing
    • 4. Prompt Engineering for Software Testing
      • Prompt Managerment
  • Session 2: AI-Assisted Test Case Generation
    • Exam #1: eCommerce Domain - Checkout Flow
    • Exam #2: Mobile App - User Login and Authentication
    • Exam #3: API Testing - User Registration Endpoint
  • Session 3: Advanced AI in Test Automation
    • 🐍 Python 3.12 Setup Guide
    • Chrome AI Asistant
    • Setup Github Copilot in VS Code
    • Playwright MCP Server
    • SQLite MCP to interact with your DB
    • Browser-use Browser AI Agent
    • Postman PostBot AI for API Testing
    • Self Healing Elements with AgentQL and Playwright
  • n8n flexible AI workflow automation for technical teams
    • Setup n8n with docker
  • Build small thing with LLM
    • Create chatbot with gemini model
    • Create R.A.G with germini
    • Create AI Agent tool for query DB
  • Get selenium locator with llm and java
  • Group 1
    • Setup Local DB
Powered by GitBook
On this page
  • Setup​
  • Implement code
  1. Build small thing with LLM

Create chatbot with gemini model

Setup​

To access Google AI models you'll need to create a Google Account, get a Google AI API key, and install the langchain-google-genai integration package.

1. Installation:

pip install langchain-google-genai

2. Credentials:

Head to https://ai.google.dev/gemini-api/docs/api-key (or via Google AI Studio) to generate a Google AI API key.

Implement code

from langchain_google_genai import ChatGoogleGenerativeAI
import getpass
import os

if "GOOGLE_API_KEY" not in os.environ:
    os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter your Google AI API key: ")
llm = ChatGoogleGenerativeAI(
    model="gemini-2.0-flash",
    temperature=0,
    max_tokens=None,
    timeout=None,
    max_retries=2,
    # other params...
)    

messages = [
    ("human", "what is duckDB? Answer in two sentences."),
]
ai_msg = llm.invoke(messages)
print(ai_msg.content)
PreviousSetup n8n with dockerNextCreate R.A.G with germini

Last updated 1 month ago