البحث عن الملفات  |  Gemini API  |  Google AI for Developers التخطّي إلى المحتوى الرئيسي / English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Shqip Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어 الحصول على مفتاح واجهة برمجة التطبيقات كتاب الطبخ منتدى تسجيل الدخول المستندات مرجع واجهة برمجة التطبيقات Gemini API المستندات مرجع واجهة برمجة التطبيقات الحصول على مفتاح واجهة برمجة التطبيقات كتاب الطبخ منتدى البدء نظرة عامة البدء مفاتيح واجهة برمجة التطبيقات المكتبات الأسعار واجهة برمجة التطبيقات Interactions API إعداد وكيل البرمجة الطرُز كل الطرز الحالي: Gemini 3.5 Nano Banana Veo Gemini Omni Flash ‫Lyria 3 Lyria RealTime Imagen نص إلى كلام الفيديوهات المباشرة الترجمة المباشرة التضمينات روبوتيات الإمكانات الأساسية نص صورة إنشاء الصور 🍌 فهم الصور فيديو نظرة عامة على الفيديو فهم الفيديو المستندات الكلام والصوت إنشاء الكلام فهم الصوت جارٍ التفكير جارٍ التفكير توقيعات الأفكار النتائج المنظَّمة استدعاء الدالة سياق طويل الوكلاء نظرة عامة التشغيل السريع Antigravity Agent إنشاء وكلاء مُدارين البيئات Deep Research Agent الأدوات نظرة عامة Google Search Google Maps تنفيذ الرمز البرمجي سياق عنوان URL استخدام الكمبيوتر البحث عن الملفات الجمع بين "الأدوات" و"استدعاء الدالة" واجهة برمجة التطبيقات للبث المباشر نظرة عامة البدء بدء استخدام حزمة تطوير البرامج (SDK) للذكاء الاصطناعي التوليدي بدء استخدام WebSockets غير المعالجة الإمكانات الترجمة المباشرة استخدام الأداة إدارة الجلسة الرموز المميّزة المؤقتة أفضل الممارسات التحسين نظرة عامة Batch API الردّ التلقائي على الويب الاستنتاج المرن الاستدلال حسب الأولوية التخزين المؤقت للسياق الأدلة بث التنفيذ في الخلفية إدخال الملف أساليب الإدخال واجهة برمجة تطبيقات الملفات التوافق مع OpenAI درجة دقة الوسائط احتساب الرموز المميّزة هندسة الطلبات السجلّات ومجموعات البيانات بدء استخدام السجلات تسجيل البيانات ومشاركتها دفاع إعدادات الأمن الشخصي إرشادات السلامة الأطر LangChain وLangGraph CrewAI LlamaIndex Vercel AI SDK زماني الموارد ملاحظات حول الإصدار الميزات التي سيتم إيقافها نهائيًا النقل نقل البيانات إلى حزمة تطوير برامج الذكاء الاصطناعي التوليدي نقل البيانات إلى Interactions API التغييرات غير المتوافقة في التفاعلات (مايو 2026) حدود المعدل معلومات الفوترة تحديد المشاكل في واجهة برمجة التطبيقات وحلّها الحالة عمليات الدمج مع الشركاء والمكتبات Google AI Studio التشغيل السريع البرمجة الوصفية في "وضع الإنشاء" تطوير تطبيقات الحزمة الكاملة إنشاء تطبيقات Android نشر تطبيقك الوكلاء في مساحة تجربة الذكاء الاصطناعي في Studio تجربة LearnLM تحديد المشاكل وحلّها إمكانية الوصول لمستخدمي Workspace Google Cloud Platform Gemini Enterprise Agent Platform Gemini API مصادقة OAuth السياسات بنود الخدمة المناطق المتاحة رصد إساءة الاستخدام الملاحظات في "تعليقات Google" أصبحت Interactions API متاحة الآن للجميع. ننصحك باستخدام واجهة برمجة التطبيقات هذه للوصول إلى جميع أحدث الميزات والنماذج. Google uses AI technology to translate content into your preferred language. AI translations can contain errors. الصفحة الرئيسية Gemini API المستندات إرسال ملاحظات البحث عن الملفات ملاحظة: يغطي هذا الإصدار من الصفحة واجهة برمجة التطبيقات Interactions API. يمكنك استخدام زر التبديل في هذه الصفحة للانتقال إلى إصدار صفحة generateContent API. تتيح Gemini API ميزة "التوليد المعزّز بالاسترجاع" من خلال أداة "البحث في الملفات". تستورد ميزة "البحث في الملفات" بياناتك وتقسّمها إلى أجزاء وتفهرسها لتتيح استرجاع المعلومات ذات الصلة بسرعة استنادًا إلى طلب مقدَّم. يتم بعد ذلك استخدام هذه المعلومات المسترجَعة كسياق للنموذج، ما يتيح له تقديم إجابات أكثر دقة وملاءمةً. تتوفّر أيضًا إمكانات البحث المتعدّد الوسائط في ميزة "البحث عن الملفات"، وذلك من خلال تضمين النصوص باستخدام gemini-embedding-001، وتضمين الصور والوسائط المتعددة باستخدام gemini-embedding-2. ملاحظة: لا تتوفّر حاليًا تنسيقات الصوت والفيديو. تكون عملية تخزين الملفات وإنشاء عمليات التضمين عند وقت طلب البحث مجانية، ولن تدفع إلا مقابل إنشاء عمليات التضمين عند فهرسة ملفاتك لأول مرة وتكلفة الرموز المميزة العادية الخاصة بمدخلات ومخرجات نموذج Gemini. يساهم نموذج الفوترة الجديد هذا في تسهيل عملية إنشاء &quot;أداة البحث عن الملفات&quot; وتوسيع نطاقها، كما يقلّل من تكلفتها. راجِع قسم الأسعار لمعرفة التفاصيل. التحميل مباشرةً إلى "متجر البحث عن الملفات" يوضّح المثال التالي كيفية تحميل ملف مباشرةً إلى مخزن البحث عن الملفات: Python from google import genai from google.genai import types import time client = genai.Client() file_search_store = client.file_search_stores.create( config={ 'display_name': 'your-fileSearchStore-name', 'embedding_model': 'models/gemini-embedding-2' } ) operation = client.file_search_stores.upload_to_file_search_store( file='sample.txt', file_search_store_name=file_search_store.name, config={ 'display_name' : 'display-file-name', } ) while not operation.done: time.sleep(5) operation = client.operations.get(operation) interaction = client.interactions.create( model="gemini-3.5-flash", input="Can you tell me about [insert question]", tools=[{ "type": "file_search", "file_search_store_names": [file_search_store.name] }] ) for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.type == "text": print(content_block.text) if content_block.annotations: print("\nSources:") for annotation in content_block.annotations: if annotation.type == "file_citation": print(f" - {annotation.file_name}: {annotation.source}") JavaScript import { GoogleGenAI } from '@google/genai'; const ai = new GoogleGenAI({}); async function run() { const fileSearchStore = await ai.fileSearchStores.create({ config: { displayName: 'your-fileSearchStore-name', embeddingModel: 'models/gemini-embedding-2' } }); let operation = await ai.fileSearchStores.uploadToFileSearchStore({ file: 'file.txt', fileSearchStoreName: fileSearchStore.name, config: { displayName: 'file-name', } }); while (!operation.done) { await new Promise(resolve => setTimeout(resolve, 5000)); operation = await ai.operations.get({ operation }); } const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "Can you tell me about [insert question]", tools: [{ type: "file_search", file_search_store_names: [fileSearchStore.name] }] }); for (const step of interaction.steps) { if (step.type === 'model_output') { for (const contentBlock of step.content) { if (contentBlock.type === 'text') { console.log(contentBlock.text); if (contentBlock.annotations) { console.log("\nSources:"); for (const annotation of contentBlock.annotations) { if (annotation.type === 'file_citation') { console.log(` - ${annotation.file_name}: ${annotation.source}`); } } } } } } } } run(); REST # 1. Create a File Search store curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=$GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "displayName": "your-file-search-store-name", "embeddingModel": "models/gemini-embedding-2" }' > store_res.json FILE_SEARCH_STORE_NAME=$(jq -r ".name" store_res.json) # 2. Upload directly to File Search store using resumable upload NUM_BYTES=$(wc -c < "sample.txt") curl "https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/$FILE_SEARCH_STORE_NAME:uploadToFileSearchStore?key=$GEMINI_API_KEY" \ -D upload-header.tmp \ -H "X-Goog-Upload-Protocol: resumable" \ -H "X-Goog-Upload-Command: start" \ -H "X-Goog-Upload-Header-Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Header-Content-Type: text/plain" \ -H "Content-Type: application/json" \ -d '{"displayName": "sample.txt"}' 2> /dev/null upload_url=$(grep -i "x-goog-upload-url: " upload-header.tmp | cut -d" " -f2 | tr -d "\r") rm upload-header.tmp curl "${upload_url}" \ -H "Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Offset: 0" \ -H "X-Goog-Upload-Command: upload, finalize" \ --data-binary "@sample.txt" 2> /dev/null > upload_response.json cat upload_response.json # 3. Query using the File Search store curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3.5-flash", "input": "Can you tell me about [insert question]", "tools": [{ "type": "file_search", "file_search_store_names": ["'"$FILE_SEARCH_STORE_NAME"'"] }] }' راجِع مرجع واجهة برمجة التطبيقات uploadToFileSearchStore للحصول على مزيد من المعلومات. استيراد الملفات بدلاً من ذلك، يمكنك تحميل ملف حالي واستيراده إلى متجر البحث عن الملفات باتّباع الخطوات التالية: Python from google import genai from google.genai import types import time client = genai.Client() sample_file = client.files.upload(file='sample.txt', config={'display_name': 'display_file_name'}) file_search_store = client.file_search_stores.create( config={ 'display_name': 'your-fileSearchStore-name', 'embedding_model': 'models/gemini-embedding-2' } ) operation = client.file_search_stores.import_file( file_search_store_name=file_search_store.name, file_name=sample_file.name ) while not operation.done: time.sleep(5) operation = client.operations.get(operation) interaction = client.interactions.create( model="gemini-3.5-flash", input="Can you tell me about [insert question]", tools=[{ "type": "file_search", "file_search_store_names": [file_search_store.name] }] ) for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.type == "text": print(content_block.text) JavaScript import { GoogleGenAI } from '@google/genai'; const ai = new GoogleGenAI({}); async function run() { const sampleFile = await ai.files.upload({ file: 'sample.txt', config: { displayName: 'file-name' } }); const fileSearchStore = await ai.fileSearchStores.create({ config: { displayName: 'your-fileSearchStore-name', embeddingModel: 'models/gemini-embedding-2' } }); let operation = await ai.fileSearchStores.importFile({ fileSearchStoreName: fileSearchStore.name, fileName: sampleFile.name }); while (!operation.done) { await new Promise(resolve => setTimeout(resolve, 5000)); operation = await ai.operations.get({ operation: operation }); } const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "Can you tell me about [insert question]", tools: [{ type: "file_search", file_search_store_names: [fileSearchStore.name] }] }); for (const step of interaction.steps) { if (step.type === 'model_output') { for (const contentBlock of step.content) { if (contentBlock.type === 'text') { console.log(contentBlock.text); } } } } } run(); REST # 1. Upload file using the Files API NUM_BYTES=$(wc -c < "sample.txt") curl "https://generativelanguage.googleapis.com/upload/v1beta/files?key=$GEMINI_API_KEY" \ -D upload-header.tmp \ -H "X-Goog-Upload-Protocol: resumable" \ -H "X-Goog-Upload-Command: start" \ -H "X-Goog-Upload-Header-Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Header-Content-Type: text/plain" \ -H "Content-Type: application/json" \ -d '{"file": {"displayName": "sample.txt"}}' 2> /dev/null upload_url=$(grep -i "x-goog-upload-url: " upload-header.tmp | cut -d" " -f2 | tr -d "\r") rm upload-header.tmp curl "${upload_url}" \ -H "Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Offset: 0" \ -H "X-Goog-Upload-Command: upload, finalize" \ --data-binary "@sample.txt" 2> /dev/null > file_info.json FILE_NAME=$(jq -r ".file.name" file_info.json) # 2. Create a File Search store curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=$GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "displayName": "your-file-search-store-name", "embeddingModel": "models/gemini-embedding-2" }' > store_res.json FILE_SEARCH_STORE_NAME=$(jq -r ".name" store_res.json) # 3. Import the file into the File Search store curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/$FILE_SEARCH_STORE_NAME:importFile?key=$GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"fileName": "'"$FILE_NAME"'"}' # 4. Query using the File Search store curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3.5-flash", "input": "Can you tell me about [insert question]", "tools": [{ "type": "file_search", "file_search_store_names": ["'"$FILE_SEARCH_STORE_NAME"'"] }] }' راجِع مرجع واجهة برمجة التطبيقات importFile للحصول على مزيد من المعلومات. إعدادات التقسيم عند استيراد ملف إلى مستودع &quot;البحث عن الملفات&quot;، يتم تقسيمه تلقائيًا إلى أجزاء، وتضمينه، وفهرسته، وتحميله إلى مستودع &quot;البحث عن الملفات&quot;. إذا كنت بحاجة إلى المزيد من التحكّم في استراتيجية التقسيم، يمكنك تحديد إعداد chunking_config لضبط الحد الأقصى لعدد الرموز المميزة لكل جزء والحد الأقصى لعدد الرموز المميزة المتداخلة. Python from google import genai from google.genai import types import time client = genai.Client() operation = client.file_search_stores.upload_to_file_search_store( file_search_store_name=file_search_store.name, file='sample.txt', config={ 'chunking_config': { 'white_space_config': { 'max_tokens_per_chunk': 200, 'max_overlap_tokens': 20 } } } ) while not operation.done: time.sleep(5) operation = client.operations.get(operation) print("Custom chunking complete.") JavaScript import { GoogleGenAI } from '@google/genai'; const ai = new GoogleGenAI({}); let operation = await ai.fileSearchStores.uploadToFileSearchStore({ file: 'file.txt', fileSearchStoreName: fileSearchStore.name, config: { displayName: 'file-name', chunkingConfig: { whiteSpaceConfig: { maxTokensPerChunk: 200, maxOverlapTokens: 20 } } } }); while (!operation.done) { await new Promise(resolve => setTimeout(resolve, 5000)); operation = await ai.operations.get({ operation }); } console.log("Custom chunking complete."); REST NUM_BYTES=$(wc -c < "sample.txt") curl "https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/$FILE_SEARCH_STORE_NAME:uploadToFileSearchStore?key=$GEMINI_API_KEY" \ -D upload-header.tmp \ -H "X-Goog-Upload-Protocol: resumable" \ -H "X-Goog-Upload-Command: start" \ -H "X-Goog-Upload-Header-Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Header-Content-Type: text/plain" \ -H "Content-Type: application/json" \ -d '{ "displayName": "sample.txt", "chunkingConfig": { "whiteSpaceConfig": { "maxTokensPerChunk": 200, "maxOverlapTokens": 20 } } }' 2> /dev/null upload_url=$(grep -i "x-goog-upload-url: " upload-header.tmp | cut -d" " -f2 | tr -d "\r") rm upload-header.tmp curl "${upload_url}" \ -H "Content-Length: $NUM_BYTES" \ -H "X-Goog-Upload-Offset: 0" \ -H "X-Goog-Upload-Command: upload, finalize" \ --data-binary "@sample.txt" 2> /dev/null > upload_response.json cat upload_response.json لاستخدام متجر "بحث الملفات"، مرِّره كأداة إلى طريقة interactions.create، كما هو موضّح في المثالَين تحميل واستيراد. آلية العمل تستخدم ميزة &quot;البحث عن الملفات&quot; أسلوبًا يُعرف باسم البحث الدلالي للعثور على معلومات ذات صلة بطلب المستخدم. على عكس البحث العادي المستند إلى الكلمات الرئيسية، يفهم البحث الدلالي المعنى والسياق الخاصين بطلب البحث. عند استيراد ملف، يتم تحويله إلى تمثيلات رقمية تُعرف باسم التضمينات، وهي تلتقط المعنى الدلالي للمحتوى الذي تم تحميله. يتم تخزين هذه التضمينات في قاعدة بيانات متخصصة في "البحث عن الملفات". عند إجراء طلب بحث، يتم تحويله أيضًا إلى تضمين. بعد ذلك، يجري النظام عملية &quot;البحث في الملفات&quot; للعثور على أجزاء المستندات الأكثر تشابهًا وملاءمةً من مستودع &quot;البحث في الملفات&quot;. لا تتوفّر مدة بقاء (TTL) للتضمينات، بل تبقى متاحة إلى أن يتم حذفها يدويًا أو عند إيقاف النموذج نهائيًا. أما الملفات، فيتم حذفها بعد 48 ساعة. في ما يلي تفصيل لعملية استخدام واجهة برمجة التطبيقات File Search uploadToFileSearchStore: إنشاء مستودع بحث في الملفات: يحتوي مستودع بحث في الملفات على البيانات المعالَجة من ملفاتك. وهي الحاوية الثابتة لعمليات التضمين التي سيتم إجراء البحث الدلالي عليها. تحميل ملف واستيراده إلى مستودع &quot;البحث عن الملفات&quot;: يمكنك تحميل ملف واستيراد النتائج إلى مستودع &quot;البحث عن الملفات&quot; في الوقت نفسه. يؤدي ذلك إلى إنشاء كائن File مؤقت، وهو مرجع إلى المستند الأولي. يتم بعد ذلك تقسيم هذه البيانات إلى أجزاء، وتحويلها إلى تضمينات في &quot;بحث الملفات&quot;، وفهرستها. يتم حذف عنصر File بعد 48 ساعة، بينما يتم تخزين البيانات التي تم استيرادها إلى مساحة تخزين &quot;البحث عن الملفات&quot; لأجل غير مسمى إلى أن تختار حذفها. طلب البحث باستخدام "البحث عن الملفات": أخيرًا، يمكنك استخدام أداة FileSearch في مكالمة generateContent. في إعدادات الأداة، عليك تحديد FileSearchRetrievalResource، يشير إلى FileSearchStore الذي تريد البحث فيه. يطلب ذلك من النموذج إجراء بحث دلالي في مخزن &quot;بحث الملفات&quot; المحدّد للعثور على المعلومات ذات الصلة التي يمكنه الاستناد إليها في رده. عملية الفهرسة والبحث في &quot;بحث الملفات&quot; في هذا المخطط، يمثّل الخط المتقطّع من المستندات إلى نموذج التضمين (باستخدام gemini-embedding-001) واجهة برمجة التطبيقات uploadToFileSearchStore (مع تجاوز تخزين الملفات). في حال عدم توفّر ذلك، يؤدي استخدام Files API لإنشاء الملفات بشكل منفصل ثم استيرادها إلى نقل عملية الفهرسة من المستندات إلى مساحة تخزين الملفات ثم إلى نموذج التضمين. متاجر "بحث الملفات" مستودع "البحث عن الملفات" هو حاوية لتضمينات المستندات. في حين يتم حذف الملفات الأولية التي تم تحميلها من خلال File API بعد 48 ساعة، يتم تخزين البيانات التي تم استيرادها إلى مستودع &quot;بحث الملفات&quot; إلى أجل غير مسمى إلى أن تحذفها يدويًا. يمكنك إنشاء عدة مستودعات بحث في الملفات لتنظيم مستنداتك. تتيح لك واجهة برمجة التطبيقات FileSearchStore إنشاء قوائم بملفاتك وحذفها والحصول عليها وإدارتها في متاجر البحث. يتم تحديد نطاق أسماء متاجر "البحث في الملفات" على مستوى العالم. في ما يلي بعض الأمثلة على كيفية إدارة متاجر "بحث الملفات": Python file_search_store = client.file_search_stores.create( config={ 'display_name': 'myfilesearchstore123', 'embedding_model': 'models/gemini-embedding-2' } ) for store in client.file_search_stores.list(): print(store) my_file_search_store = client.file_search_stores.get(name=file_search_store.name) client.file_search_stores.delete(name=file_search_store.name, config={'force': True}) JavaScript const fileSearchStore = await ai.fileSearchStores.create({ config: { displayName: 'myfilesearchstore123', embeddingModel: 'models/gemini-embedding-2' } }); const fileSearchStores = await ai.fileSearchStores.list(); for await (const store of fileSearchStores) { console.log(store); } const myFileSearchStore = await ai.fileSearchStores.get({ name: fileSearchStore.name }); await ai.fileSearchStores.delete({ name: fileSearchStore.name, config: { force: true } }); REST curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "displayName": "My Store", "embedding_model": "models/gemini-embedding-2" }' curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/myfilesearchstore123?key=${GEMINI_API_KEY}" curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/myfilesearchstore123?key=${GEMINI_API_KEY}" مستندات "البحث في الملفات" يمكنك إدارة المستندات الفردية في مخازن الملفات باستخدام واجهة برمجة التطبيقات File Search Documents من أجل list كل مستند في مخزن بحث الملفات، وget معلومات حول مستند، وdelete مستند حسب الاسم. Python for document_in_store in client.file_search_stores.documents.list(parent='fileSearchStores/myfilesearchstore123'): print(document_in_store) file_search_document = client.file_search_stores.documents.get(name='fileSearchStores/myfilesearchstore123/documents/sampletxt123') print(file_search_document) client.file_search_stores.documents.delete(name='fileSearchStores/myfilesearchstore123/documents/sampletxt123', config={'force': True}) JavaScript const documents = await ai.fileSearchStores.documents.list({ parent: 'fileSearchStores/myfilesearchstore123' }); for await (const doc of documents) { console.log(doc); } const fileSearchDocument = await ai.fileSearchStores.documents.get({ name: 'fileSearchStores/myfilesearchstore123/documents/sampletxt123' }); await ai.fileSearchStores.documents.delete({ name: 'fileSearchStores/myfilesearchstore123/documents/sampletxt123', config: { force: true } }); REST curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/myfilesearchstore123/documents?key=${GEMINI_API_KEY}" curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/myfilesearchstore123/documents/sampletxt123?key=${GEMINI_API_KEY}" curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/myfilesearchstore123/documents/sampletxt123?key=${GEMINI_API_KEY}&force=true" البيانات الوصفية للملف يمكنك إضافة بيانات وصفية مخصّصة إلى ملفاتك للمساعدة في فلترتها أو تقديم سياق إضافي. بيانات التعريف هي مجموعة من أزواج المفتاح/القيمة. Python op = client.file_search_stores.import_file( file_search_store_name=file_search_store.name, file_name=sample_file.name, config={ 'custom_metadata': [ {"key": "author", "string_value": "Robert Graves"}, {"key": "year", "numeric_value": 1934} ] } ) JavaScript let operation = await ai.fileSearchStores.importFile({ fileSearchStoreName: fileSearchStore.name, fileName: sampleFile.name, config: { customMetadata: [ { key: "author", stringValue: "Robert Graves" }, { key: "year", numericValue: 1934 } ] } }); يكون ذلك مفيدًا عندما يكون لديك مستندات متعددة في متجر &quot;بحث الملفات&quot; وتريد البحث في مجموعة فرعية منها فقط. Python interaction = client.interactions.create( model="gemini-3.5-flash", input="Tell me about the book 'I, Claudius'", tools=[{ "type": "file_search", "file_search_store_names": [file_search_store.name], "metadata_filter": 'author="Robert Graves"', }] ) for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.type == "text": print(content_block.text) JavaScript const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "Tell me about the book 'I, Claudius'", tools: [{ type: "file_search", file_search_store_names: [fileSearchStore.name], metadata_filter: 'author="Robert Graves"', }] }); for (const step of interaction.steps) { if (step.type === 'model_output') { for (const contentBlock of step.content) { if (contentBlock.type === 'text') { console.log(contentBlock.text); } } } } REST curl "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H 'Content-Type: application/json' \ -X POST \ -d '{ "model": "gemini-3.5-flash", "input": [{"type": "text", "text": "Tell me about the book I, Claudius"}], "tools": [{ "type": "file_search", "file_search_store_names": ["'$STORE_NAME'"], "metadata_filter": "author = \"Robert Graves\"" }] }' 2> /dev/null > response.json cat response.json يمكنك الاطّلاع على إرشادات حول تنفيذ بنية فلتر القائمة metadata_filter على google.aip.dev/160. البحث المتعدد الوسائط في الملفات تتيح لك ميزة "البحث المتعدد الوسائط في الملفات" تضمين الصور والبحث فيها بشكلٍ مدمج، ما يتيح إنشاء تطبيقات غنية ومتعددة الوسائط تستخدم "التوليد المعزّز بالاسترجاع". ضبط نموذج التضمين عند إنشاء FileSearchStore، عليك تجاهل نموذج التضمين التلقائي النصي فقط واستخدام نموذج متعدد الوسائط. استخدِم models/gemini-embedding-2 لمعالجة كل من النص والصور. Python store = client.file_search_stores.create( config={ "display_name": "Multimodal Catalog", "embedding_model": "models/gemini-embedding-2", } ) JavaScript const fileSearchStore = await ai.fileSearchStores.create({ config: { displayName: "Multimodal Catalog", embeddingModel: "models/gemini-embedding-2", }, }); REST curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=$GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "display_name": "Multimodal Catalog", "embedding_model": "models/gemini-embedding-2" }' تحميل صور بعد إنشاء المتجر باستخدام نموذج التضمين المتعدّد الوسائط، يمكنك تحميل ملفات الصور مباشرةً باستخدام واجهات برمجة التطبيقات نفسها الموضّحة في التحميل مباشرةً إلى متجر "بحث الملفات" أو استيراد الملفات. متطلبات ملف الصورة: يجب ألا تزيد دقة ملفات الصور عن 4K x 4K بكسل. التنسيقات المتوافقة هي PNG وJPEG. الاقتباسات عند استخدام &quot;البحث عن الملفات&quot;، قد يتضمّن ردّ النموذج اقتباسات تحدّد الأجزاء من المستندات التي حمّلتها والتي تم استخدامها لإنشاء الإجابة. ويساعد ذلك في التحقّق من صحة المعلومات. يمكنك الوصول إلى معلومات الاقتباس من خلال السمة annotations داخل خطوات model_output في مربّعات content الخاصة بالردّ. Python for step in interaction.steps: if step.type == 'model_output': for content in step.content: if content.type == 'text' and content.annotations: print(content.annotations) JavaScript for (const step of interaction.steps) { if (step.type === 'model_output') { for (const contentBlock of step.content) { if (contentBlock.type === 'text' && contentBlock.annotations) { console.log(JSON.stringify(contentBlock.annotations, null, 2)); } } } } REST { "steps": [ { "type": "model_output", "content": [ { "type": "text", "text": "...", "annotations": [ { "type": "file_citation", "file_name": "sample.txt", "source": "..." } ] } ] } ] } للحصول على معلومات تفصيلية حول بنية الاقتباسات، يُرجى الاطّلاع على مرجع واجهة برمجة التطبيقات للتفاعلات. أرقام الصفحات عند استخدام ميزة "البحث في الملفات" مع المستندات التي تتضمّن صفحات (مثل ملفات PDF)، قد يتضمّن ردّ النموذج رقم الصفحة التي تم العثور على المعلومات فيها. يمكنك الوصول إلى هذه المعلومات من خلال السمة page_number الخاصة بالتعليق التوضيحي file_citation. Python for step in interaction.steps: if step.type == "model_output": for content in step.content: if content.type == "text" and content.annotations: for annotation in content.annotations: if annotation.type == "file_citation" and annotation.page_number: print(f"Cited Page: {annotation.page_number}") JavaScript for (const step of interaction.steps) { if (step.type === 'model_output') { for (const block of step.content) { if (block.type === 'text' && block.annotations) { for (const annotation of block.annotations) { if (annotation.type === 'file_citation' && annotation.pageNumber) { console.log(`Cited Page: ${annotation.pageNumber}`); } } } } } } REST { "steps": [ { "type": "model_output", "content": [ { "type": "text", "text": "...", "annotations": [ { "type": "file_citation", "file_name": "document.pdf", "page_number": 1, "source": "..." } ] } ] } ] } اقتباسات من الوسائط عندما يشير النموذج إلى جزء من صورة أثناء الإنشاء، تعرض واجهة برمجة التطبيقات تعليقًا توضيحيًا من النوع file_citation في التعليقات التوضيحية يتضمّن media_id. يمكنك استخدام هذا المعرّف لتنزيل جزء الصورة الذي أشار إليه النموذج. يكون media_id هذا ثابتًا في طلبات البحث المتعددة، ما يتيح لك استرداد الصورة نفسها أو تخزينها مؤقتًا بشكل موثوق باستخدام المعرّف. المقتطف التالي هو مثال على خطوة استجابة REST: { "type": "model_output", "content": [ { "type": "text", "text": "...", "annotations": [ { "type": "file_citation", "file_name": "product_image", "media_id": "fileSearchStores/my-store-123/media/BlobId-456" } ] } ] } توضّح مقتطفات الرموز البرمجية التالية كيفية استرداد media_id وتنزيل الوسائط: Python for step in interaction.steps: if step.type == "model_output": for content in step.content: if content.type == "text" and content.annotations: for annotation in content.annotations: if annotation.type == "file_citation" and annotation.media_id: print(f"Cited Media ID: {annotation.media_id}") blob_content = client.file_search_stores.download_media( media_id=annotation.media_id ) JavaScript for (const step of interaction.steps) { if (step.type === 'model_output') { for (const block of step.content) { if (block.type === 'text' && block.annotations) { for (const annotation of block.annotations) { if (annotation.type === 'file_citation' && annotation.mediaId) { console.log(`Cited Media ID: ${annotation.mediaId}`); const blobContent = await ai.fileSearchStores.downloadMedia(annotation.mediaId); } } } } } } REST curl -X GET "https://generativelanguage.googleapis.com/v1/fileSearchStores/my-store-123/media/BlobId-456" \ -H "x-goog-api-key: $GEMINI_API_KEY" البيانات الوصفية المخصّصة إذا أضفت بيانات وصفية مخصّصة إلى ملفاتك، يمكنك الوصول إليها في التعليقات التوضيحية الخاصة برد النموذج. ويكون ذلك مفيدًا في تمرير سياق إضافي (مثل عناوين URL أو أرقام الصفحات أو المؤلّفين) من المستندات المصدر إلى منطق التطبيق. يحتوي كل تعليق توضيحي للاقتباس من النوع file_citation على هذه البيانات الوصفية المخصّصة. Python interaction = client.interactions.create( model="gemini-3.5-flash", input="Tell me about [insert question]", tools=[{ "type": "file_search", "file_search_store_names": [file_search_store.name] }] ) for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.annotations: for annotation in content_block.annotations: print(annotation) JavaScript const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "Tell me about [insert question]", tools: [{ type: "file_search", file_search_store_names: [fileSearchStore.name] }] }); for (const step of interaction.steps) { if (step.type === 'model_output') { for (const contentBlock of step.content) { if (contentBlock.annotations) { contentBlock.annotations.forEach((annotation) => { console.log(annotation); }); } } } } REST { "steps": [ { "type": "model_output", "content": [ { "type": "text", "text": "...", "annotations": [ { "file_name": "...", "source": "...", "custom_metadata": [ { "key": "author", "string_value": "Robert Graves" }, { "key": "year", "numeric_value": 1934 } ] } ] } ] } ] } ناتج منظَّم بدءًا من نماذج Gemini 3، يمكنك دمج أداة البحث عن الملفات مع النتائج المنظَّمة. Python from pydantic import BaseModel, Field class Money(BaseModel): amount: str = Field(description="The numerical part of the amount.") currency: str = Field(description="The currency of amount.") interaction = client.interactions.create( model="gemini-3.5-flash", input="What is the minimum hourly wage in Tokyo right now?", tools=[{ "type": "file_search", "file_search_store_names": [file_search_store.name] }], response_format={ "type": "text", "mime_type": "application/json", "schema": Money.model_json_schema() }, ) result = Money.model_validate_json(interaction.output_text) print(result) JavaScript import { z } from "zod"; const moneyJsonSchema = { type: "object", properties: { amount: { type: "string", description: "The numerical part of the amount." }, currency: { type: "string", description: "The currency of amount." } }, required: ["amount", "currency"] }; const moneySchema = z.fromJSONSchema(moneyJsonSchema); async function run() { const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "What is the minimum hourly wage in Tokyo right now?", tools: [{ type: "file_search", file_search_store_names: [fileSearchStore.name], }], response_format: { type: 'text', mime_type: 'application/json', schema: moneyJsonSchema }, }); const result = moneySchema.parse(JSON.parse(interaction.output_text)); console.log(result); } run(); REST curl "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H 'Content-Type: application/json' \ -X POST \ -d '{ "model": "gemini-3.5-flash", "input": "What is the minimum hourly wage in Tokyo right now?", "tools": [{ "type": "file_search", "file_search_store_names": ["$FILE_SEARCH_STORE_NAME"] }], "response_format": { "type": "text", "mime_type": "application/json", "schema": { "type": "object", "properties": { "amount": {"type": "string", "description": "The numerical part of the amount."}, "currency": {"type": "string", "description": "The currency of amount."} }, "required": ["amount", "currency"] } } }' النماذج المتوافقة تتيح الطُرز التالية استخدام ميزة "البحث عن الملفات": الطراز البحث عن الملفات Gemini 3.5 Flash ✔️ إصدار تجريبي من Gemini 3.1 Pro ✔️ ‫Gemini 3.1 Flash-Lite ✔️ معاينة Gemini 3 Flash ✔️ أنواع الملفات المعتمدة يتيح &quot;بحث الملفات&quot; مجموعة كبيرة من تنسيقات الملفات، والمدرَجة في الأقسام التالية. أنواع ملفات التطبيقات application/dart application/ecmascript application/json application/ms-java application/msword application/pdf application/sql application/typescript application/vnd.curl application/vnd.dart application/vnd.ibm.secure-container application/vnd.jupyter application/vnd.ms-excel application/vnd.oasis.opendocument.text application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.openxmlformats-officedocument.spreadsheetml.sheet application/vnd.openxmlformats-officedocument.wordprocessingml.document application/vnd.openxmlformats-officedocument.wordprocessingml.template application/x-csh application/x-hwp application/x-hwp-v5 application/x-latex application/x-php application/x-powershell application/x-sh application/x-shellscript application/x-tex application/x-zsh application/xml application/zip أنواع الملفات النصية text/1d-interleaved-parityfec text/RED text/SGML text/cache-manifest text/calendar text/cql text/cql-extension text/cql-identifier text/css text/csv text/csv-schema text/dns text/encaprtp text/enriched text/example text/fhirpath text/flexfec text/fwdred text/gff3 text/grammar-ref-list text/hl7v2 text/html text/javascript text/jcr-cnd text/jsx text/markdown text/mizar text/n3 text/parameters text/parityfec text/php text/plain text/provenance-notation text/prs.fallenstein.rst text/prs.lines.tag text/prs.prop.logic text/raptorfec text/rfc822-headers text/rtf text/rtp-enc-aescm128 text/rtploopback text/rtx text/sgml text/shaclc text/shex text/spdx text/strings text/t140 text/tab-separated-values text/texmacs text/troff text/tsv text/tsx text/turtle text/ulpfec text/uri-list text/vcard text/vnd.DMClientScript text/vnd.IPTC.NITF text/vnd.IPTC.NewsML text/vnd.a text/vnd.abc text/vnd.ascii-art text/vnd.curl text/vnd.debian.copyright text/vnd.dvb.subtitle text/vnd.esmertec.theme-descriptor text/vnd.exchangeable text/vnd.familysearch.gedcom text/vnd.ficlab.flt text/vnd.fly text/vnd.fmi.flexstor text/vnd.gml text/vnd.graphviz text/vnd.hans text/vnd.hgl text/vnd.in3d.3dml text/vnd.in3d.spot text/vnd.latex-z text/vnd.motorola.reflex text/vnd.ms-mediapackage text/vnd.net2phone.commcenter.command text/vnd.radisys.msml-basic-layout text/vnd.senx.warpscript text/vnd.sosi text/vnd.sun.j2me.app-descriptor text/vnd.trolltech.linguist text/vnd.wap.si text/vnd.wap.sl text/vnd.wap.wml text/vnd.wap.wmlscript text/vtt text/wgsl text/x-asm text/x-bibtex text/x-boo text/x-c text/x-c++hdr text/x-c++src text/x-cassandra text/x-chdr text/x-coffeescript text/x-component text/x-csh text/x-csharp text/x-csrc text/x-cuda text/x-d text/x-diff text/x-dsrc text/x-emacs-lisp text/x-erlang text/x-gff3 text/x-go text/x-haskell text/x-java text/x-java-properties text/x-java-source text/x-kotlin text/x-lilypond text/x-lisp text/x-literate-haskell text/x-lua text/x-moc text/x-objcsrc text/x-pascal text/x-pcs-gcd text/x-perl text/x-perl-script text/x-python text/x-python-script text/x-r-markdown text/x-rsrc text/x-rst text/x-ruby-script text/x-rust text/x-sass text/x-scala text/x-scheme text/x-script.python text/x-scss text/x-setext text/x-sfv text/x-sh text/x-siesta text/x-sos text/x-sql text/x-swift text/x-tcl text/x-tex text/x-vbasic text/x-vcalendar text/xml text/xml-dtd text/xml-external-parsed-entity text/yaml القيود Live API: لا تتوافق ميزة &quot;البحث عن الملفات&quot; مع Live API. عدم توافق الأدوات: لا يمكن دمج أدوات التأسيس المضمّنة مع بعضها البعض، على سبيل المثال، لا يمكن استخدام "البحث عن الملفات" في الوقت نفسه مع التأسيس باستخدام "بحث Google" أو سياق عنوان URL في الطلب نفسه. حدود معدّل الاستخدام تفرض واجهة برمجة التطبيقات "البحث عن الملفات" الحدود التالية لضمان استقرار الخدمة: الحدّ الأقصى لحجم الملف / الحدّ الأقصى لكل مستند: 100 ميغابايت إجمالي حجم مساحات تخزين "البحث عن الملفات" في المشروع (استنادًا إلى فئة المستخدم): الخطة المجانية: 1 غيغابايت المستوى 1: 10 غيغابايت المستوى 2: ‏100 غيغابايت المستوى 3: 1 تيرابايت اقتراح: يجب ألا يتجاوز حجم كل مستودع بيانات في "بحث الملفات" 20 غيغابايت لضمان أفضل أوقات استجابة ممكنة. ملاحظة: يتم احتساب الحد الأقصى لحجم مساحة التخزين في "بحث الملفات" في الخلفية، استنادًا إلى حجم البيانات التي تدخلها بالإضافة إلى عمليات التضمين التي يتم إنشاؤها وتخزينها معها. ويبلغ حجمها عادةً 3 أضعاف حجم بيانات الإدخال. الأسعار يتم تحصيل رسوم منك مقابل التضمينات في وقت الفهرسة استنادًا إلى أسعار التضمينات الحالية. تتوفر خدمة تخزين الأمتعة مجانًا. تكون تضمينات وقت طلب البحث مجانية. يتم تحصيل رسوم من الرموز المميزة للمستندات التي تم استرجاعها باعتبارها رموزًا مميزة للسياق عادية. الخطوات التالية انتقِل إلى مرجع واجهة برمجة التطبيقات File Search Stores وDocuments في File Search. إرسال ملاحظات إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0‏ ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0‏. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers‏. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين. تاريخ التعديل الأخير: 2026-07-07 (حسب التوقيت العالمي المتفَّق عليه) هل تريد مشاركة ملاحظاتك معنا؟ [[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2026-07-07 (حسب التوقيت العالمي المتفَّق عليه)"],[],[]] البنود الخصوصية Manage cookies English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Shqip Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어