RAG Engine API

מנוע ה-RAG של Vertex AI הוא רכיב של פלטפורמת Vertex AI, שמסייע ביצירה משולבת-אחזור (RAG). מנוע RAG מאפשר למודלים גדולים של שפה (LLM) לגשת לנתונים ממקורות ידע חיצוניים, כמו מסמכים ומסדי נתונים, ולשלב אותם. באמצעות RAG, מודלים גדולים של שפה (LLM) יכולים ליצור תשובות מדויקות ואינפורמטיביות יותר.

רשימת הפרמטרים

בקטע הזה מפורטים:

פרמטרים דוגמאות
פרמטרים לניהול מאגרים דוגמאות לניהול קורפוס
פרמטרים לניהול קבצים דוגמאות לניהול קבצים
פרמטרים לניהול פרויקטים דוגמאות לניהול פרויקטים

פרמטרים לניהול מאגר מידע

מידע על מאגר מידע של RAG זמין במאמר בנושא ניהול מאגרי מידע.

יצירת מאגר מידע של RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים ליצירת מאגר מידע של RAG.

גוף הבקשה
פרמטרים

corpus_type_config

אופציונלי: לא ניתן לשינוי.

RagCorpus.CorpusTypeConfig

ההגדרה שקובעת את סוג המאגר.

display_name

חובה: string

השם המוצג של מאגר המידע של RAG.

description

string (אופציונלי)

תיאור של מאגר המידע של RAG.

encryption_spec

אופציונלי: בלתי ניתן לשינוי: string

שם מפתח ה-CMEK משמש להצפנת נתונים במנוחה שקשורים למאגר המידע של RAG. שם המפתח רלוונטי רק לאפשרות RagManaged של מסד הנתונים הווקטורי. אפשר להגדיר את השדה הזה כשיוצרים את מאגר המידע, אבל אי אפשר לעדכן או למחוק אותו.

פורמט: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key_name}

vector_db_config

אופציונלי: בלתי ניתן לשינוי: RagVectorDbConfig

ההגדרה של מסדי הנתונים הווקטוריים.

vertex_ai_search_config.serving_config

string (אופציונלי)

ההגדרה של חיפוש מבוסס-Vertex AI.

פורמט: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/servingConfigs/{serving_config} או projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}

CorpusTypeConfig
פרמטרים

document_corpus

oneof RagCorpus.CorpusTypeConfig.DocumentCorpus

ערך ברירת המחדל הוא corpus_type_config, שמייצג קורפוס RAG רגיל שמבוסס על מסמכים.

memory_corpus

oneof RagCorpus.CorpusTypeConfig.MemoryCorpus

אם מגדירים את הסוג הזה, קורפוס ה-RAG הוא MemoryCorpus שאפשר להשתמש בו עם Gemini Live API כמאגר זיכרון.

מידע נוסף זמין במאמר שימוש ב-Vertex AI RAG Engine כמאגר זיכרון.

memory_corpus.llm_parser

oneof RagFileParsingConfig.LlmParser

מנתח ה-LLM שמשמש לניתוח ולאחסון של הקשרים של סשנים מ-Gemini Live API. אתם יכולים ליצור זיכרונות לאינדוקס.

RagVectorDbConfig
פרמטרים

rag_managed_db

oneof vector_db: RagVectorDbConfig.RagManagedDb

אם לא מציינים מסד נתונים וקטורי, rag_managed_db הוא מסד הנתונים הווקטורי שמוגדר כברירת מחדל.

rag_managed_db.knn

oneof retrieval_strategy: KNN

ברירת מחדל.

הפונקציה מוצאת את השכנים הקרובים ביותר על ידי השוואה של כל נקודות הנתונים במאגר המידע של RAG.

אם לא מציינים אסטרטגיה במהלך יצירת מאגר המידע של RAG, אסטרטגיית השליפה שמשמשת כברירת מחדל היא KNN.

rag_managed_db.ann

oneof retrieval_strategy: ANN

tree_depth

קובע את מספר השכבות או הרמות בעץ.

אם יש לכם O(10K) קבצים של RAG במאגר המידע של RAG, צריך להגדיר את הערך הזה כ-2.
  • אם נדרשות עוד שכבות או רמות, מגדירים את הערך הזה ל-3.
  • אם לא מציינים את מספר השכבות או הרמות, Vertex AI RAG Engine מקצה לפרמטר הזה ערך ברירת מחדל של 2.

leaf_count

המאפיין קובע את מספר צמתי העלים במבנה מבוסס-העץ.

  • הערך המומלץ הוא 10 * sqrt(num of RAG files in your RAG corpus).
  • אם לא מציינים ערך, Vertex AI RAG Engine מקצה לפרמטר הזה ערך ברירת מחדל של 500.

rebuild_ann_index

  • מנוע ה-RAG של Vertex AI בונה מחדש את אינדקס ה-ANN.
  • מגדירים את הערך true בבקשת ה-API של ImportRagFiles.
  • לפני שמריצים שאילתה על מאגר המידע של RAG, צריך לבנות מחדש את אינדקס ה-ANN פעם אחת.
  • בכל מיקום, אפשר לבצע בנייה מחדש של אינדקס אחד בלבד בו-זמנית בפרויקט.

