This package offers a lightweight and straightforward solution for implementing Retrieval-augmented generation (RAG) functionality with large language models (LLMs).
Project description
RAG doc search
Overview
This package offers a lightweight and straightforward solution for implementing Retrieval-augmented generation (RAG) functionality with large language models (LLMs). RAG enhances prediction quality by incorporating external data storage during inference, enabling the construction of more contextually rich prompts. Leveraging combinations of context, history, and up-to-date knowledge, RAG LLMs empower users to generate more accurate and relevant responses. This package streamlines the integration of RAG capabilities into applications, facilitating the creation of more intelligent and context-aware conversational agents, search engines, and text generation systems.
Config Json
{
"ai_provider": "OPENAI" | "BEDROCK" | "AZURE_OPENAI",
"embeddings_model": "<embedding model of openai or bedrock or azure openai as per ai_provider>",
"llm": "<llm model of openai or bedrock as per ai_provider>",
"llm_temperature": "<llm model of temperature>",
"llm_max_output_tokens": "<llm model of mac output token>",
"vector_store_provider": "FAISS" | "PGVector",
"faiss_vector_embeddings_location": "./data", provide only if vector_store_provider is FAISS
"faiss_index_name": "fiass-db", provide only if vector_store_provider is FAISS
"name": "<name of your project>",
"retriever": {
use this link [https://python.langchain.com/docs/modules/data_connection/retrievers/vectorstore] for understanding retriver searchtype and search_args
"search_type": "similarity" | "mmr" | "similarity_score_threshold" ,
"search_args": {
"k": 10,
"fetch_k": 500,
"lambda_mult": 0.1
"score_threshold" : 0.1
}
}
}
Note
Ensure that the necessary environment variables are set before initializing the configuration.
- If AI Provider is
OPENAI
then ENVOPENAI_API_KEY
is required. - If AI Provider is
BEDROCK
then ENVAWS_ACCESS_KEY
,AWS_SECRET_ACCESS_KEY
are required and AWS_REGION is optional, default is 'us-east-1'. - If Vector Store Provider is
PGVector
thenPGVECTOR_HOST
,PGVECTOR_PORT
,PGVECTOR_DATABASE
,PGVECTOR_USER
andPGVECTOR_PASSWORD
are required
How to Use
from rag_doc_search import config_init, get_bot_instance
from rag_doc_search.utils.config import Config
from rag_doc_search.src.enums.provider import AIProvider
# provide your config JSON in init config_init method below also set the required ENV as mentioned in Note
config = config_init({})
# Method a bot instance as per AI provider it will give you the bot model for BedRock or for OpenAI
bot_instance = get_bot_instance(config.ai_provider)
qa_instance = bot_model.create_qa_instance()
result = qa_instance.invoke(input="Provide your prompt here")
print(result)
Examples
To understand how to use the package, refer to the following examples:
-
To create an API that answers your questions, use the example provided here.
-
To create a WebSocket API for streaming answers to your questions, use the example provided here.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rag_doc_search-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 881ed7f9027c8ec552fbaffc5794b6fc24313e2b99d7f0c98e9e6f48be773904 |
|
MD5 | a371914205573bf288224bbc0ce63488 |
|
BLAKE2b-256 | df3534f2605245db7003c11c56e52941219a5e19860770763b45e38f154c0e39 |