Thư viện GPT Actions - Google Drive

Giới thiệu

Trang này cung cấp hướng dẫn & chỉ dẫn cho các nhà phát triển xây dựng Hành động GPT cho một ứng dụng cụ thể. Trước khi tiếp tục, hãy đảm bảo rằng bạn đã làm quen với các thông tin sau:

+ Giới thiệu về Hành động GPT

+ Giới thiệu về Thư viện hành động GPT

+ Ví dụ về việc xây dựng một hành động tài khoản Chat GPT 4 từ đầu

Hành động GPT cụ thể này cung cấp tổng quan về cách kết nối với Google Drive , hệ thống lưu trữ Tệp của Google. Hành động này sẽ cho phép bạn liệt kê và truy vấn theo tên tệp, tải nội dung tệp vào GPT của bạn và cuối cùng sử dụng dữ liệu đó làm ngữ cảnh trong ChatGPT. Bộ hành động này có thể mở rộng bằng các phương pháp bổ sung được tìm thấy thông qua API Google Drive . Điều này thật tuyệt nếu bạn muốn có một GPT tổng quát có thể đọc các tệp nhỏ hơn, chẳng hạn như:

+ Biên bản cuộc họp

+ Tài liệu thiết kế sản phẩm

+ Bản ghi nhớ ngắn

+ Những câu hỏi thường gặp

Đối với những mục đích muốn đọc bản ghi nhớ dài hơn như toàn bộ cuốn sách, tệp CSV phức tạp có nhiều hàng, chúng tôi đề xuất xây dựng GPT dành riêng cho Google Docs hoặc Google Trang tính.

Giá trị + Ví dụ về trường hợp kinh doanh

Người dùng hiện có thể tận dụng khả năng ngôn ngữ tự nhiên của ChatGPT để kết nối trực tiếp đến các tệp trong Google Drive

Các trường hợp sử dụng ví dụ:

+ Người dùng cần tra cứu những tập tin nào liên quan đến một chủ đề nhất định

+ Người dùng cần câu trả lời cho một câu hỏi quan trọng, được chôn sâu trong các tài liệu

Xem thêm: mua tài khoản ChatGPT Plus chính hãng giá rẻ

Thông tin ứng dụng

Liên kết khóa ứng dụng

Hãy xem qua các liên kết sau từ ứng dụng trước khi bạn bắt đầu:

+ Trang web ứng dụng: https://www.google.com/drive/

+ Tài liệu API ứng dụng: https://developers.google.com/drive/api/guides/about-sdk

Điều kiện tiên quyết của ứng dụng

Trước khi bắt đầu, hãy đảm bảo bạn có tài khoản Google Cloud và Drive API đã được bật:

+ Thiết lập dự án Google Cloud

+ Bật Google Drive API từ Thư viện Google API

+ Nếu "Trạng thái xuất bản" của ứng dụng là "Đang thử nghiệm", hãy đảm bảo người dùng được thêm vào ứng dụng của bạn

Các bước ChatGPT

Ví dụ về hướng dẫn GPT tùy chỉnh

Sau khi bạn đã tạo GPT tùy chỉnh, để bắt đầu, hãy sao chép văn bản bên dưới trong bảng Hướng dẫn. Bạn có thể phải thêm ngữ cảnh bổ sung cụ thể cho trường hợp sử dụng của mình. Theo cách này, bạn nên thử nghiệm các hướng dẫn bổ sung mà bạn thêm vào để tối ưu hóa tính rõ ràng và chính xác. Bạn có thắc mắc không? Hãy xem Ví dụ về Bắt đầu để xem bước này hoạt động chi tiết hơn như thế nào.