weaviate

oneof vector_db: RagVectorDbConfig.Weaviate

מציינים את מופע Weaviate.

weaviate.http_endpoint

string

נקודת הקצה (endpoint) של HTTP במופע Weaviate.

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

weaviate.collection_name

string

אוסף Weaviate שאליו ממופה מאגר הנתונים של RAG.

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

pinecone

oneof vector_db: RagVectorDbConfig.Pinecone

מציינים את מופע Pinecone.

pinecone.index_name

string

זה השם שמשמש ליצירת אינדקס Pinecone שמשמש עם קורפוס RAG.

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

vertex_feature_store

oneof vector_db: RagVectorDbConfig.VertexFeatureStore

מציינים את המופע של Vertex AI Feature Store.

vertex_feature_store.feature_view_resource_name

string

‫Vertex AI Feature Store FeatureView שאליו ממופה מאגר המידע של RAG.

פורמט: projects/{project}/locations/{location}/featureOnlineStores/{feature_online_store}/featureViews/{feature_view}

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

vertex_vector_search

oneof vector_db: RagVectorDbConfig.VertexVectorSearch

מציינים את המכונה שלכם ב-Vertex Vector Search.

vertex_vector_search.index

string

זהו שם המשאב של אינדקס Vector Search שמשמש עם קורפוס RAG.

פורמט: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

vertex_vector_search.index_endpoint

string

זהו שם המשאב של נקודת הקצה של אינדקס החיפוש הווקטורי שמשמשת עם מאגר המידע של RAG.

פורמט: projects/{project}/locations/{location}/indexes/{index}

אי אפשר לשנות את הערך הזה אחרי שהוא מוגדר. אפשר להשאיר אותו ריק בCreateRagCorpusקריאה ל-APIUpdateRagCorpus, ולהגדיר לו ערך לא ריק בUpdateRagCorpusקריאת APIUpdateRagCorpus נוספת.

api_auth.api_key_config.api_key_secret_version

string

זהו שם המשאב המלא של הסוד שמאוחסן ב-Secret Manager, שמכיל את מפתח ה-API של Weaviate או Pinecone, בהתאם לבחירה שלכם במסד נתונים וקטורי.

פורמט: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

אפשר להשאיר אותו ריק בקריאה ל-API‏ CreateRagCorpus, ולהגדיר לו ערך לא ריק בקריאה ל-API‏ UpdateRagCorpus נוספת.

rag_embedding_model_config.vertex_prediction_endpoint.endpoint

אופציונלי: בלתי ניתן לשינוי: string

מודל ההטמעה שבו צריך להשתמש בשביל מאגר הידע של RAG. אי אפשר לשנות את הערך הזה אחרי שמגדירים אותו. אם לא תציינו מודל, נשתמש במודל text-embedding-005.

עדכון מאגר מידע של RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים לעדכון מאגר מידע של RAG.

גוף הבקשה
פרמטרים

display_name

string (אופציונלי)

השם המוצג של מאגר המידע של RAG.

description

string (אופציונלי)

תיאור של מאגר המידע של RAG.

rag_vector_db.weaviate.http_endpoint

string

נקודת הקצה (endpoint) של HTTP במופע Weaviate.

אם RagCorpus נוצר עם הגדרה של Weaviate, והשדה הזה אף פעם לא הוגדר, אפשר לעדכן את נקודת הקצה של HTTP במופע Weaviate.

rag_vector_db.weaviate.collection_name

string

אוסף Weaviate שאליו ממופה מאגר הנתונים של RAG.

אם RagCorpus נוצר עם הגדרה של Weaviate, והשדה הזה מעולם לא הוגדר לפני כן, אפשר לעדכן את שם האוסף של מופע Weaviate.

rag_vector_db.pinecone.index_name

string

זה השם שמשמש ליצירת אינדקס Pinecone שמשמש עם קורפוס RAG.

אם RagCorpus נוצר עם הגדרה של Pinecone, והשדה הזה אף פעם לא הוגדר, אפשר לעדכן את שם האינדקס של מופע Pinecone.

rag_vector_db.vertex_feature_store.feature_view_resource_name

string

‫Vertex AI Feature Store FeatureView שאליו ממופה מאגר המידע של RAG.

פורמט: projects/{project}/locations/{location}/featureOnlineStores/{feature_online_store}/featureViews/{feature_view}

אם RagCorpus נוצר עם הגדרה של Vertex AI Feature Store ולא הוגדר בו ערך בשדה הזה, אפשר לעדכן אותו.

rag_vector_db.vertex_vector_search.index

string

זהו שם המשאב של אינדקס Vector Search שמשמש עם קורפוס RAG.

פורמט: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

אם RagCorpus נוצר עם הגדרה של Vector Search ולא הוגדר בו ערך בשדה הזה, אפשר לעדכן אותו.

rag_vector_db.vertex_vector_search.index_endpoint

string

זהו שם המשאב של נקודת הקצה של אינדקס החיפוש הווקטורי שמשמשת עם מאגר המידע של RAG.

פורמט: projects/{project}/locations/{location}/indexes/{index}

אם RagCorpus נוצר עם הגדרה של Vector Search ולא הוגדר בו ערך בשדה הזה, אפשר לעדכן אותו.

