জেমিনি এপিআই ফাইল সার্চ টুলের মাধ্যমে রিট্রিভ্যাল অগমেন্টেড জেনারেশন ("RAG") সক্ষম করে। ব্যবহারকারীর প্রম্পটের উপর ভিত্তি করে প্রাসঙ্গিক তথ্য দ্রুত পুনরুদ্ধার করতে ফাইল সার্চ আপনার ডেটা আমদানি, খণ্ড এবং সূচী করে। এই তথ্যটি মডেলের প্রসঙ্গ হিসাবে সরবরাহ করা হয়, যা মডেলটিকে আরও সঠিক এবং প্রাসঙ্গিক উত্তর প্রদান করতে দেয়।
আপনি uploadToFileSearchStore API ব্যবহার করে আপনার ফাইল অনুসন্ধান স্টোরে সরাসরি একটি বিদ্যমান ফাইল আপলোড করতে পারেন, অথবা আলাদাভাবে আপলোড করতে পারেন এবং তারপর একই সময়ে ফাইলটি তৈরি করতে চাইলে importFile ব্যবহার করতে পারেন।
সরাসরি ফাইল অনুসন্ধান স্টোরে আপলোড করুন
এই উদাহরণগুলি দেখায় কিভাবে সরাসরি একটি ফাইল স্টোরে একটি ফাইল আপলোড করতে হয়:
পাইথন
from google import genai
from google.genai import types
import time
client = genai.Client()
# Create the File Search store with an optional display name
file_search_store = client.file_search_stores.create(config={'display_name': 'your-fileSearchStore-name'})
# Upload and import a file into the File Search store, supply a file name which will be visible in citations
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',
}
)
# Wait until import is complete
while not operation.done:
time.sleep(5)
operation = client.operations.get(operation)
# Ask a question about the file
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="""Can you tell me about Robert Graves""",
config=types.GenerateContentConfig(
tools=[
file_search=(
file_search_store_names=[file_search_store.name]
)
]
)
)
print(response.text)
জাভাস্ক্রিপ্ট
const { GoogleGenAI } = require('@google/genai');
const ai = new GoogleGenAI({});
async function run() {
// Create the File Search store with an optional display name
const fileSearchStore = await ai.fileSearchStores.create({
config: { displayName: 'your-fileSearchStore-name' }
});
// Upload and import a file into the File Search store, supply a file name which will be visible in citations
let operation = await ai.fileSearchStores.uploadToFileSearchStore({
file: 'file.txt',
fileSearchStoreName: fileSearchStore.name,
config: {
displayName: 'file-name',
}
});
// Wait until import is complete
while (!operation.done) {
await new Promise(resolve => setTimeout(resolve, 5000));
operation = await ai.operations.get({ operation });
}
// Ask a question about the file
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: "Can you tell me about Robert Graves",
config: {
tools: [
{
fileSearch: {
fileSearchStoreNames: [fileSearchStore.name]
}
}
]
}
});
console.log(response.text);
}
run();
বিশ্রাম
FILE_PATH="path/to/sample.pdf"
MIME_TYPE=$(file -b --mime-type "${FILE_PATH}")
NUM_BYTES=$(wc -c < "${FILE_PATH}")
# Create a FileSearchStore
STORE_RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{ "displayName": "My Store" }')
# Extract the store name (format: fileSearchStores/xxxxxxx)
STORE_NAME=$(echo $STORE_RESPONSE | jq -r '.name')
# Initiate Resumable Upload to the Store
TMP_HEADER="upload-header.tmp"
curl -s -D "${TMP_HEADER}" \ "https://generativelanguage.googleapis.com/upload/v1beta/${STORE_NAME}:uploadToFileSearchStore?key=${GEMINI_API_KEY}" \
-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: ${MIME_TYPE}" \
-H "Content-Type: application/json" > /dev/null
# Extract upload_url from headers
UPLOAD_URL=$(grep -i "x-goog-upload-url: " "${TMP_HEADER}" | cut -d" " -f2 | tr -d "\r")
rm "${TMP_HEADER}"
# --- Upload the actual bytes ---
curl "${UPLOAD_URL}" \
-H "Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
--data-binary "@${FILE_PATH}" 2> /dev/null
# Generate content using the FileSearchStore
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "What does the research say about ..."}]
}],
"tools": [{
"file_search": { "file_search_store_names":["'$STORE_NAME'"] }
}]
}' 2> /dev/null > response.json
cat response.json
আরও তথ্যের জন্য uploadToFileSearchStore এর API রেফারেন্সটি দেখুন।
ফাইল আমদানি করা হচ্ছে
বিকল্পভাবে, আপনি একটি বিদ্যমান ফাইল আপলোড করতে পারেন এবং এটি আপনার ফাইল স্টোরে আমদানি করতে পারেন:
পাইথন
from google import genai
from google.genai import types
import time
client = genai.Client()
# Upload the file using the Files API, supply a file name which will be visible in citations
sample_file = client.files.upload(file='sample.txt', config={'name': 'display_file_name'})
# Create the File Search store with an optional display name
file_search_store = client.file_search_stores.create(config={'display_name': 'your-fileSearchStore-name'})
# Import the file into the File Search store
operation = client.file_search_stores.import_file(
file_search_store_name=file_search_store.name,
file_name=sample_file.name
)
# Wait until import is complete
while not operation.done:
time.sleep(5)
operation = client.operations.get(operation)
# Ask a question about the file
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="""Can you tell me about Robert Graves""",
config=types.GenerateContentConfig(
tools=[
file_search=(
file_search_store_names=[file_search_store.name]
)
]
)
)
print(response.text)
জাভাস্ক্রিপ্ট
const { GoogleGenAI } = require('@google/genai');
const ai = new GoogleGenAI({});
async function run() {
// Upload the file using the Files API, supply a file name which will be visible in citations
const sampleFile = await ai.files.upload({
file: 'sample.txt',
config: { name: 'file-name' }
});
// Create the File Search store with an optional display name
const fileSearchStore = await ai.fileSearchStores.create({
config: { displayName: 'your-fileSearchStore-name' }
});
// Import the file into the File Search store
let operation = await ai.fileSearchStores.importFile({
fileSearchStoreName: fileSearchStore.name,
fileName: sampleFile.name
});
// Wait until import is complete
while (!operation.done) {
await new Promise(resolve => setTimeout(resolve, 5000));
operation = await ai.operations.get({ operation: operation });
}
// Ask a question about the file
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: "Can you tell me about Robert Graves",
config: {
tools: [
{
fileSearch: {
fileSearchStoreNames: [fileSearchStore.name]
}
}
]
}
});
console.log(response.text);
}
run();
বিশ্রাম
FILE_PATH="path/to/sample.pdf"
MIME_TYPE=$(file -b --mime-type "${FILE_PATH}")
NUM_BYTES=$(wc -c < "${FILE_PATH}")
# Create a FileSearchStore
STORE_RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{ "displayName": "My Store" }')
STORE_NAME=$(echo $STORE_RESPONSE | jq -r '.name')
# Initiate Resumable Upload to the Store
TMP_HEADER="upload-header.tmp"
curl -s -X POST "https://generativelanguage.googleapis.com/upload/v1beta/files?key=${GEMINI_API_KEY}" \
-D "${TMP_HEADER}" \
-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: ${MIME_TYPE}" \
-H "Content-Type: application/json" 2> /dev/null
UPLOAD_URL=$(grep -i "x-goog-upload-url: " "${TMP_HEADER}" | cut -d" " -f2 | tr -d "\r")
rm "${TMP_HEADER}"
# Upload the actual bytes.
curl -s -X POST "${UPLOAD_URL}" \
-H "Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
--data-binary "@${FILE_PATH}" 2> /dev/null > file_info.json
file_uri=$(jq ".file.name" file_info.json)
# Import files into the file search store
operation_name=$(curl "https://generativelanguage.googleapis.com/v1beta/${STORE_NAME}:importFile?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"file_name":'$file_uri'
}' | jq -r .name)
# Wait for long running operation to complete
while true; do
# Get the full JSON status and store it in a variable.
status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "https://generativelanguage.googleapis.com/v1beta/${operation_name}")
# Check the "done" field from the JSON stored in the variable.
is_done=$(echo "${status_response}" | jq .done)
if [ "${is_done}" = "true" ]; then
break
fi
# Wait for 10 seconds before checking again.
sleep 10
done
# Generate content using the FileSearchStore
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${GEMINI_API_KEY}" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "What does the research say about ..."}]
}],
"tools": [{
"file_search": { "file_search_store_names":["'$STORE_NAME'"] }
}]
}' 2> /dev/null > response.json
cat response.json
আরও তথ্যের জন্য importFile এর API রেফারেন্সটি দেখুন।
চাঙ্কিং কনফিগারেশন
যখন আপনি একটি ফাইল ফাইল সার্চ স্টোরে ইম্পোর্ট করেন, তখন এটি স্বয়ংক্রিয়ভাবে খণ্ডে বিভক্ত হয়ে যায়, এমবেড করা হয়, সূচীবদ্ধ করা হয় এবং আপনার ফাইল সার্চ স্টোরে আপলোড করা হয়। যদি আপনার চাঙ্কিং কৌশলের উপর আরও নিয়ন্ত্রণের প্রয়োজন হয়, তাহলে আপনি প্রতি চাঙ্কে সর্বাধিক সংখ্যক টোকেন এবং সর্বাধিক সংখ্যক ওভারল্যাপিং টোকেন সেট করার জন্য একটি chunking_config সেটিং নির্দিষ্ট করতে পারেন।
পাইথন
# Upload and import and upload the file into the File Search store with a custom chunking configuration
operation = client.file_search_stores.upload_to_file_search_store(
file_search_store_name=file_search_store.name,
file_name=sample_file.name,
config={
'chunking_config': {
'white_space_config': {
'max_tokens_per_chunk': 200,
'max_overlap_tokens': 20
}
}
}
)
জাভাস্ক্রিপ্ট
// Upload and import and upload the file into the File Search store with a custom chunking configuration
let operation = await ai.fileSearchStores.uploadToFileSearchStore({
file: 'file.txt',
fileSearchStoreName: fileSearchStore.name,
config: {
displayName: 'file-name',
chunkingConfig: {
whiteSpaceConfig: {
maxTokensPerChunk: 200,
maxOverlapTokens: 20
}
}
}
});
বিশ্রাম
FILE_PATH="path/to/sample.pdf"
MIME_TYPE=$(file -b --mime-type "${FILE_PATH}")
NUM_BYTES=$(wc -c < "${FILE_PATH}")
# Create a FileSearchStore
STORE_RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{ "displayName": "My Store" }')
# Extract the store name (format: fileSearchStores/xxxxxxx)
STORE_NAME=$(echo $STORE_RESPONSE | jq -r '.name')
# Initiate Resumable Upload to the Store
TMP_HEADER="upload-header.tmp"
curl -s -D "${TMP_HEADER}" \ "https://generativelanguage.googleapis.com/upload/v1beta/${STORE_NAME}:uploadToFileSearchStore?key=${GEMINI_API_KEY}" \
-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: ${MIME_TYPE}" \
-H "Content-Type: application/json" > /dev/null
-d '{
"chunking_config": {
"white_space_config": {
"max_tokens_per_chunk": 200,
"max_overlap_tokens": 20
}
}
}'
# Extract upload_url from headers
UPLOAD_URL=$(grep -i "x-goog-upload-url: " "${TMP_HEADER}" | cut -d" " -f2 | tr -d "\r")
rm "${TMP_HEADER}"
# --- Upload the actual bytes ---
curl "${UPLOAD_URL}" \
-H "Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
--data-binary "@${FILE_PATH}" 2> /dev/null
আপনার ফাইল অনুসন্ধান স্টোর ব্যবহার করতে, এটিকে একটি টুল হিসেবে generateContent পদ্ধতিতে দিন, যেমনটি Upload এবং Import উদাহরণে দেখানো হয়েছে।
কিভাবে এটা কাজ করে
ফাইল অনুসন্ধান ব্যবহারকারীর প্রম্পটের সাথে প্রাসঙ্গিক তথ্য খুঁজে পেতে শব্দার্থিক অনুসন্ধান নামে একটি কৌশল ব্যবহার করে। ঐতিহ্যবাহী কীওয়ার্ড-ভিত্তিক অনুসন্ধানের বিপরীতে, শব্দার্থিক অনুসন্ধান আপনার প্রশ্নের অর্থ এবং প্রেক্ষাপট বোঝে।
যখন আপনি একটি ফাইল আমদানি করেন, তখন এটি এম্বেডিং নামক সংখ্যাসূচক উপস্থাপনায় রূপান্তরিত হয়, যা পাঠ্যের অর্থগত অর্থ ধারণ করে। এই এম্বেডিংগুলি একটি বিশেষায়িত ফাইল অনুসন্ধান ডাটাবেসে সংরক্ষণ করা হয়। আপনি যখন একটি কোয়েরি করেন, তখন এটি একটি এম্বেডিংয়ে রূপান্তরিত হয়। তারপর সিস্টেমটি ফাইল অনুসন্ধান স্টোর থেকে সবচেয়ে অনুরূপ এবং প্রাসঙ্গিক ডকুমেন্ট খণ্ডগুলি খুঁজে পেতে একটি ফাইল অনুসন্ধান করে।
File Search uploadToFileSearchStore API ব্যবহারের প্রক্রিয়াটির একটি সংক্ষিপ্ত বিবরণ এখানে দেওয়া হল:
একটি ফাইল অনুসন্ধান স্টোর তৈরি করুন : একটি ফাইল অনুসন্ধান স্টোরে আপনার ফাইলগুলি থেকে প্রক্রিয়াজাত ডেটা থাকে। এটি এমন এম্বেডিংয়ের জন্য স্থায়ী ধারক যার উপর শব্দার্থিক অনুসন্ধান পরিচালিত হবে।
একটি ফাইল আপলোড করুন এবং একটি ফাইল অনুসন্ধান স্টোরে আমদানি করুন : একই সাথে একটি ফাইল আপলোড করুন এবং ফলাফলগুলি আপনার ফাইল অনুসন্ধান স্টোরে আমদানি করুন। এটি একটি অস্থায়ী
Fileঅবজেক্ট তৈরি করে, যা আপনার কাঁচা নথির একটি রেফারেন্স। সেই ডেটাটি তখন খণ্ডিত করা হয়, ফাইল অনুসন্ধান এম্বেডিংয়ে রূপান্তরিত হয় এবং সূচীবদ্ধ করা হয়।Fileঅবজেক্টটি 48 ঘন্টা পরে মুছে ফেলা হয়, যখন ফাইল অনুসন্ধান স্টোরে আমদানি করা ডেটা অনির্দিষ্টকালের জন্য সংরক্ষণ করা হবে যতক্ষণ না আপনি এটি মুছে ফেলার সিদ্ধান্ত নেন।ফাইল অনুসন্ধানের সাথে প্রশ্ন : অবশেষে, আপনি একটি
generateContentকলেFileSearchটুল ব্যবহার করেন। টুল কনফিগারেশনে, আপনি একটিFileSearchRetrievalResourceনির্দিষ্ট করেন, যা আপনি যেFileSearchStoreঅনুসন্ধান করতে চান তার দিকে নির্দেশ করে। এটি মডেলটিকে তার প্রতিক্রিয়া ভিত্তি করার জন্য প্রাসঙ্গিক তথ্য খুঁজে পেতে নির্দিষ্ট ফাইল অনুসন্ধান স্টোরে একটি শব্দার্থিক অনুসন্ধান করতে বলে।