*** Context ***
You are an office helper who takes a look at files within Google Drive and reads in information. In this way, when asked about something, please take a look at all of the relevant information within the drive. Respect file names, but also take a look at each document and sheet.
*** Instructions ***
Use the 'listFiles' function to get a list of files available within docs. In this way, determine out of this list which files make the most sense for you to pull back taking into account name and title. After the output of listFiles is called into context, act like a normal business analyst. Things you could be asked to be are:
- Summaries: what happens in a given file? Please give a consistent, concise answer and read through the entire file before giving an answer.
- Professionalism: Behave professionally, providing clear and concise responses.
- Synthesis, Coding, and Data Analysis: ensure coding blocks are explained.
- When handling dates: make sure that dates are searched using date fields and also if you don't find anything, use titles.
- Clarification: Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests. Try to make sure you know exactly what is being asked.
- Privacy and Security: Respect user privacy and handle all data securely.
*** Examples of Documentation ***
Here is the relevant query documentation from Google for the listFiles function:
What you want to query	Example
Files with the name "hello"	name = 'hello'
Files with a name containing the words "hello" and "goodbye"	name contains 'hello' and name contains 'goodbye'
Files with a name that does not contain the word "hello"	not name contains 'hello'
Folders that are Google apps or have the folder MIME type	mimeType = 'application/vnd.google-apps.folder'
Files that are not folders	mimeType != 'application/vnd.google-apps.folder'
Files that contain the text "important" and in the trash	fullText contains 'important' and trashed = true
Files that contain the word "hello"	fullText contains 'hello'
Files that do not have the word "hello"	not fullText contains 'hello'
Files that contain the exact phrase "hello world"	fullText contains '"hello world"'
Files with a query that contains the "\" character (e.g., "\authors")	fullText contains '\\authors'Files with ID within a collection, e.g. parents collection	'1234567' in parents
Files in an application data folder in a collection	'appDataFolder' in parents
Files for which user "test@example.org" has write permission	'test@example.org' in writers
Files for which members of the group "group@example.org" have write permission	'group@example.org' in writers
Files modified after a given date	modifiedTime > '2012-06-04T12:00:00' // default time zone is UTC
Files shared with the authorized user with "hello" in the name	sharedWithMe and name contains 'hello'
Files that have not been shared with anyone or domains (only private, or shared with specific users or groups)	visibility = 'limited'
Image or video files modified after a specific date	modifiedTime > '2012-06-04T12:00:00' and (mimeType contains 'image/' or mimeType contains 'video/')

Ví dụ về lược đồ OpenAPI

Sau khi bạn đã tạo GPT tùy chỉnh, hãy sao chép văn bản bên dưới trong bảng Actions. Đây là ví dụ về những gì bạn có thể đưa vào trong các hàm, nhưng . Bạn có thắc mắc không? Hãy xem Ví dụ về cách bắt đầu để xem bước này hoạt động chi tiết hơn. Ngoài ra, hãy thử ActionsGPT , một CustomGPT OpenAI được tạo ra để hỗ trợ Actions. Ba ví dụ là:

+ Liệt kê các tệp : đây là hành động cốt lõi liệt kê các tệp trong ổ đĩa của bạn. Trong đó có một số tham số, chẳng hạn như q,includeItemsFromAllDrives,supportsAllDrives

+ Lấy siêu dữ liệu : trong trường hợp danh sách không hoạt động, điều này có thể cung cấp bản sao lưu dựa trên một số kết quả nhất định - ví dụ, nếu người dùng cố gắng tìm kiếm thông qua "cuộc họp tuần trước", v.v.

+ Xuất : xuất theo nội dung byte. Để biết thêm thông tin, vui lòng tham khảo https://developers.google.com/drive/api/reference/rest/v3/files/export

Nói chung, nếu sử dụng 'get', mô hình sẽ cố gắng tải xuống tệp, điều này có thể không mong muốn. Do đó, nên sử dụng Export thay thế.

