Context based document search
1.0.0
โครงการนี้มีระบบสำหรับการค้นหาตามบริบทระหว่างเอกสารที่เก็บไว้ในฐานข้อมูลเวกเตอร์ การใช้โมเดลการฝังของ OpenAI และ Chroma เครื่องมือนี้ช่วยให้คุณค้นหาได้อย่างมีประสิทธิภาพผ่านการรวบรวมเอกสารข้อความและดึงผลลัพธ์ที่เกี่ยวข้องมากที่สุดตามแบบสอบถามที่กำหนด
Python 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 และ CALL 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." )