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
  • Step 1: Create txt file with name facts.txt and content below:
  • Step 2: Using the code be low to build a simple RAG with doc and germini
  1. Build small thing with LLM

Create R.A.G with germini

Step 1: Create txt file with name facts.txt and content below:

Severe weather can trigger a mass migration known as a “grand passage.”
In 1995, a blizzard in the Prairie Pothole Region spurred a migration of millions of ducks 
and geese that jammed radar systems and grounded flights in Nebraska and Missouri.

The fastest duck recorded was a red-breasted merganser, which achieved an airspeed of 100 mph.

According to research, ducks may show a preference for colors in the green or blue spectrum.

A duck’s bill varies by species and relates to its function.
Flat bills are used to consume plant materials, 
while pointed bills are used to catch and eat fish.

City ducks have a different accent than country ducks – typically louder!

Mallards often have clutches that include eggs fertilized by different males, 
which biologists believe ensures successful fertilization and greater genetic variation.

All ducks can dive, but some species are better at diving than others. 
The best is the long-tailed duck, also known as an oldsquaw, which can dive 240 feet.

Ducklings can understand the relationship between objects, 
which demonstrates abstract thought capabilities.

Ducks, like other waterfowl, have as many as 12,000 separate muscles to control their feathers. 
They can use these to lift or compress feathers to dive underwater, show emotion, or regulate body heat.

Ducks migrate at an altitude of 200 to 4,000 feet but are capable of reaching heights of 21,000 feet.

Step 2: Using the code be low to build a simple RAG with doc and germini

from llama_index.core import Settings, SimpleDirectoryReader,StorageContext,VectorStoreIndex
from llama_index.core.node_parser import TokenTextSplitter
from llama_index.vector_stores.duckdb import DuckDBVectorStore   
from langchain_google_genai import ChatGoogleGenerativeAI
import os
import getpass

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

# load documents into a vector store(DuckDB)
documents = SimpleDirectoryReader(input_files=["facts.txt"]).load_data(show_progress=True)
splitter = TokenTextSplitter(separator="\n",chunk_size=64,chunk_overlap=0)
vector_store = DuckDBVectorStore()
store_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex(splitter.get_nodes_from_documents(documents),
                                      store_context=store_context,
                                      show_progress=True)
query_engine = index.as_query_engine()

try:
    while True:
        query = input(">>")
        respone = query_engine.query(query)
        print(respone)

except KeyboardInterrupt:
    exit()
PreviousCreate chatbot with gemini modelNextCreate AI Agent tool for query DB

Last updated 1 month ago