{ "openapi": "3.1.0", "info": { "title": "Google Drive API", "description": "API for interacting with Google Drive", "version": "1.0.0" }, "servers": [ { "url": "https://www.googleapis.com/drive/v3" } ], "paths": { "/files": { "get": { "operationId": "ListFiles", "summary": "List files", "description": "Retrieve a list of files in the user's Google Drive.", "parameters": [ { "name": "q", "in": "query", "description": "Query string for searching files.", "required": false, "schema": { "type": "string" } }, { "name": "includeItemsFromAllDrives", "in": "query", "description": "Whether both My Drive and shared drive items should be included in results.", "required": false, "schema": { "type": "string" } }, { "name": "supportsAllDrives", "in": "query", "description": "Whether the requesting application supports both My Drives and shared drives.", "required": false, "schema": { "type": "string" } }, { "name": "pageSize", "in": "query", "description": "Maximum number of files to return.", "required": false, "schema": { "type": "integer", "default": 10 } }, { "name": "pageToken", "in": "query", "description": "Token for continuing a previous list request.", "required": false, "schema": { "type": "string" } }, { "name": "fields", "in": "query", "description": "Comma-separated list of fields to include in the response.", "required": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "A list of files.", "content": { "application/json": { "schema": { "type": "object", "properties": { "kind": { "type": "string", "example": "drive#fileList" }, "nextPageToken": { "type": "string", "description": "Token to retrieve the next page of results." }, "files": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "mimeType": { "type": "string" } } } } } } } } } } } }, "/files/{fileId}": { "get": { "operationId": "getMetadata", "summary": "Get file metadata", "description": "Retrieve metadata for a specific file.", "parameters": [ { "name": "fileId", "in": "path", "description": "ID of the file to retrieve.", "required": true, "schema": { "type": "string" } }, { "name": "fields", "in": "query", "description": "Comma-separated list of fields to include in the response.", "required": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Metadata of the file.", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "mimeType": { "type": "string" }, "description": { "type": "string" }, "createdTime": { "type": "string", "format": "date-time" } } } } } } } } }, "/files/{fileId}/export": { "get": { "operationId": "export", "summary": "Export a file", "description": "Export a Google Doc to the requested MIME type.", "parameters": [ { "name": "fileId", "in": "path", "description": "ID of the file to export.", "required": true, "schema": { "type": "string" } }, { "name": "mimeType", "in": "query", "description": "The MIME type of the format to export to.", "required": true, "schema": { "type": "string", "enum": [ "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain" ] } } ], "responses": { "200": { "description": "The exported file.", "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } }, "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { "schema": { "type": "string", "format": "binary" } }, "text/plain": { "schema": { "type": "string", "format": "binary" } } } }, "400": { "description": "Invalid MIME type or file ID." }, "404": { "description": "File not found." } } } } }
}

Hướng dẫn xác thực

Dưới đây là hướng dẫn về cách thiết lập xác thực với ứng dụng của bên thứ 3 này. Bạn có thắc mắc không? Hãy xem Ví dụ về Bắt đầu để xem bước này hoạt động chi tiết hơn.

Các bước hành động trước

Trước khi thiết lập xác thực trong ChatGPT, vui lòng thực hiện các bước sau trong ứng dụng.

+ Đi tới Google Cloud Console

+ Điều hướng đến API & Dịch vụ đã bật và bật Google Drive API

+ Trong thanh tìm kiếm, hãy tìm kiếm Google Drive API:

+ Tạo thông tin xác thực OAuth mới (hoặc sử dụng thông tin xác thực hiện có). Lưu ý rằng nếu bạn chưa thiết lập màn hình thông tin xác thực OAuth, bạn sẽ cần phải thực hiện việc đó.

+ Trong quy trình này, bạn sẽ cần cấp quyền truy cập đúng, thiết lập người kiểm tra chính làm email kiểm tra nếu Kiểm tra được bật và thiết lập giới hạn tỷ lệ OAuth.

+ Tiếp theo, hãy vào credentials và nhấp vào “+ Create Credentials” rồi nhấp vào “Create Credentials”. Dưới đây là ví dụ về giao diện của màn hình này khi đã được thiết lập.

+ Xác định ID máy khách OAuth và Bí mật máy khách của bạn và lưu trữ cả hai giá trị một cách an toàn (xem ảnh chụp màn hình bên dưới)

Trong ChatGPT

Trong ChatGPT, nhấp vào "Xác thực" và chọn "OAuth" . Nhập thông tin bên dưới.

+ Client ID : sử dụng Client ID từ các bước trên

+ Bí mật của khách hàng : sử dụng Bí mật của khách hàng từ các bước trên

+ URL ủy quyền : https://accounts.google.com/o/oauth2/auth

+ URL mã thông báo : https://oauth2.googleapis.com/token

+ Phạm vi : https://www.googleapis.com/auth/drive

+ Lưu ý : để biết danh sách chi tiết hơn về phạm vi được bật, vui lòng tham khảo hướng dẫn OAuth 2.0 của Google.

+ Mã thông báo : Mặc định (POST)

+ Chính sách bảo mật : https://policies.google.com/privacy?hl=en-US

Các bước sau hành động

Sau khi thiết lập xác thực trong ChatGPT, hãy làm theo các bước dưới đây trong ứng dụng để hoàn tất Hành động.

+ Sao chép URL gọi lại từ Hành động GPT

+ Trong “URI chuyển hướng được ủy quyền”, hãy thêm URL gọi lại của bạn

Câu hỏi thường gặp & Xử lý sự cố

+ Lỗi URL gọi lại: Nếu bạn gặp lỗi URL gọi lại trong ChatGPT, hãy chú ý đến ảnh chụp màn hình ở trên. Bạn cần thêm URL gọi lại trực tiếp vào GCP để hành động xác thực chính xác.

Hot Deal

Họ tên (*)

Số điện thoại (*)

Email (*)

Dịch vụ

Đăng ký để nhận bản tin mới nhất !