File size: 723 Bytes
0321eee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
This file contains the tools for the RAG workflow.
"""

import os
from groundx import GroundX
from dotenv import load_dotenv

load_dotenv()

client = GroundX(api_key=os.getenv("GROUNDX_API_KEY") or '')

def search_groundx_for_rag_context(query: str) -> str:
    """
    Searches and retrieves relevant context from a knowledge base,
    based on the user's query.
    Args:
        query: The search query supplied by the user.
    Returns:
        str: Relevant text content that can be used by the LLM to answer the query.
    """

    response = client.search.content(
        id=os.getenv("GROUNDX_BUCKET_ID"),
        query=query,
        n=10,
    )

    return response.search.text or "No relevant context found"