rag_vector_db.api_auth.api_key_config.api_key_secret_version

string

השם המלא של המשאב של הסוד שמאוחסן ב-Secret Manager, שמכיל את מפתח ה-API של Weaviate או Pinecone, תלוי בבחירה שלכם לגבי מסד הנתונים הווקטורי.

פורמט: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

הצגת רשימה של מאגרי מידע של RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים לרישום של מאגרי מידע של RAG.

פרמטרים

page_size

int (אופציונלי)

גודל הדף הרגיל ברשימה.

page_token

string (אופציונלי)

טוקן הדף הרגיל של הרשימה. בדרך כלל מתקבל מ-[ListRagCorporaResponse.next_page_token][] של הקריאה הקודמת של [VertexRagDataService.ListRagCorpora][].

קבלת קורפוס RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים לקבלת מאגר מידע של RAG.

פרמטרים

name

string

השם של משאב RagCorpus. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

מחיקת מאגר מידע של RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים למחיקת מאגר מידע של RAG.

פרמטרים

name

string

השם של משאב RagCorpus. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

פרמטרים של ניהול קבצים

מידע על קובץ RAG זמין במאמר בנושא ניהול קבצים.

העלאת קובץ RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים להעלאת קובץ RAG.

גוף הבקשה
פרמטרים

parent

string

השם של משאב RagCorpus. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

rag_file

חובה: RagFile

הקובץ להעלאה.

upload_rag_file_config

חובה: UploadRagFileConfig

ההגדרה של RagFile שצריך להעלות אל RagCorpus.

RagFile

display_name

חובה: string

השם המוצג של קובץ ה-RAG.

description

string (אופציונלי)

תיאור קובץ ה-RAG.

UploadRagFileConfig

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_size

int32

מספר הטוקנים בכל מקטע.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_overlap

int32

החפיפה בין המקטעים.

ייבוא קובצי RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים לייבוא של קובץ RAG.

פרמטרים

parent

חובה: string

השם של משאב RagCorpus.

פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

gcs_source

oneof import_source: GcsSource

מיקום ב-Cloud Storage.

תמיכה בייבוא של קבצים בודדים וגם של ספריות שלמות ב-Cloud Storage.

gcs_source.uris

list מתוך string

‫URI של Cloud Storage שמכיל את קובץ ההעלאה.

google_drive_source

oneof import_source: GoogleDriveSource

מיקום Google Drive.

אפשר לייבא קבצים בודדים וגם תיקיות מ-Google Drive.

slack_source

oneof import_source: SlackSource

ערוץ Slack שאליו הקובץ מועלה.

jira_source

oneof import_source: JiraSource

שאילתת Jira שאליה הקובץ מועלה.

share_point_sources

oneof import_source: SharePointSources

מקורות SharePoint שאליהם הקובץ מועלה.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_size

int32

מספר הטוקנים בכל מקטע.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_overlap

int32

החפיפה בין המקטעים.

rag_file_parsing_config

RagFileParsingConfig (אופציונלי)

מציינת את הגדרות הניתוח של RagFiles.

אם השדה הזה לא מוגדר, RAG משתמש במנתח ברירת המחדל.

max_embedding_requests_per_min

int32 (אופציונלי)

המספר המקסימלי של שאילתות לדקה שהעבודה הזו יכולה לשלוח למודל ההטמעה שצוין בקורפוס. הערך הזה ספציפי למשימה הזו ולא משותף בין משימות ייבוא אחרות. כדי להגדיר ערך מתאים, אפשר לעיין בדף Quotas בפרויקט.

אם לא צוין ערך, המערכת תשתמש בערך ברירת המחדל 1,000 QPM.

GoogleDriveSource

resource_ids.resource_id

חובה: string

המזהה של המשאב ב-Google Drive.

resource_ids.resource_type

חובה: string

סוג המשאב ב-Google Drive.

SlackSource

channels.channels

חוזרת: SlackSource.SlackChannels.SlackChannel

פרטי ערוץ Slack, כולל מזהה וטווח זמן לייבוא.

channels.channels.channel_id

חובה: string

מזהה הערוץ ב-Slack.

channels.channels.start_time

google.protobuf.Timestamp (אופציונלי)

חותמת הזמן של ההתחלה של ההודעות לייבוא.

channels.channels.end_time

google.protobuf.Timestamp (אופציונלי)

חותמת הזמן של סיום ההודעות לייבוא.

channels.api_key_config.api_key_secret_version

חובה: string

השם המלא של המשאב של הסוד שמאוחסן ב-Secret Manager, שמכיל אסימון גישה לערוץ Slack שיש לו גישה למזהי הערוצים ב-Slack.
מידע נוסף זמין בכתובת: https://api.slack.com/tutorials/tracks/getting-a-token.

פורמט: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

JiraSource

jira_queries.projects

חוזרת: string

רשימה של פרויקטים ב-Jira לייבוא בשלמותם.

jira_queries.custom_queries

חוזרת: string

רשימה של שאילתות מותאמות אישית של Jira לייבוא. מידע על JQL (שפת שאילתות של Jira) זמין ב
Jira Support.

jira_queries.email

חובה: string

כתובת האימייל של Jira.

