-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Background
In PR #1 (#1 (comment)), a performance improvement was identified for the resume_rag_tool function.
Issue
Currently, the resume is processed and indexed on every query, which is inefficient for repeated use, especially when the content of the resume doesn't change frequently.
Proposed Solution
Implement a caching mechanism for the vector store:
- Add a global
_vector_storevariable to cache the FAISS index - Check if the vector store exists before creating a new one
- Only process and index the resume if the vector store isn't already cached
- Add proper logging for when a new vector store is created
Implementation Details
# Global variable to cache the vector store
_vector_store = None
@tool("resume_rag_tool")
def resume_rag_tool(input: str) -> str:
# Existing code...
try:
global _vector_store
# Use cached vector store if available
if _vector_store is not None:
retriever = _vector_store.as_retriever(search_kwargs={"k": 3})
else:
# Process and index the resume if not cached
# Add proper logging here
# Load and process documents...
# Create FAISS vector store
_vector_store = FAISS.from_documents(docs, embeddings)
retriever = _vector_store.as_retriever(search_kwargs={"k": 3})Additional Considerations
- Consider adding a timestamp or hash check to invalidate the cache if the resume file changes
- Ensure proper logging is implemented with the right imports
- Implement a way to force a refresh of the vector store if needed
This improvement will significantly enhance performance for repeated queries to the resume tool.
Reference: PR #1 discussion: #1 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels