تكامل Google Drive
نظرة عامة
Section titled “نظرة عامة”مكّن وكلاءك من إدارة الملفات والمجلدات عبر Google Drive. ارفع الملفات وحمّلها ونظّمها وشاركها، وأنشئ المجلدات، وبسّط سير عمل إدارة المستندات باستخدام الأتمتة المدعومة بالذكاء الاصطناعي.
المتطلبات الأساسية
Section titled “المتطلبات الأساسية”قبل استخدام تكامل Google Drive، تأكد من توفر ما يلي:
- حساب CrewAI AMP مع اشتراك فعّال
- حساب Google مع إمكانية الوصول إلى Google Drive
- ربط حساب Google الخاص بك عبر صفحة التكاملات
إعداد تكامل Google Drive
Section titled “إعداد تكامل Google Drive”1. ربط حساب Google الخاص بك
Section titled “1. ربط حساب Google الخاص بك”- انتقل إلى تكاملات CrewAI AMP
- ابحث عن Google Drive في قسم تكاملات المصادقة
- انقر على Connect وأكمل عملية OAuth
- امنح الصلاحيات اللازمة لإدارة الملفات والمجلدات
- انسخ رمز المؤسسة من إعدادات التكامل
2. تثبيت الحزمة المطلوبة
Section titled “2. تثبيت الحزمة المطلوبة”uv add crewai-tools3. إعداد متغير البيئة
Section titled “3. إعداد متغير البيئة”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"أو أضفه إلى ملف .env:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokenالإجراءات المتاحة
Section titled “الإجراءات المتاحة”google_drive/get_file
الوصف: الحصول على ملف بواسطة المعرّف من Google Drive.
المعاملات:
file_id(string, مطلوب): معرّف الملف المراد استرجاعه.
google_drive/list_files
الوصف: عرض قائمة الملفات في Google Drive.
المعاملات:
q(string, اختياري): سلسلة استعلام لتصفية الملفات (مثال: “name contains ‘report’”).page_size(integer, اختياري): الحد الأقصى لعدد الملفات المُرجعة (الافتراضي: 100، الحد الأقصى: 1000).page_token(string, اختياري): رمز لاسترجاع الصفحة التالية من النتائج.order_by(string, اختياري): ترتيب الفرز (مثال: “name”, “createdTime desc”, “modifiedTime”).spaces(string, اختياري): قائمة مفصولة بفواصل للمساحات المراد الاستعلام عنها (drive, appDataFolder, photos).
google_drive/upload_file
الوصف: رفع ملف إلى Google Drive.
المعاملات:
name(string, مطلوب): اسم الملف المراد إنشاؤه.content(string, مطلوب): محتوى الملف المراد رفعه.mime_type(string, اختياري): نوع MIME للملف (مثال: “text/plain”, “application/pdf”).parent_folder_id(string, اختياري): معرّف المجلد الأصلي حيث يجب إنشاء الملف.description(string, اختياري): وصف الملف.
google_drive/download_file
الوصف: تحميل ملف من Google Drive.
المعاملات:
file_id(string, مطلوب): معرّف الملف المراد تحميله.mime_type(string, اختياري): نوع MIME للتصدير (مطلوب لمستندات Google Workspace).
google_drive/create_folder
الوصف: إنشاء مجلد جديد في Google Drive.
المعاملات:
name(string, مطلوب): اسم المجلد المراد إنشاؤه.parent_folder_id(string, اختياري): معرّف المجلد الأصلي حيث يجب إنشاء المجلد الجديد.description(string, اختياري): وصف المجلد.
google_drive/delete_file
الوصف: حذف ملف من Google Drive.
المعاملات:
file_id(string, مطلوب): معرّف الملف المراد حذفه.
google_drive/share_file
الوصف: مشاركة ملف في Google Drive مع مستخدمين محددين أو جعله عاماً.
المعاملات:
file_id(string, مطلوب): معرّف الملف المراد مشاركته.role(string, مطلوب): الدور الممنوح بهذا الإذن (reader, writer, commenter, owner).type(string, مطلوب): نوع المستفيد (user, group, domain, anyone).email_address(string, اختياري): عنوان البريد الإلكتروني للمستخدم أو المجموعة المراد المشاركة معهم (مطلوب لأنواع user/group).domain(string, اختياري): النطاق المراد المشاركة معه (مطلوب لنوع domain).send_notification_email(boolean, اختياري): ما إذا كان يجب إرسال بريد إلكتروني إشعاري (الافتراضي: true).email_message(string, اختياري): رسالة نصية مخصصة لتضمينها في البريد الإلكتروني الإشعاري.
google_drive/update_file
الوصف: تحديث ملف موجود في Google Drive.
المعاملات:
file_id(string, مطلوب): معرّف الملف المراد تحديثه.name(string, اختياري): الاسم الجديد للملف.content(string, اختياري): المحتوى الجديد للملف.mime_type(string, اختياري): نوع MIME الجديد للملف.description(string, اختياري): الوصف الجديد للملف.add_parents(string, اختياري): قائمة مفصولة بفواصل لمعرّفات المجلدات الأصلية المراد إضافتها.remove_parents(string, اختياري): قائمة مفصولة بفواصل لمعرّفات المجلدات الأصلية المراد إزالتها.
أمثلة الاستخدام
Section titled “أمثلة الاستخدام”إعداد Agent أساسي لـ Google Drive
Section titled “إعداد Agent أساسي لـ Google Drive”from crewai import Agent, Task, Crew
# Create an agent with Google Drive capabilitiesdrive_agent = Agent( role="File Manager", goal="Manage files and folders in Google Drive efficiently", backstory="An AI assistant specialized in document and file management.", apps=['google_drive'] # All Google Drive actions will be available)
# Task to organize filesorganize_files_task = Task( description="List all files in the root directory and organize them into appropriate folders", agent=drive_agent, expected_output="Summary of files organized with folder structure")
# Run the taskcrew = Crew( agents=[drive_agent], tasks=[organize_files_task])
crew.kickoff()تصفية أدوات Google Drive المحددة
Section titled “تصفية أدوات Google Drive المحددة”from crewai import Agent, Task, Crew
# Create agent with specific Google Drive actions onlyfile_manager_agent = Agent( role="Document Manager", goal="Upload and manage documents efficiently", backstory="An AI assistant that focuses on document upload and organization.", apps=[ 'google_drive/upload_file', 'google_drive/create_folder', 'google_drive/share_file' ] # Specific Google Drive actions)
# Task to upload and share documentsdocument_task = Task( description="Upload the quarterly report and share it with the finance team", agent=file_manager_agent, expected_output="Document uploaded and sharing permissions configured")
crew = Crew( agents=[file_manager_agent], tasks=[document_task])
crew.kickoff()إدارة الملفات المتقدمة
Section titled “إدارة الملفات المتقدمة”from crewai import Agent, Task, Crew
file_organizer = Agent( role="File Organizer", goal="Maintain organized file structure and manage permissions", backstory="An experienced file manager who ensures proper organization and access control.", apps=['google_drive'])
# Complex task involving multiple Google Drive operationsorganization_task = Task( description=""" 1. List all files in the shared folder 2. Create folders for different document types (Reports, Presentations, Spreadsheets) 3. Move files to appropriate folders based on their type 4. Set appropriate sharing permissions for each folder 5. Create a summary document of the organization changes """, agent=file_organizer, expected_output="Files organized into categorized folders with proper permissions and summary report")
crew = Crew( agents=[file_organizer], tasks=[organization_task])
crew.kickoff()