jira_queries.server_uri

חובה: string

‫URI של שרת Jira.

jira_queries.api_key_config.api_key_secret_version

חובה: string

שם המשאב המלא של הסוד שמאוחסן ב-Secret Manager, שכולל את מפתח ה-API של Jira שיש לו גישה למזהי הערוצים של Slack.
מידע נוסף זמין בכתובת: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

פורמט: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

SharePointSources

share_point_sources.sharepoint_folder_path

oneof בfolder_source: string

הנתיב של תיקיית SharePoint שממנה רוצים להוריד.

share_point_sources.sharepoint_folder_id

oneof בfolder_source: string

המזהה של תיקיית SharePoint שממנה רוצים להוריד.

share_point_sources.drive_name

oneof בdrive_source: string

השם של הכונן שממנו רוצים להוריד.

share_point_sources.drive_id

oneof בdrive_source: string

המזהה של הכונן שממנו רוצים להוריד.

share_point_sources.client_id

string

מזהה האפליקציה שרשומה בפורטל Microsoft Azure.
צריך גם להגדיר את האפליקציה עם ההרשאות Files.ReadAll,‏ Sites.ReadAll ו-BrowserSiteLists.Read.All ב-MS Graph.

share_point_sources.client_secret.api_key_secret_version

חובה: string

השם המלא של המשאב של הסוד שמאוחסן ב-Secret Manager, שמכיל את הסוד של האפליקציה שרשומה ב-Azure.

פורמט: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

share_point_sources.tenant_id

string

מזהה ייחודי של מופע Azure Active Directory.

share_point_sources.sharepoint_site_name

string

שם אתר SharePoint שממנו רוצים להוריד. זה יכול להיות שם האתר או מזהה האתר.

RagFileParsingConfig

layout_parser

oneof parser: RagFileParsingConfig.LayoutParser

הכלי לניתוח פריסה שבו יש להשתמש עבור RagFile.

layout_parser.processor_name

string

השם המלא של משאב של מעבד Document AI או גרסת מעבד.

פורמט:
projects/{project_id}/locations/{location}/processors/{processor_id}
projects/{project_id}/locations/{location}/processors/{processor_id}/processorVersions/{processor_version_id}

layout_parser.max_parsing_requests_per_min

string

המספר המקסימלי של בקשות שהעבודה יכולה לשלוח למעבד Document AI בכל דקה.

כדי להגדיר ערך מתאים כאן, אפשר לעיין במאמר בנושא מכסות ב-Document AI בכתובת https://cloud.google.com/document-ai/quotas ובדף Quota (מכסה) של הפרויקט. אם לא מציינים ערך, נעשה שימוש בערך ברירת המחדל של 120 QPM.

llm_parser

oneof parser: RagFileParsingConfig.LlmParser

המערכת לניתוח LLM שבה צריך להשתמש בשביל RagFile.

llm_parser.model_name

string

שם המשאב של מודל LLM.

פורמט:
{publisher}/models/{model}

llm_parser.max_parsing_requests_per_min

string

המספר המקסימלי של בקשות שהעבודה יכולה לשלוח למודל LLM בכל דקה.

כדי להגדיר ערך מתאים לפרויקט, אפשר לעיין בקטע בנושא מכסות של מודלים ובדף Quota של הפרויקט. אם לא מציינים ערך, המערכת משתמשת בערך ברירת המחדל של 5,000 שאילתות לדקה.

קבלת קובץ RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים לקבלת קובץ RAG.

פרמטרים

name

string

השם של משאב RagFile. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_file_id}

מחיקת קובץ RAG

בטבלה הזו מפורטים הפרמטרים שמשמשים למחיקת קובץ RAG.

פרמטרים

name

string

השם של משאב RagFile. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_file_id}

פרמטרים של אחזור וחיזוי

בקטע הזה מפורטים הפרמטרים של השליפה והחיזוי.

פרמטרים של אחזור

בטבלה הזו מפורטים הפרמטרים של retrieveContexts API.

פרמטרים

parent

חובה: string

שם המשאב של המיקום לאחזור RagContexts.
למשתמשים צריכה להיות הרשאה להתקשר בפרויקט.

פורמט: projects/{project}/locations/{location}

vertex_rag_store

VertexRagStore

מקור הנתונים של Vertex RagStore.

query

חובה: RagQuery

שאילתת אחזור RAG יחידה.

VertexRagStore
VertexRagStore

rag_resources

רשימה: RagResource

ייצוג של מקור RAG. אפשר להשתמש בו כדי לציין רק את הקורפוס או את RagFile. יש תמיכה רק בקורפוס אחד או בכמה קבצים מקורפוס אחד.

rag_resources.rag_corpus

string (אופציונלי)

RagCorpora שם המשאב.

פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}

rag_resources.rag_file_ids

רשימה: string

רשימה של RagFile משאבים.

פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}/ragFiles/{rag_file}

RagQuery

text

string

השאילתה בפורמט טקסט כדי לקבל הקשרים רלוונטיים.

rag_retrieval_config

RagRetrievalConfig (אופציונלי)

הגדרת האחזור של השאילתה.

RagRetrievalConfig

top_k

int32 (אופציונלי)

מספר ההקשרים לאחזור.

