|
""" |
|
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" |