Context based document search
1.0.0
이 프로젝트는 벡터 데이터베이스에 저장된 문서에서 컨텍스트 기반 검색을 수행하기위한 시스템을 제공합니다. OpenAI의 임베딩 모델 및 크로마를 사용 하여이 도구를 사용하면 텍스트 문서 모음을 효율적으로 검색하고 주어진 쿼리를 기반으로 가장 관련성이 가장 높은 결과를 검색 할 수 있습니다.
파이썬 3.7 이상
Openai API 키
실행하여 필요한 패키지를 설치하십시오.
pip install -r requirements.txtgit clone https://github.com/your-username/contextual-documents-search.git cd contextual-documents-searchpython -m venv venv
source venv/bin/activate # On Windows: venvScriptsactivatepip install -r requirements.txtOPENAI_API_KEY = your_openai_api_key 검색하려는 .txt 파일 디렉토리를 준비하여 ./resumes 폴더에 배치하거나 코드에 다른 디렉토리를 지정하십시오.
기본 스크립트에서 VectorDBHandler 클래스를 인스턴스화하고 load_or_create_db() 호출하여 벡터 저장소를 초기화하십시오.
from dotenv import load_dotenv
from vector_db_handler import VectorDBHandler
# Load environment variables
load_dotenv ()
# Set up directory paths and collection name
files_directory = "./resumes"
persist_directory = "./vector_db"
collection_name = "resumes_collection"
# Initialize the vector database handler
vector_db_handler = VectorDBHandler ( files_directory , persist_directory , collection_name )
# Load or create the vector store database
vector_db_handler . load_or_create_db ()
# Define the query for the search
query = "I am looking for a software engineer with OpenAI hard skill."
docs = vector_db_handler . query_vector_store ( query )
# Output the top result
if docs :
print ( "Top matching document:" )
print ( docs [ 0 ]. page_content )
else :
print ( "No matching documents found." )