এই চিত্রে, Documents থেকে Embedding মডেলে ( gemini-embedding-001 ব্যবহার করে) বিন্দুযুক্ত রেখাটি uploadToFileSearchStore API ( ফাইল স্টোরেজ বাইপাস করে) উপস্থাপন করে। অন্যথায়, Files API ব্যবহার করে আলাদাভাবে ফাইল তৈরি এবং আমদানি করলে ইনডেক্সিং প্রক্রিয়াটি Documents থেকে File স্টোরেজ এবং তারপর Embedding মডেলে স্থানান্তরিত হয়।
ফাইল অনুসন্ধান স্টোর
ফাইল সার্চ স্টোর হল আপনার ডকুমেন্ট এম্বেডিংয়ের জন্য একটি কন্টেইনার। ফাইল এপিআই-এর মাধ্যমে আপলোড করা কাঁচা ফাইলগুলি ৪৮ ঘন্টা পরে মুছে ফেলা হলেও, ফাইল সার্চ স্টোরে আমদানি করা ডেটা অনির্দিষ্টকালের জন্য সংরক্ষণ করা হয় যতক্ষণ না আপনি ম্যানুয়ালি মুছে ফেলেন। আপনার ডকুমেন্টগুলি সংগঠিত করার জন্য আপনি একাধিক ফাইল সার্চ স্টোর তৈরি করতে পারেন। FileSearchStore API আপনাকে আপনার ফাইল সার্চ স্টোরগুলি পরিচালনা করার জন্য তৈরি, তালিকাভুক্ত, পেতে এবং মুছে ফেলার সুযোগ দেয়। ফাইল সার্চ স্টোরের নামগুলি বিশ্বব্যাপী বিস্তৃত।
আপনার ফাইল অনুসন্ধান স্টোরগুলি কীভাবে পরিচালনা করবেন তার কিছু উদাহরণ এখানে দেওয়া হল:
পাইথন
# Create a File Search store (including optional display_name for easier reference)
file_search_store = client.file_search_stores.create(config={'display_name': 'my-file_search-store-123'})
# List all your File Search stores
for file_search_store in client.file_search_stores.list():
print(file_search_store)
# Get a specific File Search store by name
my_file_search_store = client.file_search_stores.get(name='fileSearchStores/my-file_search-store-123')
# Delete a File Search store
client.file_search_stores.delete(name='fileSearchStores/my-file_search-store-123', config={'force': True})
জাভাস্ক্রিপ্ট
// Create a File Search store (including optional display_name for easier reference)
const fileSearchStore = await ai.fileSearchStores.create({
config: { displayName: 'my-file_search-store-123' }
});
// List all your File Search stores
const fileSearchStores = await ai.fileSearchStores.list();
for await (const store of fileSearchStores) {
console.log(store);
}
// Get a specific File Search store by name
const myFileSearchStore = await ai.fileSearchStores.get({
name: 'fileSearchStores/my-file_search-store-123'
});
// Delete a File Search store
await ai.fileSearchStores.delete({
name: 'fileSearchStores/my-file_search-store-123',
config: { force: true }
});
বিশ্রাম
# Create a File Search store (including optional display_name for easier reference)
curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json"
-d '{ "displayName": "My Store" }'
# List all your File Search stores
curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
# Get a specific File Search store by name
curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"
# Delete a File Search store
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"
আপনার ফাইল স্টোরে ডকুমেন্ট পরিচালনার সাথে সম্পর্কিত পদ্ধতি এবং ক্ষেত্রগুলির জন্য ফাইল অনুসন্ধান ডকুমেন্টস API রেফারেন্স।
ফাইল মেটাডেটা
আপনার ফাইলগুলিকে ফিল্টার করতে বা অতিরিক্ত প্রসঙ্গ প্রদান করতে আপনি কাস্টম মেটাডেটা যোগ করতে পারেন। মেটাডেটা হল কী-মান জোড়ার একটি সেট।
পাইথন
# Import the file into the File Search store with custom metadata
op = client.file_search_stores.import_file(
file_search_store_name=file_search_store.name,
file_name=sample_file.name,
custom_metadata=[
{"key": "author", "string_value": "Robert Graves"},
{"key": "year", "numeric_value": 1934}
]
)
জাভাস্ক্রিপ্ট
// Import the file into the File Search store with custom metadata
let operation = await ai.fileSearchStores.importFile({
fileSearchStoreName: fileSearchStore.name,
fileName: sampleFile.name,
config: {
customMetadata: [
{ key: "author", stringValue: "Robert Graves" },
{ key: "year", numericValue: 1934 }
]
}
});
বিশ্রাম
FILE_PATH="path/to/sample.pdf"
MIME_TYPE=$(file -b --mime-type "${FILE_PATH}")
NUM_BYTES=$(wc -c < "${FILE_PATH}")
# Create a FileSearchStore
STORE_RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{ "displayName": "My Store" }')
# Extract the store name (format: fileSearchStores/xxxxxxx)
STORE_NAME=$(echo $STORE_RESPONSE | jq -r '.name')
# Initiate Resumable Upload to the Store
TMP_HEADER="upload-header.tmp"
curl -s -D "${TMP_HEADER}" \
"https://generativelanguage.googleapis.com/upload/v1beta/${STORE_NAME}:uploadToFileSearchStore?key=${GEMINI_API_KEY}" \
-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: ${MIME_TYPE}" \
-H "Content-Type: application/json" \
-d '{
"custom_metadata": [
{"key": "author", "string_value": "Robert Graves"},
{"key": "year", "numeric_value": 1934}
]
}' > /dev/null
# Extract upload_url from headers
UPLOAD_URL=$(grep -i "x-goog-upload-url: " "${TMP_HEADER}" | cut -d" " -f2 | tr -d "\r")
rm "${TMP_HEADER}"
# --- Upload the actual bytes ---
curl "${UPLOAD_URL}" \
-H "Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
--data-binary "@${FILE_PATH}" 2> /dev/null
যখন আপনার ফাইল অনুসন্ধান স্টোরে একাধিক নথি থাকে এবং আপনি কেবল তাদের একটি উপসেট অনুসন্ধান করতে চান তখন এটি কার্যকর।
পাইথন
# Use the metadata filter to search within a subset of documents
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Tell me about the book 'I, Claudius'",
config=types.GenerateContentConfig(
tools=[
types.Tool(
file_search=types.FileSearch(
file_search_store_names=[file_search_store.name],
metadata_filter="author=Robert Graves",
)
)
]
)
)
print(response.text)
জাভাস্ক্রিপ্ট
// Use the metadata filter to search within a subset of documents
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: "Tell me about the book 'I, Claudius'",
config: {
tools: [
{
fileSearch: {
fileSearchStoreNames: [fileSearchStore.name],
metadataFilter: 'author="Robert Graves"',
}
}
]
}
});
console.log(response.text);
বিশ্রাম
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${GEMINI_API_KEY}" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "Tell me about the book I, Claudius"}]
}],
"tools": [{
"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 এ পাওয়া যাবে।
উদ্ধৃতি
যখন আপনি ফাইল সার্চ ব্যবহার করেন, তখন মডেলের প্রতিক্রিয়ায় উদ্ধৃতি অন্তর্ভুক্ত থাকতে পারে যা আপনার আপলোড করা নথির কোন অংশগুলি উত্তর তৈরি করতে ব্যবহার করা হয়েছিল তা নির্দিষ্ট করে। এটি তথ্য-পরীক্ষা এবং যাচাইকরণে সহায়তা করে।
আপনি প্রতিক্রিয়ার grounding_metadata বৈশিষ্ট্যের মাধ্যমে উদ্ধৃতি তথ্য অ্যাক্সেস করতে পারেন।
পাইথন
print(response.candidates[0].grounding_metadata)
জাভাস্ক্রিপ্ট
console.log(JSON.stringify(response.candidates?.[0]?.groundingMetadata, null, 2));
সমর্থিত মডেল
নিম্নলিখিত মডেলগুলি ফাইল অনুসন্ধান সমর্থন করে:
সমর্থিত ফাইলের ধরণ
ফাইল অনুসন্ধান বিভিন্ন ধরণের ফাইল ফর্ম্যাট সমর্থন করে, যা নিম্নলিখিত বিভাগগুলিতে তালিকাভুক্ত করা হয়েছে।
অ্যাপ্লিকেশন ফাইলের ধরণ
-
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/xc -
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/xd -
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/xr-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
হারের সীমা
পরিষেবার স্থিতিশীলতা জোরদার করার জন্য ফাইল অনুসন্ধান API-এর নিম্নলিখিত সীমা রয়েছে:
- সর্বোচ্চ ফাইলের আকার / প্রতি নথির সীমা : ১০০ এমবি
- প্রকল্প ফাইল অনুসন্ধান স্টোরের মোট আকার (ব্যবহারকারী স্তরের উপর ভিত্তি করে):
- বিনামূল্যে : ১ জিবি
- স্তর ১ : ১০ জিবি
- স্তর ২ : ১০০ জিবি
- স্তর ৩ : ১ টিবি
- সুপারিশ : সর্বোত্তম পুনরুদ্ধার বিলম্ব নিশ্চিত করতে প্রতিটি ফাইল অনুসন্ধান স্টোরের আকার 20 গিগাবাইটের মধ্যে সীমাবদ্ধ করুন।
মূল্য নির্ধারণ
- বিদ্যমান এম্বেডিং মূল্যের উপর ভিত্তি করে ডেভেলপারদের থেকে ইনডেক্সিং সময়ে এম্বেডিংয়ের জন্য চার্জ নেওয়া হয় (প্রতি ১০ লক্ষ টোকেনে $০.১৫)।
- সংরক্ষণ বিনামূল্যে।
- কোয়েরি টাইম এম্বেডিং বিনামূল্যে।
- পুনরুদ্ধার করা ডকুমেন্ট টোকেনগুলি নিয়মিত প্রসঙ্গ টোকেন হিসাবে চার্জ করা হয়।
এরপর কি?
- ফাইল অনুসন্ধান স্টোর এবং ফাইল অনুসন্ধান নথির জন্য API রেফারেন্সটি দেখুন।