hybrid_search.alpha

float (אופציונלי)

ערך האלפא קובע את המשקל בין תוצאות חיפוש וקטורים צפופים לבין תוצאות חיפוש וקטורים דלילים. הטווח הוא [0, 1], כאשר 0 מציין חיפוש של וקטורים דלילים בלבד ו-1 מציין חיפוש של וקטורים צפופים בלבד. ערך ברירת המחדל הוא 0.5, שמאזן באופן שווה בין חיפוש וקטורי דליל לחיפוש וקטורי צפוף.

החיפוש ההיברידי זמין רק ב-Weaviate.

filter.vector_distance_threshold

oneof vector_db_threshold: double

הפונקציה מחזירה רק הקשרים עם מרחק וקטורי קטן יותר מהסף.

filter.vector_similarity_threshold

oneof vector_db_threshold: double

הפונקציה מחזירה רק הקשרים עם דמיון וקטורי שגדול מהסף.

ranking.rank_service.model_name

string (אופציונלי)

שם הדגם של שירות הדירוג.

לדוגמה: semantic-ranker-512@latest

ranking.llm_ranker.model_name

string (אופציונלי)

שם הדגם שמשמש לדירוג.

לדוגמה: gemini-2.5-flash

פרמטרים של חיזוי

בטבלה הזו מפורטים פרמטרים של תחזיות.

GenerateContentRequest

tools.retrieval.vertex_rag_store

VertexRagStore

הגדרה לשימוש במקור נתונים שמבוסס על מאגר RAG של Vertex AI.

פרטים נוספים זמינים במאמר בנושא VertexRagStore.

פרמטרים של ניהול פרויקטים

בטבלה הזו מפורטים פרמטרים ברמת הפרויקט.

RagEngineConfig
פרמטרים
RagManagedDbConfig.scaled שכבה זו מציעה ביצועים בקנה מידה של Production יחד עם פונקציונליות של התאמה אוטומטית לעומס (automatic scaling).
RagManagedDbConfig.basic במסלול הזה יש אפשרות חסכונית עם שימוש נמוך במחשוב.
RagManagedDbConfig.unprovisioned בשלב הזה נמחקת התוכנית RagManagedDb ומופע Spanner הבסיסי שלה.

דוגמאות לניהול מאגר מידע

בקטע הזה מופיעות דוגמאות לשימוש ב-API כדי לנהל את מאגר המידע של RAG.

יצירת דוגמה של מאגר מידע RAG

בדוגמת הקוד הזו מוסבר איך ליצור קורפוס RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • CORPUS_DISPLAY_NAME: השם המוצג של RagCorpus.
  • CORPUS_DESCRIPTION: התיאור של RagCorpus.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora

גוף בקשת JSON:

{
  "display_name" : "CORPUS_DISPLAY_NAME",
  "description": "CORPUS_DESCRIPTION",
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora" | Select-Object -Expand Content
צריך להתקבל קוד סטטוס של הצלחה (2xx).

בדוגמה הבאה מוסבר איך ליצור מאגר מידע של RAG באמצעות REST API.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  CORPUS_DISPLAY_NAME: The display name of the <code>RagCorpus</code>.
    // CreateRagCorpus
    // Input: LOCATION, PROJECT_ID, CORPUS_DISPLAY_NAME
    // Output: CreateRagCorpusOperationMetadata
    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora \
    -d '{
          "display_name" : "CORPUS_DISPLAY_NAME"
      }'

דוגמה לעדכון של מאגר מידע של RAG

אתם יכולים לעדכן את מאגר הנתונים של RAG עם שם תצוגה, תיאור ותצורת מסד נתונים וקטורי חדשים. עם זאת, אי אפשר לשנות את הפרמטרים הבאים במאגר המידע של RAG:

  • סוג מסד הנתונים הווקטורי. לדוגמה, אי אפשר לשנות את מסד הנתונים הווקטורי מ-Weaviate ל-Vertex AI Feature Store.
  • אם אתם משתמשים באפשרות של מסד נתונים מנוהל, אתם לא יכולים לעדכן את ההגדרות של מסד הנתונים הווקטורי.

בדוגמאות האלה אפשר לראות איך מעדכנים קורפוס RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • CORPUS_ID: מזהה הקורפוס של קורפוס ה-RAG.
  • CORPUS_DISPLAY_NAME: השם המוצג של RagCorpus.
  • CORPUS_DESCRIPTION: התיאור של RagCorpus.
  • INDEX_NAME: שם המשאב של Vector Search Index. פורמט: projects/{project}/locations/{location}/indexes/{index}
  • INDEX_ENDPOINT_NAME: שם המשאב של Vector Search Index Endpoint. פורמט: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

ה-method של ה-HTTP וכתובת ה-URL:

PATCH https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID

גוף בקשת JSON:

