بحث RAG في DOCX
DOCXSearchTool
Section titled “DOCXSearchTool”أداة DOCXSearchTool هي أداة RAG مصممة للبحث الدلالي داخل مستندات DOCX. تتيح للمستخدمين البحث بفعالية واستخراج المعلومات ذات الصلة من ملفات DOCX باستخدام عمليات بحث قائمة على الاستعلامات. هذه الأداة لا تُقدَّر بثمن لمهام تحليل البيانات وإدارة المعلومات والبحث، حيث تبسط عملية العثور على معلومات محددة داخل مجموعات مستندات كبيرة.
التثبيت
Section titled “التثبيت”قم بتثبيت حزمة crewai_tools بتنفيذ الأمر التالي في الطرفية:
uv pip install docx2txt 'crewai[tools]'يوضح المثال التالي تهيئة DOCXSearchTool للبحث داخل محتوى أي ملف DOCX أو بمسار ملف DOCX محدد.
from crewai_tools import DOCXSearchTool
# Initialize the tool to search within any DOCX file's contenttool = DOCXSearchTool()
# OR
# Initialize the tool with a specific DOCX file,# so the agent can only search the content of the specified DOCX filetool = DOCXSearchTool(docx='path/to/your/document.docx')المعاملات
Section titled “المعاملات”يمكن استخدام المعاملات التالية لتخصيص سلوك DOCXSearchTool:
| المعامل | النوع | الوصف |
|---|---|---|
| docx | string | اختياري. معامل يحدد مسار ملف DOCX المراد البحث فيه. إذا لم يُقدَّم أثناء التهيئة، تسمح الأداة بتحديد مسار محتوى أي ملف DOCX للبحث لاحقاً. |
النموذج والتضمينات المخصصة
Section titled “النموذج والتضمينات المخصصة”بشكل افتراضي، تستخدم الأداة OpenAI لكل من التضمينات والتلخيص. لتخصيص النموذج، يمكنك استخدام قاموس تكوين كما يلي:
from chromadb.config import Settings
tool = DOCXSearchTool( config={ "embedding_model": { "provider": "openai", "config": { "model": "text-embedding-3-small", # "api_key": "sk-...", }, }, "vectordb": { "provider": "chromadb", # or "qdrant" "config": { # "settings": Settings(persist_directory="/content/chroma", allow_reset=True, is_persistent=True), # from qdrant_client.models import VectorParams, Distance # "vectors_config": VectorParams(size=384, distance=Distance.COSINE), } }, })