Method: projects.locations.collections.engines.sessions.addContextFile

העלאה של קובץ הקשר לשימוש כמקור לקריאות העזרה בסשן.

בקשת HTTP

POST https://discoveryengine.googleapis.com/v1alpha/{name=projects/*/locations/*/collections/*/engines/*/sessions/*}:addContextFile

כתובת ה-URL כתובה בתחביר של gRPC Transcoding.

פרמטרים של נתיב

פרמטרים
name

string

חובה. שם המשאב של הסשן. פורמט: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

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

גוף הבקשה

גוף הבקשה מכיל נתונים במבנה הבא:

ייצוג ב-JSON
{
  "fileName": string,
  "mimeType": string,

  // Union field file can be only one of the following:
  "fileContents": string,
  "document": string
  // End of list of possible types for union field file.
}
שדות
fileName

string

חובה. שם הקובץ.

mimeType

string

זה שינוי אופציונלי. סוג התוכן של הקובץ, אפשר לעיין בכתובת https://www.iana.org/assignments/media-types/media-types.xhtml.

השדה הזה נדרש אם מקור הנתונים לא מספק את סוג התוכן.

שדה איחוד file. התוכן של הקובץ. הערך file יכול להיות רק אחד מהבאים:
fileContents

string (bytes format)

תוכן הקובץ מוצג בתוך הטקסט.

מחרוזת בקידוד Base64.

document

string

שם המשאב של Document. למבצע הקריאה צריכה להיות הרשאה לגשת אל Document, אחרת תוחזר השגיאה PERMISSION_DENIED.

פורמט: projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}/branches/{branch}/documents/{document}

גוף התשובה

תשובה לשיטה AssistantService.AddContextFile.

אם הפעולה בוצעה ללא שגיאות, גוף התגובה יכיל נתונים במבנה הבא:

ייצוג ב-JSON
{
  "session": string,
  "fileId": string,
  "tokenCount": string,
  "mimeType": string,
  "byteCount": string,
  "fileName": string
}
שדות
session

string

שם הסשן, השם שצוין או השם החדש שנוצר.

פורמט: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

fileId

string

המזהה של הקובץ שהועלה.

tokenCount
(deprecated)

string (int64 format)

הוצא משימוש: השדה הזה לא יוגדר לכל סוגי הקבצים, ובסופו של דבר הוא יוסר.

אורך הקובץ שנמדד בטוקנים.

mimeType

string

פלט בלבד. סוג התוכן שזוהה של הקובץ שהועלה. מידע נוסף זמין בכתובת https://www.iana.org/assignments/media-types/media-types.xhtml.

בניגוד ל-AddContextFileRequest.mime_type האופציונלי שסופק על ידי המתקשר, זהו סוג התוכן שהשירות פתר בפועל עבור הקובץ.

byteCount

string (int64 format)

פלט בלבד. גודל הקובץ שהועלה בבייטים.

fileName

string

פלט בלבד. השם של הקובץ שהועלה, כולל סיומת הקובץ.

בניגוד ל-AddContextFileRequest.file_name שסופק על ידי המתקשר, האפליקציה של השירות מוסיפה את הסיומת שתואמת ל-mimeType שפוענח, אם השם שסופק על ידי המתקשר לא כולל סיומת. כך, יומני הביקורת של השימוש מתעדים את סוג הקובץ גם עבור קבצים גנריים שנוצרו על ידי AI.

היקפי הרשאות

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

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/discoveryengine.assist.readwrite
  • https://www.googleapis.com/auth/discoveryengine.readwrite
  • https://www.googleapis.com/auth/discoveryengine.serving.readwrite

ניתן למצוא מידע נוסף כאן: Authentication Overview.

הרשאות IAM

נדרשת הרשאת IAM הבאה במשאב name:

  • discoveryengine.sessions.addContextFile

מידע נוסף מופיע במאמרי העזרה בנושא IAM.