{
  "display_name" : "CORPUS_DISPLAY_NAME",
  "description": "CORPUS_DESCRIPTION",
  "rag_vector_db_config": {
     "vertex_vector_search": {
         "index": "INDEX_NAME",
         "index_endpoint": "INDEX_ENDPOINT_NAME",
     }
  }
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID" | Select-Object -Expand Content
צריך להתקבל קוד סטטוס של הצלחה (2xx).

דוגמה להצגת רשימה של מאגרי מידע של RAG

בדוגמת הקוד הזו מוסבר איך להציג רשימה של כל מאגרי המידע של RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • PAGE_SIZE: גודל הדף הסטנדרטי של הרשימה. אפשר לשנות את מספר RagCorpora התוצאות שיוחזרו בכל דף על ידי עדכון הפרמטר page_size.
  • PAGE_TOKEN: אסימון דף הרשימה הרגיל. בדרך כלל מתקבל באמצעות ListRagCorporaResponse.next_page_token של הקריאה הקודמת של VertexRagDataService.ListRagCorpora.

ה-method של ה-HTTP וכתובת ה-URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN" | Select-Object -Expand Content
אמור להתקבל קוד סטטוס של הצלחה (‎2xx) ורשימה של RagCorpora תחת PROJECT_ID שצוין.

דוגמה לקורפוס RAG

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.

ה-method של ה-HTTP וכתובת ה-URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID" | Select-Object -Expand Content
תגובה מוצלחת מחזירה את משאב RagCorpus.

בדוגמה הבאה השתמשנו בפקודות get ו-list כדי להדגים איך RagCorpus משתמש בשדה rag_embedding_model_config בתוך vector_db_config, שמפנה למודל ההטמעה שבחרתם.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
// GetRagCorpus
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID
// Output: RagCorpus
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

// ListRagCorpora
curl -sS -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/

מחיקת דוגמה של מאגר מידע RAG

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.

ה-method של ה-HTTP וכתובת ה-URL:

DELETE https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID" | Select-Object -Expand Content
תגובה מוצלחת מחזירה את DeleteOperationMetadata.

דוגמאות לניהול קבצים

בקטע הזה מופיעות דוגמאות לשימוש ב-API לניהול קבצי RAG.

העלאה של קובץ RAG לדוגמה

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  LOCAL_FILE_PATH: The local path to the file to be uploaded.
  DISPLAY_NAME: The display name of the RAG file.
  DESCRIPTION: The description of the RAG file.

כדי לשלוח את הבקשה, משתמשים בפקודה הבאה:

  curl -X POST \
    -H "X-Goog-Upload-Protocol: multipart" \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -F metadata="{'rag_file': {'display_name':' DISPLAY_NAME', 'description':'DESCRIPTION'}}" \
    -F file=@LOCAL_FILE_PATH \
    "https://LOCATION-aiplatform.googleapis.com/upload/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:upload"

דוגמה לייבוא קובצי RAG

אפשר לייבא קבצים ותיקיות מ-Drive או מ-Cloud Storage.

הערך response.skipped_rag_files_count מתייחס למספר הקבצים שהמערכת דילגה עליהם במהלך הייבוא. קובץ ידלג אם התנאים הבאים יתקיימו:

  1. הקובץ כבר יובא.
  2. הקובץ לא השתנה.
  3. ההגדרה של חלוקת הקובץ לחלקים לא השתנתה.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.
  • GCS_URIS: רשימה של מיקומי Cloud Storage. לדוגמה: gs://my-bucket1, gs://my-bucket2.
  • CHUNK_SIZE: אופציונלי: מספר הטוקנים שכל מקטע צריך להכיל.
  • CHUNK_OVERLAP: אופציונלי: מספר האסימונים שחופפים בין חלקי הטקסט.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import

גוף בקשת JSON:

{
  "import_rag_files_config": {
    "gcs_source": {
      "uris": "GCS_URIS"
    },
    "rag_file_chunking_config": {
      "chunk_size": CHUNK_SIZE,
      "chunk_overlap": CHUNK_OVERLAP
    }
  }
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import" | Select-Object -Expand Content
תגובה מוצלחת מחזירה את משאב ImportRagFilesOperationMetadata.

בדוגמה הבאה אפשר לראות איך מייבאים קובץ מ-Cloud Storage. משתמשים בשדה הבקרה max_embedding_requests_per_min כדי להגביל את הקצב שבו RAG Engine קורא למודל ההטמעה במהלך תהליך יצירת האינדקס ImportRagFiles. ערך ברירת המחדל של השדה הוא 1000 שיחות לדקה.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  GCS_URIS: A list of Cloud Storage locations. Example: gs://my-bucket1.
  CHUNK_SIZE: Number of tokens each chunk should have.
  CHUNK_OVERLAP: Number of tokens overlap between chunks.
  EMBEDDING_MODEL_QPM_RATE: The QPM rate to limit RAGs access to your embedding model. Example: 1000.
// ImportRagFiles
// Import a single Cloud Storage file or all files in a Cloud Storage bucket.
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID, GCS_URIS
// Output: ImportRagFilesOperationMetadataNumber
// Use ListRagFiles to find the server-generated rag_file_id.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import \
-d '{
  "import_rag_files_config": {
    "gcs_source": {
      "uris": "GCS_URIS"
    },
    "rag_file_chunking_config": {
      "chunk_size": CHUNK_SIZE,
      "chunk_overlap": CHUNK_OVERLAP
    },
    "max_embedding_requests_per_min": EMBEDDING_MODEL_QPM_RATE
  }
}'

// Poll the operation status.
// The response contains the number of files imported.
OPERATION_ID: The operation ID you get from the response of the previous command.
poll_op_wait OPERATION_ID

הדוגמה הבאה מדגימה איך מייבאים קובץ מ-Drive. משתמשים בשדה הבקרה max_embedding_requests_per_min כדי להגביל את הקצב שבו RAG Engine קורא למודל ההטמעה במהלך ImportRagFiles תהליך יצירת האינדקס. ערך ברירת המחדל של השדה הוא 1000 שיחות לדקה.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  FOLDER_RESOURCE_ID: The resource ID of your Google Drive folder.
  CHUNK_SIZE: Number of tokens each chunk should have.
  CHUNK_OVERLAP: Number of tokens overlap between chunks.
  EMBEDDING_MODEL_QPM_RATE: The QPM rate to limit RAGs access to your embedding model. Example: 1000.
// ImportRagFiles
// Import all files in a Google Drive folder.
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID, FOLDER_RESOURCE_ID
// Output: ImportRagFilesOperationMetadataNumber
// Use ListRagFiles to find the server-generated rag_file_id.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import \
-d '{
  "import_rag_files_config": {
    "google_drive_source": {
      "resource_ids": {
        "resource_id": "FOLDER_RESOURCE_ID",
        "resource_type": "RESOURCE_TYPE_FOLDER"
      }
    },
    "max_embedding_requests_per_min": EMBEDDING_MODEL_QPM_RATE
  }
}'

