Blogs Gemini Rules — Free Gemini Rules Template
    Neura MarketNeura Market/Gemini
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityGemsExtensionsTrending
    GeminiRulesBlogs Gemini Rules
    Back to Rules

    Blogs Gemini Rules

    rnkp755 July 19, 2026
    0 copies 0 downloads
    Rule Content
    """
    - pip install langchain_community pypdf langchain_text_splitters langchain-google-genai langchain_qdrant openai
    """
    
    import os
    import json
    from pathlib import Path
    from langchain_community.document_loaders import PyPDFLoader
    from langchain_text_splitters import RecursiveCharacterTextSplitter
    from langchain_google_genai import GoogleGenerativeAIEmbeddings
    from langchain_qdrant import QdrantVectorStore
    from openai import OpenAI
    
    GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
    
    pdf_path = Path("./nodejs.pdf")
    
    loader = PyPDFLoader(file_path = pdf_path)
    docs = loader.load()
    
    text_splitter = RecursiveCharacterTextSplitter(
        chunk_size=1000,
        chunk_overlap=200
    )
    
    split_docs = text_splitter.split_documents(docs)
    
    print("Number of documents before splitting:", len(docs))
    # print(docs[0])  # docs is a list of Document objects
    print("Number of documents after splitting:", len(split_docs))
    # print(split_docs[0])    # split_docs is a list of Document objects
    
    embedder = GoogleGenerativeAIEmbeddings(
        model="models/text-embedding-004",
        google_api_key=GOOGLE_API_KEY,
        )
    
    
    vector_store = QdrantVectorStore.from_documents(
        documents = split_docs,
        url = "http://localhost:6333",
        collection_name = "learning_langchain",
        embedding = embedder
    )
    
    
    retriever = QdrantVectorStore.from_existing_collection(
        url = "http://localhost:6333",
        collection_name = "learning_langchain",
        embedding = embedder
    )
    
    # Create client for chatting
    client = OpenAI(
        api_key=GOOGLE_API_KEY,
        base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
    )
    
    finalResponse = ""
    
    def fan_out():
        user_query = input(">> ")
    
        global finalResponse
        finalResponse = ""  # Reset the final response for each new query
    
        FAN_OUT_SYSTEM_PROMPT = """
        You are a helpful assistant. You will be provided with a question and you need to generate 3 questions out of it focusing on different aspects of it or related to it. The focus should be on what user might be interested in and maybe he couldn't ask it directly. You need to generate them.
    
        Rules:
        - Follow the output JSON format.
    
        Example:
        User Query: How does garbage collection workin python?
        Output: {{ "q1": "What triggers garbage collection in python?", "q2": "Garbage collection algorithms in Python?", "q3": "How memory leaks relate to GC?" }}
        """
    
        response = client.chat.completions.create(
            model="gemini-2.0-flash",
            response_format={"type": "json_object"},
            messages=[
                {"role": "system", "content": FAN_OUT_SYSTEM_PROMPT},
                {
                    "role": "user",
                    "content": user_query
                }
            ]
        )
        content = response.choices[0].message.content
        print("Fan out response:", content)
        # Parse the JSON response
        parsed_response = json.loads(content)
        # Extract the questions
        questions = [parsed_response["q1"], parsed_response["q2"], parsed_response["q3"]]
        print("Questions:", questions)
        # Call the retrieval_generation function for each question
        for question in questions:
            retrieval_generation(question)
    
        print("Final response:", finalResponse)
        
    def retrieval_generation(query: str):
    
        global finalResponse
    
        relevant_chunks  = retriever.similarity_search(
            query = query
        )
    
        print("Search result:", relevant_chunks)
    
        GENERATION_SYSTEM_PROMPT = """
        You are a helpful assistant. You will be provided with a question and relevant context from a document. Your task is to provide a concise answer based on the context.
        Context: {relevant_chunks}
        """
    
        response = client.chat.completions.create(
            model="gemini-2.0-flash",
            messages=[
                {"role": "system", "content": GENERATION_SYSTEM_PROMPT.format(relevant_chunks=relevant_chunks)},
                {
                    "role": "user",
                    "content": query
                }
            ]
        )
        answer = response.choices[0].message.content
        finalResponse += f"\n{answer}"
    
    
    fan_out()
    

    Comments

    More Rules

    View all

    Sleepycat Seo Platform Gemini Rules

    A
    acovrp

    LITE IDE Gemini Rules

    H
    Heyz24

    Shadowtagai Monorepo V2 Gemini Rules

    S
    ShadowTag-v2

    WoKFlow Gemini Rules

    H
    howyongheng0313

    MetaPrompter Gemini Rules

    U
    ummerr

    Taskora Gemini Rules

    K
    kabilesh-c

    Stay up to date

    Get the latest Gemini prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Gemini and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Gemini resource

    • Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Databasen8n · $24.99 · Related topic
    • Convert Telegram Messages to Professional LinkedIn Posts with Gemini AI & Approval Workflown8n · $24.99 · Related topic
    • Kubernetes RCA and Alerting Using Gemini, Loki, Prometheus, Slackn8n · $24.99 · Related topic
    • AI-Powered Auto-Generated Exam Questions and Answers from Google Docs with Geminin8n · $24.99 · Related topic
    Browse all workflows