Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/aieng-abdullah/production-rag-assistant
/ functions
Functions
205 in github.com/aieng-abdullah/production-rag-assistant
⨍
Functions
205
◇
Types & classes
20
↳
Endpoints
65
↓ 17 callers
Function
_usage_from_lc_response
Extract token usage from a LangChain response object.
src/generation/chain.py:24
↓ 13 callers
Function
ingest
Process a PDF file through the full ingestion pipeline. Steps: 1. Extract text from PDF pages 2. Split pages into chunks
src/ingestion/pipeline.py:13
↓ 11 callers
Function
retrieval
Retrieve relevant text chunks from a vector database using embeddings, using traditional BM25 search and vector search then uses a reranker
src/retrieval/pipeline.py:14
↓ 8 callers
Function
_get_vectorstore
Get or initialize the LangChain Chroma vectorstore.
src/db/chroma_client.py:17
↓ 8 callers
Function
chunk_pages
Split pages into chunks while preserving metadata.
src/ingestion/chunker.py:17
↓ 7 callers
Function
rrf_fusion
Combine BM25 and vector search results using Reciprocal Rank Fusion (RRF).
src/retrieval/hybrid_fusion.py:11
↓ 6 callers
Function
_build_sources
Convert raw retrieval chunks into Source objects.
src/generation/chain.py:40
↓ 6 callers
Function
_invoke_llm
Call LLM providers with retry + exponential backoff + failover. Tries each provider in order (Groq → Anthropic → OpenAI). Each provider gets
src/generation/chain.py:48
↓ 6 callers
Function
build_provider_chain
Return providers that have API keys configured, in failover order. Order: Groq (free) → Anthropic → OpenAI. Only includes providers whose API
src/generation/providers.py:15
↓ 6 callers
Function
get_langfuse_client
Return a Langfuse client, or None if tracing is disabled or unavailable.
src/monitoring/langfuse_tracer.py:22
↓ 6 callers
Function
rerank
Rerank chunks against a query using a cross-encoder model.
src/retrieval/cross_encoder.py:16
↓ 5 callers
Function
_run_pipeline
Core RAG pipeline: retrieve → build prompt → call LLM → validate citations.
src/generation/chain.py:90
↓ 5 callers
Function
count_chunks
Return the total number of chunks in the vectorstore without loading them.
src/db/chroma_client.py:93
↓ 5 callers
Function
create_langchain_client
Instantiate the LangChain chat model for the given provider. Imports are local so users only need to install the package for providers they a
src/generation/providers.py:42
↓ 5 callers
Function
embed_query
Generate embedding for a single query text. Args: text: The text to embed. Returns: List of float embedding values.
src/ingestion/embedder.py:28
↓ 5 callers
Function
extract_pages
(pdf_path: str, doc_id: Optional[str] = None)
src/ingestion/parser.py:9
↓ 5 callers
Method
validate
Call this once at app startup. Crashes immediately with a clear message if critical vars are missing. Much better than cra
src/config.py:58
↓ 4 callers
Function
_chunks_to_documents
Convert chunk dictionaries to LangChain Documents.
src/retrieval/bm25_index.py:10
↓ 4 callers
Function
_get_model
Get or initialize the embedding model.
src/ingestion/embedder.py:15
↓ 4 callers
Function
_traced_step
(name: str, fn)
src/retrieval/pipeline.py:27
↓ 4 callers
Function
flush_langfuse
()
src/monitoring/langfuse_tracer.py:59
↓ 4 callers
Function
generate
Generate a cited answer for the given query using the RAG pipeline.
src/generation/chain.py:196
↓ 4 callers
Function
has_chunks
Check if any chunks exist in the vectorstore without loading them.
src/db/chroma_client.py:88
↓ 4 callers
Function
vector_search
Semantic similarity search in vector store. Uses embed_query to embed the query.
src/retrieval/chroma_search.py:11
↓ 3 callers
Function
_documents_to_chunks
Convert LangChain Documents back to chunk dictionaries.
src/retrieval/bm25_index.py:27
↓ 3 callers
Function
_get_model
()
src/retrieval/cross_encoder.py:7
↓ 3 callers
Function
bm25_search
Search the BM25 index using LangChain retriever.
src/retrieval/bm25_index.py:53
↓ 3 callers
Function
build_bm25_index
Build a BM25 index from chunks using LangChain BM25Retriever.
src/retrieval/bm25_index.py:42
↓ 3 callers
Function
build_citation_prompt
Build the citation prompt for the RAG system.
src/generation/Citation_system.py:29
↓ 3 callers
Function
langfuse_configured
()
src/monitoring/langfuse_tracer.py:18
↓ 3 callers
Function
load_all_chunks
Load all chunks from the vectorstore. Uses the underlying collection for efficient retrieval.
src/db/chroma_client.py:69
↓ 2 callers
Function
cosine_sim
(a, b)
tests/test_embedder.py:85
↓ 2 callers
Function
embed_chunks
Generate embeddings for chunks in batches.
src/ingestion/embedder.py:42
↓ 2 callers
Function
get_collection
Returns the underlying Chroma collection for compatibility. Accesses the internal _collection from LangChain Chroma.
src/db/chroma_client.py:31
↓ 2 callers
Function
upsert_chunks
Add or update chunks in the vectorstore using LangChain add_documents.
src/db/chroma_client.py:41
↓ 1 callers
Function
_apply_provider_overrides
Inject provider API keys from sidebar UI into Config.
app.py:108
↓ 1 callers
Function
_call_provider_with_retry
Call a single provider with retry + exponential backoff.
src/generation/chain.py:82
↓ 1 callers
Function
_generate_traced
Run the RAG pipeline with Langfuse tracing spans around each step.
src/generation/chain.py:104
↓ 1 callers
Function
_get_pipeline
()
eval/eval_runner.py:40
↓ 1 callers
Function
build_eval_samples
(eval_dataset: List[Dict[str, str]])
eval/eval_runner.py:61
↓ 1 callers
Function
check_thresholds
(scores: Dict[str, float])
eval/eval_runner.py:98
↓ 1 callers
Function
display_cited_answer
Display answer with expandable citations.
app.py:90
↓ 1 callers
Function
get_bm25_retriever
Get a BM25Retriever for use in chains.
src/retrieval/bm25_index.py:75
↓ 1 callers
Function
get_vectorstore
Get the LangChain Chroma vectorstore for use in chains. Returns: Chroma vectorstore instance.
src/db/chroma_client.py:109
↓ 1 callers
Function
handle_query
Handle user query and generate response.
app.py:120
↓ 1 callers
Function
init_session_state
Initialize session state variables.
app.py:32
↓ 1 callers
Function
load_eval_dataset
(file_path: str)
eval/eval_runner.py:47
↓ 1 callers
Function
main
Main app entry point.
app.py:272
↓ 1 callers
Function
main
()
eval/eval_runner.py:114
↓ 1 callers
Function
process_pdf
Process PDF through ingestion pipeline.
app.py:58
↓ 1 callers
Function
render_chat
Render main chat area.
app.py:245
↓ 1 callers
Function
render_sidebar
Render left sidebar with upload and document list.
app.py:173
↓ 1 callers
Function
reset_client
Resets the singleton vectorstore (useful for tests).
src/db/chroma_client.py:100
↓ 1 callers
Function
run_rag
(question: str)
eval/eval_runner.py:53
↓ 1 callers
Function
run_ragas_evaluation
(samples: List[Dict[str, Any]])
eval/eval_runner.py:74
↓ 1 callers
Function
save_results
(samples, scores, threshold_results, output_path)
eval/eval_runner.py:109
↓ 1 callers
Function
save_uploaded_file
Save uploaded PDF to data/raw/ directory.
app.py:50
↓ 1 callers
Function
test_embed_chunks
Test batch chunk embedding preserves metadata.
tests/test_embedder.py:28
↓ 1 callers
Function
test_embed_query
Test single query embedding returns correct format.
tests/test_embedder.py:9
↓ 1 callers
Function
test_model_singleton
Test that model is lazy-loaded and reused.
tests/test_embedder.py:58
↓ 1 callers
Function
test_similarity_consistency
Test that similar texts have higher similarity.
tests/test_embedder.py:74
Method
must_have_citation
(cls, validate)
src/generation/Citation_system.py:22
Function
reset_langfuse_state
Reset module-level state before each test.
tests/test_langfuse_tracer.py:8
Function
reset_model
()
tests/test_cross_encoder.py:8
Function
reset_vectorstore
()
tests/test_chroma_client.py:8
Method
test_all_providers_fail_raises
(self, mock_call, mock_chain)
tests/test_generate.py:241
Method
test_all_three_providers
(self)
tests/test_providers.py:28
Method
test_answer_relevancy_threshold_is_between_0_and_1
(self)
tests/test_config.py:80
Method
test_anthropic_and_openai_only
(self)
tests/test_providers.py:38
Method
test_anthropic_client
(self, mock_chat_anthropic)
tests/test_providers.py:77
Method
test_base_dir_is_project_root
(self)
tests/test_config.py:10
Method
test_bm25_error_wrapped
(self, mock_bm25)
tests/test_retrieval_pipeline.py:96
Function
test_bm25_search
(mock_bm25_cls)
tests/test_bm25.py:65
Function
test_bm25_search_error
(mock_bm25_cls)
tests/test_bm25.py:76
Function
test_build_bm25_index
(mock_bm25_cls)
tests/test_bm25.py:55
Function
test_build_prompt_contains_sources
()
tests/test_citations.py:15
Function
test_build_sources
()
tests/test_chain_utils.py:58
Function
test_build_sources_empty
()
tests/test_chain_utils.py:72
Method
test_chroma_dir_is_under_data_dir
(self)
tests/test_config.py:16
Method
test_chroma_dir_path_is_absolute
(self)
tests/test_config.py:19
Method
test_chroma_host_is_string
(self)
tests/test_config.py:27
Method
test_chroma_port_is_int
(self)
tests/test_config.py:30
Method
test_chunk_metadata_preserved_through_pipeline
Verify doc_id and page_num survive from extract through chunk to embed.
tests/test_pipeline_ingest.py:44
Method
test_chunk_overlap_is_less_than_chunk_size
(self)
tests/test_config.py:68
Function
test_chunk_pages_basic
()
tests/test_chunker.py:6
Function
test_chunk_pages_empty_page_skipped
()
tests/test_chunker.py:19
Function
test_chunk_pages_global_index_increments
()
tests/test_chunker.py:67
Function
test_chunk_pages_metadata_preserved
()
tests/test_chunker.py:28
Function
test_chunk_pages_no_pages
()
tests/test_chunker.py:62
Function
test_chunk_pages_small_chunks_filtered
()
tests/test_chunker.py:54
Function
test_chunk_pages_total_chunks_added
()
tests/test_chunker.py:42
Method
test_chunk_size_is_positive
(self)
tests/test_config.py:65
Method
test_chunking_error
(self, mock_extract, mock_chunk)
tests/test_pipeline_ingest.py:120
Method
test_chunks_have_total_chunks_metadata
Verify chunk_pages adds total_chunks metadata.
tests/test_pipeline_ingest.py:82
Function
test_chunks_to_documents
()
tests/test_bm25.py:14
Function
test_chunks_to_documents_defaults
()
tests/test_bm25.py:27
Method
test_collection_name_is_nonempty
(self)
tests/test_config.py:83
Method
test_converts_chunks_to_sources
(self)
tests/test_generate.py:88
Function
test_count_chunks
(mock_embed, mock_chroma)
tests/test_chroma_client.py:116
Method
test_data_dir_exists
(self)
tests/test_config.py:13
next →
1–100 of 205, ranked by callers