// Poll the operation status.
// The response contains the number of files imported.
OPERATION_ID: The operation ID you get from the response of the previous command.
poll_op_wait OPERATION_ID

דוגמה לרשימת קובצי RAG

בדוגמת הקוד הזו אפשר לראות איך מציגים רשימה של קובצי RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.
  • PAGE_SIZE: גודל הדף הסטנדרטי של הרשימה. אפשר לשנות את מספר RagFiles התוצאות שיוחזרו בכל דף על ידי עדכון הפרמטר page_size.
  • PAGE_TOKEN: אסימון דף הרשימה הרגיל. בדרך כלל מתקבל באמצעות ListRagFilesResponse.next_page_token של הקריאה הקודמת של VertexRagDataService.ListRagFiles.

ה-method של ה-HTTP וכתובת ה-URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN" | Select-Object -Expand Content
אמור להתקבל קוד סטטוס של הצלחה (2xx) יחד עם רשימה של RagFiles ב-RAG_CORPUS_ID שצוין.

דוגמה לקובץ RAG

בדוגמת הקוד הזו אפשר לראות איך מקבלים קובץ RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.
  • RAG_FILE_ID: המזהה של משאב RagFile.

ה-method של ה-HTTP וכתובת ה-URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID" | Select-Object -Expand Content
תגובה מוצלחת מחזירה את משאב RagFile.

מחיקת קובץ RAG לדוגמה

דוגמת הקוד הזו מדגימה איך למחוק קובץ RAG.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • RAG_CORPUS_ID: המזהה של משאב RagCorpus.
  • RAG_FILE_ID: המזהה של משאב RagFile. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}/ragFiles/{rag_file_id}

ה-method של ה-HTTP וכתובת ה-URL:

DELETE https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID"

PowerShell

מריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID" | Select-Object -Expand Content
תגובה מוצלחת מחזירה את משאב DeleteOperationMetadata.

דוגמה לשאילתת אחזור

כשמשתמש שואל שאלה או מזין הנחיה, רכיב האחזור ב-RAG מחפש ב<b>מאגר הידע</b> שלו מידע שרלוונטי לשאילתה.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION: האזור שבו הבקשה תעובד.
  • PROJECT_ID: מזהה הפרויקט.
  • RAG_CORPUS_RESOURCE: השם של משאב RagCorpus. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}
  • VECTOR_DISTANCE_THRESHOLD: רק הקשרים עם מרחק וקטורי קטן יותר מהסף מוחזרים.
  • TEXT: טקסט השאילתה כדי לקבל הקשרים רלוונטיים.
  • SIMILARITY_TOP_K: מספר ההקשרים העליונים לאחזור.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts

גוף בקשת JSON:

{
 "vertex_rag_store": {
    "rag_resources": {
      "rag_corpus": "RAG_CORPUS_RESOURCE"
    },
    "vector_distance_threshold": VECTOR_DISTANCE_THRESHOLD
  },
  "query": {
   "text": "TEXT",
   "similarity_top_k": SIMILARITY_TOP_K
  }
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts" | Select-Object -Expand Content
אמור להתקבל קוד סטטוס של הצלחה (2xx) ורשימה של RagFiles קשורים.

דוגמה ליצירה

ה-LLM יוצר תשובה שמבוססת על מקורות באמצעות ההקשרים שאוחזרו.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט.
  • LOCATION: האזור שבו הבקשה תעובד.
  • MODEL_ID: מודל LLM ליצירת תוכן. לדוגמה: gemini-2.5-flash
  • GENERATION_METHOD: שיטה של LLM ליצירת תוכן. אפשרויות: generateContent, ‏ streamGenerateContent
  • INPUT_PROMPT: הטקסט שנשלח למודל שפה גדול (LLM) ליצירת תוכן. כדאי לנסות להשתמש בהנחיה שרלוונטית לקובצי ה-RAG שהועלו.
  • RAG_CORPUS_RESOURCE: השם של משאב RagCorpus. פורמט: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}
  • SIMILARITY_TOP_K: אופציונלי: מספר ההקשרים העליונים לאחזור.
  • VECTOR_DISTANCE_THRESHOLD: אופציונלי: מוחזרים הקשרים עם מרחק וקטורי קטן יותר מערך הסף.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD

