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
OPENAIthen ENVOPENAI_API_KEYis required. - If AI Provider is
BEDROCKthen ENVAWS_ACCESS_KEY,AWS_SECRET_ACCESS_KEYare required and AWS_REGION is optional, default is 'us-east-1'. - If Vector Store Provider is
PGVectorthenPGVECTOR_HOST,PGVECTOR_PORT,PGVECTOR_DATABASE,PGVECTOR_USERandPGVECTOR_PASSWORDare 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_doc_search-0.1.9.tar.gz.
File metadata
- Download URL: rag_doc_search-0.1.9.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0984fb7255890c437981dbe291e0e44f93a44352c5549b8900f9214bbb0e0b7c
|
|
| MD5 |
60b77e3e5c35f96889962466fce3f9dc
|
|
| BLAKE2b-256 |
c1b9b4d6ebd51601d60bbfefe01cb62ec802b3324b095982d7362ce7a2b12774
|
File details
Details for the file rag_doc_search-0.1.9-py3-none-any.whl.
File metadata
- Download URL: rag_doc_search-0.1.9-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bce5641282548204c578c27cc58ed6bbe9dad0481c3ce2071850d9f0138ce6c
|
|
| MD5 |
83196e5d8e97b03c0e3c013820301f21
|
|
| BLAKE2b-256 |
d3e7715a87e64945910ef00de3982fa2323b326e5b78e46b1ec1dd422b06fd75
|