גוף בקשת JSON:

{
 "contents": {
  "role": "user",
  "parts": {
    "text": "INPUT_PROMPT"
  }
 },
 "tools": {
  "retrieval": {
   "disable_attribution": false,
   "vertex_rag_store": {
    "rag_resources": {
      "rag_corpus": "RAG_CORPUS_RESOURCE"
    },
    "similarity_top_k": SIMILARITY_TOP_K,
    "vector_distance_threshold": VECTOR_DISTANCE_THRESHOLD
   }
  }
 }
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD" | Select-Object -Expand Content
תשובה מוצלחת מחזירה את התוכן שנוצר עם ציטוטים.

דוגמאות לניהול פרויקטים

המסלול הוא הגדרה ברמת הפרויקט שזמינה במשאב RagEngineConfig ומשפיעה על מאגרי מידע של RAG באמצעות RagManagedDb. כדי לקבל את הגדרת הרמה, משתמשים בפקודה GetRagEngineConfig. כדי לעדכן את הגדרות הרמה, משתמשים בפקודה UpdateRagEngineConfig.

מידע נוסף על ניהול הגדרות הרמה זמין במאמר ניהול הרמה.

אחזור של הגדרות הפרויקט

בדוגמת הקוד הבאה אפשר לראות איך קוראים את RagEngineConfig:

המסוף

  1. נכנסים לדף RAG Engine במסוף Google Cloud .

    מעבר אל RAG Engine

  2. בוחרים את האזור שבו מנוע ה-RAG פועל. רשימת מאגרי המידע של RAG עודכנה.
  3. לוחצים על Configure RAG Engine (הגדרת מנוע RAG). מופיעה החלונית Configure RAG Engine. תוכלו לראות את הרמה שנבחרה למנוע ה-RAG.
  4. לוחצים על ביטול.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config = rag.rag_data.get_rag_engine_config(
    name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
)

print(rag_engine_config)

REST

curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig

עדכון הגדרות הפרויקט

בקטע הזה מופיעות דוגמאות קוד שמדגימות איך לשנות את הרמה בהגדרה.

עדכון של RagEngineConfig לרמת Scaled

בדוגמאות הקוד הבאות אפשר לראות איך מגדירים את RagEngineConfig לרמה Scaled:

המסוף

  1. נכנסים לדף RAG Engine במסוף Google Cloud .

    מעבר אל RAG Engine

  2. בוחרים את האזור שבו מנוע ה-RAG פועל. רשימת מאגרי המידע של RAG עודכנה.
  3. לוחצים על Configure RAG Engine (הגדרת מנוע RAG). מופיעה החלונית Configure RAG Engine.
  4. בוחרים את הרמה שבה רוצים להפעיל את מנוע ה-RAG.
  5. לוחצים על Save.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Scaled()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'scaled': {}}}"

עדכון של RagEngineConfig לחבילת Basic

בדוגמאות הקוד הבאות אפשר לראות איך מגדירים את RagEngineConfig לרמה הבסיסית:

אם יש לכם כמות גדולה של נתונים ב-RagManagedDb בכל מאגרי המידע של RAG, יכול להיות שהשדרוג לא יצליח בגלל קיבולת אחסון וחישוב לא מספקת.

המסוף

  1. נכנסים לדף RAG Engine במסוף Google Cloud .

    מעבר אל RAG Engine

  2. בוחרים את האזור שבו מנוע ה-RAG פועל. רשימת מאגרי המידע של RAG עודכנה.
  3. לוחצים על Configure RAG Engine (הגדרת מנוע RAG). מופיעה החלונית Configure RAG Engine.
  4. בוחרים את הרמה שבה רוצים להפעיל את מנוע ה-RAG.
  5. לוחצים על Save.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Basic()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'basic': {}}}"

עדכון המינוי ל-RagEngineConfig למהדורה שלא הוקצתה

בדוגמאות הקוד הבאות אפשר לראות איך מגדירים את RagEngineConfig לרמה Unprovisioned:

המסוף

  1. נכנסים לדף RAG Engine במסוף Google Cloud .

    מעבר אל RAG Engine

  2. בוחרים את האזור שבו מנוע ה-RAG פועל. רשימת מאגרי המידע של RAG עודכנה.
  3. לוחצים על Configure RAG Engine (הגדרת מנוע RAG). מופיעה החלונית Configure RAG Engine.
  4. לוחצים על מחיקת מנוע RAG. מופיעה תיבת דו-שיח לאישור.
  5. כדי לוודא שאתם עומדים למחוק את הנתונים במנוע RAG, מקלידים delete ולוחצים על Confirm.
  6. לוחצים על Save.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
  name=rag_engine_config_name,
  rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Unprovisioned()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
  rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'unprovisioned': {}}}"

המאמרים הבאים