Khám Phá Google Anti-gravity

Google Anti-gravity không chỉ là một công cụ; đó là một triết lý mới về kỹ thuật phần mềm. Trong kỷ nguyên của các agent lập trình, Google đã mạnh dạn định nghĩa lại quy trình phát triển bằng cách tung ra một Hệ thống Lập trình Agentic đầy đủ chức năng và đáng kinh ngạc, chạy hoàn toàn cục bộ (locally) trên máy tính của bạn.

Nếu bạn đang tìm kiếm một “lập trình viên cấp dưới” thông minh, đa nhiệm và luôn sẵn sàng làm việc, Anti-gravity chính là thứ bạn cần.

Dưới đây là những tính năng cốt lõi làm nên sức mạnh và sự khác biệt của Google Anti-gravity:

Google Antigravity và cách sử dụng

I.  Môi Trường Phát Triển & Khả Năng Cơ Bản

1. IDE Đầy Đủ Chức Năng Chạy Cục Bộ (Local, Full-fledged IDE)

Khác biệt lớn nhất so với các agent tiền nhiệm như Gemini CLA (CLI) hay Jules (Cloud), Anti-gravity là IDE lập trình đầy đủ chức năng đầu tiên của Google chạy trực tiếp trên máy của bạn. Giao diện quen thuộc (dựa trên VS Code) giúp bạn chuyển đổi mượt mà và tập trung vào công việc.

2. Hệ Thống Lập Trình Đa Agent & Đa Nhiệm

Đây là trụ cột sức mạnh của Anti-gravity.

  • Chạy Song Song: Cho phép bạn quản lý và chạy nhiều dự án hoặc nhiều tác vụ của các agent khác nhau cùng một lúc mà không bị gián đoạn.

  • Hộp Thư Đến Agent (Inbox): Cung cấp một trung tâm thông báo tập trung, nơi bạn nhận được cập nhật theo thời gian thực về tiến độ và trạng thái của tất cả các tác vụ đang được thực thi.

II. Lên Kế Hoạch Thông Minh & Tương Tác Có Kiểm Soát

3. Quy Trình Lập Kế Hoạch (Planning) Chi Tiết

Agent không thực thi ngay lập tức. Nó học hỏi từ quy trình phát triển phần mềm thực tế bằng cách:

  • Phân tích Yêu Cầu: Chia nhỏ tác vụ phức tạp thành danh sách các bước thực thi (Ví dụ: Nghiên cứu -> Triển khai -> Xác minh).

  • Chế Độ Planning: Lý tưởng cho các dự án mới, nghiên cứu sâu và các tác vụ phức tạp, cho phép agent lập kế hoạch kỹ lưỡng trước khi bắt đầu viết code.

4. Kiểm Soát Hoàn Toàn Qua Chế Độ Review

Bạn luôn giữ vai trò là Kiến trúc sư phần mềm.

  • Review Kế Hoạch: Bạn có thể xem xét chi tiết kế hoạch của agent trước khi thực thi.

  • Thêm Nhận Xét & Điều Chỉnh: Dễ dàng thêm nhận xét, yêu cầu thay đổi (ví dụ: “chỉ tạo 2 hình ảnh thay vì 4”) và agent sẽ tự động cập nhật kế hoạch dựa trên phản hồi của bạn.

III. Khả Năng Tự Sửa Lỗi & Tự Kiểm Tra Độc Đáo

5. Trình Duyệt Tích Hợp (Built-in Browser)

Đây là tính năng đột phá nhất. Anti-gravity nhúng một trình duyệt web, cho phép agent:

  • Tương Tác Website: Tự động nhấp, cuộn, gõ, và điều hướng các trang web.

  • Tự Kiểm Tra: Agent có thể mở ứng dụng vừa code, tự nhập liệu (ví dụ: khóa API), và chạy thử nghiệm hoàn toàn tự động để tìm và sửa lỗi. Điều này loại bỏ nhu cầu về các máy chủ bên ngoài hay công cụ kiểm thử phức tạp.

6. Video Phát Lại Hành Động (Action Playback)

  • Trong quá trình kiểm tra và sửa lỗi tự động, Anti-gravity ghi lại một video nhỏ (playback) về các hành động mà agent đã thực hiện (những cú nhấp chuột, cuộn, gõ phím).

  • Tính năng này cực kỳ hữu ích cho việc xem xét lại công việc của agent sau khi chạy tác vụ trong thời gian dài (ví dụ: qua đêm).

IV.  Học Tập Liên Tục & Tính Mở

7. Tính Năng Kiến Thức (Knowledge)

Anti-gravity không chỉ code; nó học hỏi. Nó xây dựng một cơ sở kiến thức theo thời gian, ghi lại:

  • Các vấn đề đã gặp phải.

  • Cách thức đã khắc phục các vấn đề đó. Điều này giúp agent ngày càng thông minh và hiệu quả hơn trong các dự án tương lai.

8. Hỗ Trợ Mô Hình Ngoài (Open Model Support)

Dù được xây dựng bởi Google và tối ưu với Gemini, đội ngũ Anti-gravity cam kết mở rộng hỗ trợ cho các mô hình từ nhà cung cấp khác (ví dụ: Claude, OpenAI). Đây là một bước đi đột phá cho thấy Google đang ưu tiên tính hiệu quả và sự lựa chọn cho nhà phát triển.

V. Điều gì làm IDE này tốt hơn các IDE khác?

Có 3 thứ:

  1. Agent Manager (Trình quản lý tác nhân).

  2. Evidential: Sau khi thực thi câu lệnh, IDE sẽ cung cấp cho dev các bằng chứng, chứng minh ứng dụng đã hoạt động bằng cách chụp ảnh màn hình, video, các test case đã thực hiện cho dev mà các công cụ khác không có.
  3. Inbuilt Browser (Trình duyệt tích hợp). Nếu bạn muốn test giao diện (UI), bạn có thể yêu cầu trình duyệt tự làm. Bạn cần thêm extension (tiện ích mở rộng) để làm việc này.

Trong Agent Manager, bạn có thể làm việc với nhiều dự án cùng lúc, tạo nhiều agent cho các dự án khác nhau và chuyển đổi qua lại. Bạn có thể thay đổi Model AI. Ở đây có Gemini 3 Pro (bản gốc ghi nhầm là “Germany”) là một model rất tốt. Bạn cũng có thể thử các model khác như GPT (bản gốc ghi “GPD”).

 

VI. Thử nghiệm

OK. nói nhiều rồi, bây giờ sẽ đến lúc chúng ta thử nhiệm với Anti-gravity.

Antigravity vs Cursor: Which AI Coding Tool Is Better? - Skywork ai

Tôi sẽ thử nghiệm trực tiếp nó bằng 2 cách.

1.   Thử nghiệm Anti-gravity với dự án công ty
(Lưu ý: Vì là dự án nội bộ nên tôi không thể quay video hoặc chụp màn hình.)

Cấu hình máy: Apple M4, Python 3.11
Bối cảnh dự án:

  • Dự án có một phần hoạt động giống VSCode.

  • Có một mô-đun xử lý Git, sử dụng GitPython để push các file thay đổi từ local lên GitHub.

  • Đang gặp một lỗi: khi người dùng chỉnh sửa file và chọn “Git push”, hệ thống báo lỗi conflict.

Tôi dùng cùng một prompt, mode: plan, model: Claude Sonnet 4.5 để so sánh.

Kết quả thử nghiệm

AntiGravity

  • Không sửa được lỗi conflict.

  • Tự ý chỉnh sửa thêm nhiều file không liên quan → phát sinh bug mới.

Cursor

  • Sửa được lỗi conflict.

  • Không tự động thay đổi những file không liên quan, tránh làm phát sinh lỗi mới.

2. Tự tạo một ứng dụng mới  theo yêu cầu đã được viết ở link sau:

Link: https://docs.google.com/document/d/1ZfW0Fdm3l-x4gKbf9e2q54o5OrMXrd-NS4QWyZZPLoA/edit?usp=sharing

Kết quả:

 

Kết luận bài test:

  • Tạo code tốt, ở mức ổn
  • Source code ổn
  • Lỗi: “Agent terminated due to error” (Tác nhân bị ngắt do lỗi). Tôi nhận được khá nhiều lỗi,
  • Frontend: Như shit vậy,
  • Giới hạn Quota: Rất dễ đạt giới hạn khi sử dụng mô hình Gemini 3 Pro

So sánh Anti-Gravity và Cursor

Tiêu chí Anti-Gravity Cursor
Tính ổn định Kém (Thường xuyên lỗi Tác nhân) Tốt (Sản phẩm trưởng thành, ít lỗi)
Trải nghiệm sử dụng Phức tạp, mang tính quản lý. Dễ dùng, tích hợp AI mượt mà trong IDE truyền thống.
Tầm nhìn Thay đổi mô hình lập trình (Agent Manager). Nâng cao hiệu suất lập trình (AI Assistant).
Khuyến nghị hiện tại Chỉ nên thử nghiệm, không dùng cho công việc. Lựa chọn hàng đầu cho lập trình AI chuyên nghiệp.

Ý kiến cá nhân:

  • Cursor vẫn là lựa chọn tốt hơn và đáng tin cậy hơn cho bất kỳ ai muốn sử dụng AI để xây dựng ứng dụng. Anti-Gravity, mặc dù có tầm nhìn tiên phong, vẫn chỉ là một sản phẩm thử nghiệm còn nhiều lỗi và cần thời gian để phát triển
  • Anh/Em Dev vẫn nên sử dụng Claude Sonnet hơn là sử dụng Gemini 3 Pro
  • Khi dùng cursor nếu hết token có thẻ qua sử dụng Antigravity để fix bug các bug nhỏ, cần review cẩn thận, vì có thể Antigravity sẽ thay đổi code ở nhưng files không mong muốn, prompt phải chuẩn chỉ.

 

Google Workspace Flows: Tự động hóa công việc với sức mạnh AI – Hướng dẫn toàn diện

I. Giới thiệu

Trong thời đại số hóa và làm việc từ xa ngày càng phổ biến, việc tối ưu hóa quy trình làm việc và giảm thiểu các tác vụ lặp đi lặp lại trở thành ưu tiên hàng đầu của mọi tổ chức. Google đã giới thiệu một giải pháp đột phá mang tên **Google Workspace Flows** – một ứng dụng web được hỗ trợ bởi trí tuệ nhân tạo Gemini, giúp tự động hóa các quy trình công việc phức tạp mà không cần bất kỳ kỹ năng lập trình nào.

Được công bố tại sự kiện Google Next 2025, Workspace Flows đánh dấu bước tiến mới trong việc tích hợp AI vào công việc hàng ngày, cho phép người dùng tạo ra các quy trình tự động mạnh mẽ chỉ bằng ngôn ngữ tự nhiên. Đây không chỉ là một công cụ tự động hóa đơn thuần, mà còn là một trợ lý AI thông minh có khả năng nghiên cứu, phân tích và tạo nội dung để hỗ trợ công việc của bạn.

II. Google Workspace Flows là gì?

1. Định nghĩa và bản chất

Google Workspace Flows là một ứng dụng trực tuyến cho phép bạn tự động hóa các tác vụ hàng ngày và công việc thường xuyên trên các dịch vụ Google Workspace với sự hỗ trợ của Gemini – hoàn toàn không cần kỹ năng lập trình. Đây là giải pháp no-code với giao diện tương tự như chat với một chatbot AI, giúp bất kỳ ai cũng có thể tạo ra các quy trình tự động phức tạp.

Khác với các giải pháp tự động hóa truyền thống như Apps Script hay AppSheet, Workspace Flows không yêu cầu bạn phải hiểu biết về lập trình hay thiết lập Cloud Project. Bạn chỉ cần mô tả những gì bạn muốn tự động hóa bằng ngôn ngữ thường ngày, và Gemini sẽ tạo ra quy trình làm việc cho bạn.

2. Cách thức hoạt động

Workspace Flows hoạt động dựa trên ba thành phần cốt lõi:

2.1. Starters (Trình kích hoạt)

Đây là sự kiện hoặc lịch trình khởi động quy trình của bạn. Các ví dụ về starter bao gồm:
– Khi bạn nhận được email từ một người cụ thể
– Theo lịch trình định kỳ (ví dụ: mỗi thứ Hai lúc 9 giờ sáng)
– Khi có phản hồi mới từ Google Forms
– Khi ai đó đề cập đến bạn trong Google Chat Spaces
– Khi có file mới được thêm vào thư mục Drive
– Dựa trên sự kiện Google Calendar

2.2. Steps (Các bước hành động)

Đây là các hành động mà quy trình sẽ thực hiện sau khi được kích hoạt. Ví dụ:
– Trả lời email
– Cập nhật bảng tính
– Yêu cầu Gemini nghiên cứu một chủ đề
– Gửi thông báo qua Chat
– Tạo tài liệu mới trong Drive
– Lên lịch cuộc họp

2.3. Variables (Biến số)

Variables cho phép bạn kết nối thông tin từ bước này sang bước khác. Ví dụ, bạn có thể tự động lấy địa chỉ email của người gửi từ tin nhắn đến và thêm nó vào bảng tính.

3. Các tính năng nổi bật của Google Workspace Flows

3.1. Tự động hóa bằng ngôn ngữ tự nhiên

Không giống như các công cụ tự động hóa truyền thống đòi hỏi phải hiểu về logic lập trình, Workspace Flows cho phép bạn mô tả quy trình bằng tiếng Anh đơn giản. Ví dụ:

“Mỗi khi tôi nhận được email từ khách hàng, hãy đánh nhãn nó là ‘hỗ trợ’, sau đó soạn thảo phản hồi dựa trên tài liệu FAQ này”*

Gemini sẽ tự động tạo ra quy trình hoàn chỉnh với các bước cần thiết, bạn chỉ cần kiểm tra và điều chỉnh nếu cần.

3.2. Các bước AI chuyên biệt

Workspace Flows cung cấp nhiều loại bước AI tối ưu cho các mục đích khác nhau:

Ask Gemini (Hỏi Gemini)
– Tốt nhất cho các câu hỏi chung hoặc tạo văn bản
– Có thể tìm kiếm thông tin trên web
– Tóm tắt trạng thái dự án dựa trên ghi chú họp và bảng tính
– Soạn thảo nội dung dựa trên yêu cầu

Ask a Gem (Hỏi một Gem)
– Sử dụng khi cần chuyên môn của một Gem cụ thể
– Tạo ý tưởng bán hàng dựa trên biểu mẫu quan tâm của khách hàng
– Sử dụng Gem tùy chỉnh được đào tạo trên tài liệu của bạn

Decide (Quyết định)
– Cho phép quy trình chỉ chạy khi đáp ứng điều kiện chủ quan hoặc phức tạp
– Lọc email có giọng điệu tức giận
– Phát hiện file về chủ đề cụ thể
– Nhận diện phản hồi tích cực

Extract (Trích xuất)
– Rút ra thông tin cụ thể từ văn bản
– Trích xuất số đơn hàng, số điện thoại, địa chỉ
– Tìm các mục hành động từ email hoặc ghi chú

Summarize (Tóm tắt)
– Tóm tắt chuỗi email
– Tóm tắt email chưa đọc
– Tóm tắt nội dung tài liệu
– Rút ra insights từ bảng tính

3.3. Điều kiện và logic phức tạp

Workspace Flows hỗ trợ hai loại bước kiểm tra điều kiện:

Decide (AI-powered)
– Sử dụng Gemini để đánh giá điều kiện bạn mô tả là đúng hay sai
– Có thể xử lý điều kiện phức tạp và chủ quan
– Cho phép chỉ định nhiều điều kiện cùng lúc

Check if (So sánh giá trị)
– So sánh các giá trị cụ thể
– Sử dụng toán tử logic như “is”, “is not”, “contains”
– Có thể kết hợp nhiều điều kiện với AND/OR

Bạn có thể tạo các quy trình con (substeps) chỉ chạy khi điều kiện được đáp ứng, cho phép kiểm soát tinh vi hành vi của agent.

3.4. Tích hợp ứng dụng bên thứ ba

Mặc dù hiện tại Workspace Flows tập trung chủ yếu vào các ứng dụng Google Workspace, nhưng đã có hỗ trợ cho các tích hợp bên thứ ba như:
– Asana (quản lý dự án)
– Mailchimp (email marketing)
– Salesforce (CRM)
– Và nhiều dịch vụ khác đang được bổ sung

Các tích hợp này cho phép bạn tự động hóa công việc xuyên suốt giữa Google Workspace và các công cụ kinh doanh khác mà tổ chức bạn đang sử dụng.

3.5. Templates sẵn có

Workspace Flows cung cấp nhiều mẫu có sẵn cho các tác vụ phổ biến:
– Thông báo khi quản lý gửi tin nhắn cho bạn
– Tự động tóm tắt các hành động được giao
– Chào mừng thành viên mới trong nhóm
– Gửi nhắc nhở theo lịch
– Cập nhật nhóm về thay đổi trong lịch họp
– Đánh giá mức độ khẩn cấp của công việc từ email

Những template này giúp bạn bắt đầu nhanh chóng mà không cần tạo từ đầu.

3.6. Kiểm soát nguồn dữ liệu

Trong các bước Ask Gemini và Ask a Gem, bạn có thể chọn nguồn dữ liệu mà Gemini được phép sử dụng:

Tất cả nguồn (mặc định)
– Web
– Gmail và Chat messages
– Files trong Drive (của bạn hoặc được chia sẻ)
– Calendar của bạn
– Nội dung từ các tích hợp đã liên kết

Chỉ Web
– Chỉ sử dụng các website công khai
– Gemini không thể truy cập dữ liệu tổ chức của bạn
– Phù hợp cho các quy trình chia sẻ thông tin ra bên ngoài tự động

Tính năng này giúp bạn: Kiểm soát quyền riêng tư và bảo mật thông tin tổ chức.

4. Lợi ích và sự tiện lợi

4.1. Tiết kiệm thời gian đáng kể

Workspace Flows giúp loại bỏ các tác vụ lặp đi lặp lại, cho phép bạn tập trung vào công việc có giá trị cao hơn. Thay vì phải:
– Thủ công phân loại và gắn nhãn hàng trăm email mỗi ngày
– Sao chép thông tin giữa các ứng dụng khác nhau
– Tự tóm tắt các cuộc họp và email dài
– Nhắc nhở thủ công về các deadline

Bạn có thể để Workspace Flows tự động xử lý tất cả những việc này, tiết kiệm hàng giờ mỗi tuần.

4.2. Không cần kỹ năng lập trình

Đây là lợi ích lớn nhất so với các giải pháp tự động hóa truyền thống:
– Không cần học Apps Script, JavaScript, hoặc bất kỳ ngôn ngữ lập trình nào
– Không cần thiết lập môi trường phát triển
– Không cần hiểu về API và webhooks
– Chỉ cần mô tả bằng ngôn ngữ tự nhiên những gì bạn muốn

Điều này mở ra khả năng tự động hóa cho tất cả mọi người trong tổ chức, không chỉ đội ngũ IT.

4.3. Tích hợp sâu với hệ sinh thái Google Workspace

Workspace Flows được thiết kế đặc biệt cho Google Workspace, do đó:
– Tích hợp mượt mà với Gmail, Drive, Calendar, Chat, Docs, Sheets
– Không cần xác thực phức tạp giữa các ứng dụng
– Hiểu rõ cấu trúc dữ liệu của các ứng dụng Workspace
– Tận dụng được đầy đủ sức mạnh của Gemini đã tích hợp trong Workspace

4.4. Bảo mật và tuân thủ

Vì Workspace Flows là một phần của Google Workspace:
– Dữ liệu được lưu trữ an toàn trong môi trường Workspace của bạn
– Tuân thủ các chính sách bảo mật và quản trị mà admin đã thiết lập
– Không cần lo lắng về việc dữ liệu tổ chức bị chia sẻ với dịch vụ bên thứ ba không đáng tin cậy
– Có kiểm soát chi tiết về quyền truy cập và chia sẻ

4.5. Dễ dàng chia sẻ và cộng tác

Bạn có thể:
– Chia sẻ quy trình với đồng nghiệp
– Sao chép và tùy chỉnh quy trình của người khác
– Tạo thư viện các quy trình chung cho toàn tổ chức
– Cho phép nhiều người cùng hưởng lợi từ một quy trình tốt

4.6. Khả năng mở rộng và linh hoạt

Workspace Flows có thể xử lý từ các tác vụ đơn giản đến phức tạp:
– Bắt đầu với quy trình đơn giản 2-3 bước
– Dần dần thêm các bước phức tạp hơn
– Kết hợp nhiều quy trình con với logic điều kiện
– Tích hợp nhiều ứng dụng và dịch vụ khác nhau

III. Các use case hiệu quả

1. Quản lý email và hộp thư đến

Use case: Tự động phân loại và ưu tiên email

Tình huống: Bạn nhận hàng trăm email mỗi ngày và mất nhiều thời gian để phân loại, xác định email quan trọng cần xử lý ngay.

Giải pháp với Workspace Flows:
– Starter: Khi nhận được email mới
– Bước 1: Gemini phân tích nội dung, tone và người gửi
– Bước 2: Decide – xác định mức độ ưu tiên (cao, trung bình, thấp)
– Bước 3: Tự động gắn nhãn tương ứng
– Bước 4: Với email ưu tiên cao, gửi thông báo qua Chat
– Bước 5: Tóm tắt nội dung chính và gửi cho bạn

Kết quả: Bạn luôn biết email nào cần xử lý ngay, tiết kiệm hàng giờ phân loại thủ công mỗi tuần.

Use case: Tự động trả lời email khách hàng

Tình huống: Đội hỗ trợ khách hàng nhận nhiều câu hỏi lặp lại, mất thời gian soạn phản hồi tương tự.

Giải pháp:
– Starter: Email mới có nhãn “Hỗ trợ khách hàng”
– Bước 1: Extract – trích xuất vấn đề chính từ email
– Bước 2: Ask a Gem – sử dụng Gem “Customer Service Helper” được đào tạo với kiến thức sản phẩm và chính sách
– Bước 3: Gem tìm kiếm giải pháp trong tài liệu sản phẩm
– Bước 4: Soạn thảo email phản hồi chuyên nghiệp
– Bước 5: Lưu draft trong Gmail để nhân viên xem lại trước khi gửi

Kết quả: Giảm 70% thời gian soạn email, đảm bảo phản hồi nhất quán và chính xác.

2. Quản lý dự án và theo dõi công việc

Use case: Tự động cập nhật tiến độ dự án

Tình huống: Quản lý dự án cần tổng hợp cập nhật từ nhiều nguồn: email, chat, tài liệu, bảng tính.

Giải pháp:
– Starter: Lịch trình hàng tuần (mỗi thứ Sáu lúc 4 giờ chiều)
– Bước 1: Recap unread emails – tóm tắt email chưa đọc từ thành viên nhóm
– Bước 2: Summarize – tóm tắt các thảo luận quan trọng trong Chat Spaces
– Bước 3: Ask Gemini – phân tích bảng theo dõi dự án trong Sheets
– Bước 4: Ask Gemini – tạo báo cáo tổng hợp tiến độ, rủi ro, và hành động cần thiết
– Bước 5: Tạo Google Doc với báo cáo
– Bước 6: Gửi email tới stakeholders với link tới báo cáo
– Bước 7: Post summary trong team Chat Space

Kết quả: Tiết kiệm 3-4 giờ mỗi tuần trong việc tổng hợp báo cáo, đảm bảo mọi người đều cập nhật.

Use case: Theo dõi action items từ cuộc họp

Tình huống: Sau mỗi cuộc họp, có nhiều action items được phân công nhưng dễ bị quên hoặc bỏ sót.

Giải pháp:
– Starter: Sau sự kiện Calendar (cuộc họp kết thúc)
– Bước 1: Truy cập ghi chú cuộc họp trong Drive (từ link trong sự kiện)
– Bước 2: Extract – trích xuất tất cả action items và người được giao
– Bước 3: Check if – kiểm tra xem có action item nào được giao cho bạn không
– Bước 4 (nếu có):** Gửi Chat notification cho bạn với danh sách action items
– Bước 5: Thêm action items vào bảng theo dõi trong Sheets
– Bước 6: Tạo reminder trong Calendar cho mỗi action item

Kết quả: Không bỏ sót action item nào, mọi người biết rõ trách nhiệm của mình ngay sau họp.

3. Dịch vụ khách hàng và hỗ trợ

Use case: Xử lý phản hồi từ Google Forms

Tình huống: Công ty thu thập phản hồi khách hàng qua Forms, cần xử lý nhanh các vấn đề khẩn cấp.

Giải pháp:
– Starter: Khi có phản hồi mới trong Form
– Bước 1: Summarize – Gemini tóm tắt phản hồi
– Bước 2: Decide – xác định mức độ ưu tiên (cao, trung bình, thấp) và sentiment (tích cực, trung lập, tiêu cực)
– Bước 3: Check if – nếu ưu tiên cao hoặc sentiment tiêu cực
– Bước 4: Post ngay vào Customer Service Chat Space với tag @team
– Bước 5: Ask a Gem – Gem phân tích vấn đề và đề xuất giải pháp từ knowledge base
– Bước 6: Extract – trích xuất email khách hàng
– Bước 7: Soạn email draft phản hồi
– Bước 8: Thêm vào tracking sheet

Kết quả: Phản hồi nhanh với khách hàng không hài lòng trong vòng vài phút thay vì vài giờ hoặc ngày.

4. Marketing và truyền thông

Use case: Đảm bảo tính nhất quán về giọng điệu thương hiệu

Tình huống: Nhiều người tạo nội dung marketing, cần đảm bảo giọng điệu thương hiệu nhất quán.

Giải pháp:
– Starter: Khi file mới được thêm vào thư mục “Marketing Content Draft” trong Drive
– Bước 1: Ask a Gem – sử dụng Gem “Brand Voice Guardian” được đào tạo với brand guidelines
– Bước 2: Gem phân tích nội dung và đưa ra feedback về tone, style, messaging
– Bước 3: Check if – nếu có vấn đề về brand voice
– Bước 4: Tạo Google Doc với đề xuất chỉnh sửa chi tiết
– Bước 5: Gửi Chat notification cho tác giả với link đến feedback
– Bước 6: Nếu đạt chuẩn, di chuyển file sang thư mục “Ready for Review”

Kết quả: Đảm bảo 100% nội dung tuân thủ brand guidelines trước khi xuất bản.

5. Onboarding nhân viên mới

Use case: Tự động hóa quy trình chào đón

Tình huống: Khi có nhân viên mới, cần nhiều bước onboarding lặp lại.

Giải pháp:
– Starter: Khi hàng mới được thêm vào Sheets “New Hires”
– Bước 1: Extract – lấy tên, email, bộ phận, ngày bắt đầu
– Bước 2: Tạo thư mục Drive cho nhân viên mới
– Bước 3: Copy tài liệu onboarding template vào thư mục
– Bước 4: Ask Gemini – tạo email chào mừng cá nhân hóa
– Bước 5: Gửi email với thông tin quan trọng và link tới thư mục
– Bước 6: Thêm nhân viên vào Chat Spaces phù hợp
– Bước 7: Post thông báo chào mừng trong company-wide Chat Space
– Bước 8: Tạo Calendar events cho các buổi training

Kết quả: Trải nghiệm onboarding nhất quán và chuyên nghiệp, HR tiết kiệm 2-3 giờ cho mỗi nhân viên mới.

6. Phê duyệt và quy trình làm việc

Use case: Quy trình phê duyệt nghỉ phép

Tình huống: Nhân viên gửi yêu cầu nghỉ phép qua Form, cần được quản lý phê duyệt.

Giải pháp:
– Starter: Phản hồi mới trong Form “Leave Request”
– Bước 1: Extract – trích xuất thông tin: nhân viên, ngày nghỉ, lý do, quản lý
– Bước 2: Check if – kiểm tra xung đột với Calendar (đã có sự kiện quan trọng trong ngày đó không)
– Bước 3: Ask Gemini – kiểm tra lịch sử nghỉ phép trong Sheets
– Bước 4: Tạo email tới quản lý với tóm tắt yêu cầu và thông tin liên quan
– Bước 5: Add link phê duyệt/từ chối trong email
– Bước 6: Sau khi quản lý phản hồi, cập nhật Sheets
– Bước 7: Gửi thông báo cho nhân viên về quyết định
– Bước 8: Nếu được phê duyệt, tạo out-of-office event trong Calendar

Kết quả: Quy trình phê duyệt minh bạch, nhanh chóng, và tự động cập nhật.

7. Báo cáo và phân tích

Use case: Báo cáo hiệu suất hàng tuần

Tình huống: Cần tổng hợp dữ liệu từ nhiều nguồn để tạo báo cáo hiệu suất.

Giải pháp:
– Starter: Lịch hàng tuần (thứ Hai, 8 giờ sáng)
– Bước 1: Ask Gemini – phân tích dữ liệu bán hàng trong Sheets tuần trước
– Bước 2: Ask Gemini – phân tích metrics từ tích hợp Salesforce
– Bước 3: Summarize – tóm tắt feedback khách hàng từ email
– Bước 4: Ask Gemini – tạo insights và recommendations dựa trên tất cả dữ liệu
– Bước 5: Tạo Google Slides với báo cáo visualized
– Bước 6: Gửi email cho leadership team
– Bước 7: Post summary trong Sales Chat Space

Kết quả: Báo cáo chính xác, đúng giờ, cho phép ra quyết định nhanh hơn.

IV. Hướng dẫn bắt đầu với Google Workspace Flows

1. Yêu cầu trước khi bắt đầu

Để sử dụng Google Workspace Flows, bạn cần:

1. Tài khoản Google Workspace: Flows không khả dụng cho tài khoản Gmail cá nhân
2. Quyền truy cập Gemini: Tài khoản của bạn phải được phép sử dụng Gemini và các tính năng của nó
3. Đăng ký chương trình Gemini Alpha**: Hiện tại Workspace Flows chỉ khả dụng cho khách hàng trong chương trình Gemini Alpha (khách hàng mua license Gemini for Google Workspace trước ngày 15/1/2025)
4. Trình duyệt web được hỗ trợ: Workspace Flows chưa hỗ trợ trên thiết bị di động
5. Bật smart features: Để sử dụng đầy đủ tính năng AI, bạn cần bật smart features và personalization settings

2. Cách 1: Tạo Flow với AI (Khuyến nghị cho người mới)

Đây là cách nhanh nhất và dễ nhất để bắt đầu:

Bước 1: Truy cập Workspace Flows
– Mở trình duyệt và truy cập: [https://flows.workspace.google.com](https://flows.workspace.google.com)
– Hoặc click vào biểu tượng Flows trong Gmail

Bước 2: Mô tả quy trình bạn muốn tạo
– Click vào nút “+” để tạo flow mới
– Nhập mô tả bằng tiếng Anh về những gì bạn muốn tự động hóa
– Ví dụ: “When I get a customer support email, label it as support and then draft a response based on this FAQ doc [link]”

Bước 3: Xem lại và điều chỉnh
– Gemini sẽ tạo quy trình với các bước cụ thể
– Xem qua từng bước trong panel bên trái
– Click vào mỗi bước để xem và chỉnh sửa cấu hình
– Bạn có thể thêm, xóa, hoặc sắp xếp lại các bước

Bước 4: Test run (Tùy chọn nhưng khuyến nghị)
– Click “Test run” để chạy thử quy trình một lần
– Chọn điều kiện khởi động
– Quan sát kết quả để đảm bảo quy trình hoạt động đúng

Bước 5: Kích hoạt flow
– Khi hài lòng, click “Turn on”
– Flow của bạn sẽ tự động chạy khi điều kiện được đáp ứng

Mẹo để có kết quả tốt nhất:
– Nói rõ khi nào agent nên bắt đầu: Thay vì “mỗi tuần”, hãy nói “Mỗi thứ Hai lúc 4 giờ chiều”
– Chỉ định người cụ thể bằng email: Thay vì “quản lý của tôi”, dùng địa chỉ email cụ thể
– Nói rõ app nào sẽ dùng: Thay vì “gửi tin nhắn cho tôi”, nói “gửi tin nhắn cho tôi trong Chat”
– Cung cấp link cụ thể: Khi đề cập đến file hoặc folder, cung cấp link Drive

3. Cách 2: Bắt đầu với Template

Nếu bạn mới làm quen, template là cách tuyệt vời để học cách Flows hoạt động:

Bước 1: Duyệt templates
– Trong Workspace Flows builder, vào phần “Discover”
– Xem qua các template có sẵn
– Click vào template phù hợp với nhu cầu của bạn

Bước 2: Tùy chỉnh template
– Template sẽ mở với các bước đã được thiết lập sẵn
– Click qua từng bước để hiểu cách hoạt động
– Điều chỉnh các bước cho phù hợp với tình huống của bạn:
– Thay đổi starter (ví dụ: email từ ai, lịch trình nào)
– Sửa nội dung tin nhắn
– Thay đổi người nhận
– Thêm hoặc bỏ bước

Bước 3: Kiểm tra và kích hoạt
– Chú ý các dấu chấm đỏ cảnh báo – chúng cho biết bước nào còn thiếu thông tin bắt buộc
– Điền đầy đủ thông tin cần thiết
– Test run để đảm bảo hoạt động đúng
– Click “Turn on”

Ví dụ: Sử dụng template “Thông báo khi quản lý gửi email”
1. Chọn template “Stay on top of asks from manager”
2. Bước Starter: Điền email của quản lý vào filter
3. Bước Summarize: Kiểm tra prompt tóm tắt, tùy chỉnh nếu cần
4. Bước Send Chat: Chọn gửi cho chính bạn
5. Test bằng cách nhờ quản lý gửi email thử
6. Kích hoạt khi mọi thứ hoạt động tốt

4. Cách 3: Tạo từ đầu (Dành cho người dùng nâng cao)

Khi bạn đã quen với Workspace Flows, tạo từ đầu cho phép kiểm soát hoàn toàn:

Bước 1: Tạo flow mới
– Click nút “+” trong Workspace Flows builder
– Chọn “Start from scratch”

Bước 2: Chọn Starter
– Click “Choose a starter” trong panel bên phải
– Chọn loại trigger phù hợp:
– Schedule (lịch trình)
– Email received (nhận email)
– Form response (phản hồi form)
– Calendar event (sự kiện lịch)
– Chat message (tin nhắn chat)
– File added to Drive (file mới trong Drive)
– Cấu hình chi tiết cho starter

Bước 3: Thêm các Steps
– Click “Add step” trong panel trái
– Chọn loại step phù hợp:
– AI steps: Ask Gemini, Ask a Gem, Decide, Extract, Summarize
– Gmail: Send email, Add label, List emails
– Drive: Create folder, Save file
– Chat: Send message, Post in space
– Calendar: Create event, Add guests
– Docs/Sheets: Create, Update
– Cấu hình mỗi step với thông tin cần thiết
– Sử dụng variables để kết nối dữ liệu giữa các steps

Bước 4: Thêm logic điều kiện (nếu cần)
– Add bước “Decide” hoặc “Check if”
– Mô tả điều kiện cần kiểm tra
– Thêm substeps sẽ chạy khi điều kiện đúng
– Có thể thêm substeps cho điều kiện ngược lại

Bước 5: Sắp xếp và tối ưu
– Kéo thả để sắp xếp lại thứ tự steps
– Xóa steps không cần thiết
– Đảm bảo logic flow rõ ràng và hiệu quả

Bước 6: Test và debug
– Chạy test run với dữ liệu thật
– Kiểm tra Activity panel để xem chi tiết từng bước
– Sửa lỗi nếu có
– Test lại cho đến khi hoạt động hoàn hảo

Bước 7: Kích hoạt và theo dõi
– Click “Turn on”
– Theo dõi Activity để xem flow chạy trong thực tế
– Điều chỉnh nếu cần dựa trên kết quả thực tế

5. Làm việc với Variables

Variables là chìa khóa để tạo flows mạnh mẽ:

Hiểu về Variables:
– Mỗi step tạo ra variables chứa output của nó
– Ví dụ: Step “Receive email” tạo variables như sender email, subject, body
– Bạn có thể sử dụng variables này trong các steps sau

Cách sử dụng Variables:
1. Trong step configuration, tìm trường có thể chấp nhận variables
2. Click vào icon “+” hoặc “Insert variable”
3. Chọn variable từ danh sách (từ các steps trước)
4. Variable sẽ được thêm vào text của bạn

Ví dụ thực tế:

Step 1: Receive email
Variables: sender_email, subject, body

Step 2: Ask Gemini “Summarize this email: {body}”
Variables: summary

Step 3: Send Chat message “You got email from {sender_email} about {subject}. Summary: {summary}”

5. Quản lý và chia sẻ Flows

5.1 Xem danh sách flows:
– Vào “My flows” để xem tất cả flows bạn đã tạo
– Flows được hiển thị với trạng thái: On, Off, hoặc Error

5.2 Chỉnh sửa flow:
– Click vào flow để mở editor
– Thực hiện thay đổi cần thiết
– Click “Save” hoặc “Turn on” để áp dụng

5.3 Chia sẻ flow:
– Mở flow cần chia sẻ
– Click nút “Share”
– Nhập email của người bạn muốn chia sẻ
– Chọn quyền: View only hoặc Can edit
– Click “Send”

5.4 Sao chép flow:
– Click vào menu ba chấm của flow
– Chọn “Make a copy”
– Đặt tên mới và tùy chỉnh

5.5 Xóa flow:
– Click vào menu ba chấm
– Chọn “Delete”
– Xác nhận

5.6 Xem Activity:
– Click vào “Activity” trong flow editor
– Xem lịch sử các lần flow đã chạy
– Click vào mỗi run để xem chi tiết từng bước
– Hữu ích cho debugging và tối ưu

6. Mẹo và thực hành tốt nhất

6. 1. Bắt đầu đơn giản
– Đừng cố tạo flow phức tạp ngay từ đầu
– Bắt đầu với 2-3 steps đơn giản
– Test kỹ trước khi thêm complexity

6.2. Sử dụng Test run thường xuyên
– Luôn test sau mỗi thay đổi lớn
– Kiểm tra kỹ output của mỗi step
– Đảm bảo variables được truyền đúng

6.3. Viết prompts rõ ràng cho Gemini
– Cung cấp context đầy đủ
– Sử dụng variables để Gemini có dữ liệu cụ thể
– Đưa ra hướng dẫn chi tiết về format output mong muốn

6.4. Kiểm soát quyền truy cập dữ liệu
– Cẩn thận khi cho phép Gemini truy cập tất cả dữ liệu Workspace
– Với flows chia sẻ external, chọn “Web only” cho Gemini
– Review output trước khi tự động gửi ra ngoài

6.5. Tổ chức flows
– Đặt tên flow có ý nghĩa, mô tả rõ mục đích
– Nhóm các flows liên quan
– Document lý do và cách hoạt động của flow phức tạp

6.6. Theo dõi và tối ưu
– Thường xuyên kiểm tra Activity log
– Xác định bottlenecks hoặc steps thất bại
– Cải tiến dựa trên cách flow hoạt động trong thực tế

6. 7. Học từ cộng đồng
– Khám phá templates và flows người khác chia sẻ
– Tham gia cộng đồng Google Workspace
– Chia sẻ flows hữu ích của bạn

7. Troubleshooting và các vấn đề thường gặp

7.1 Flow không chạy

Nguyên nhân có thể:
– Flow chưa được bật
– Điều kiện starter không được đáp ứng
– Quyền truy cập bị từ chối

Giải pháp:
– Kiểm tra toggle “On/Off”
– Xác minh điều kiện starter chính xác (email address, filter, schedule)
– Kiểm tra permissions của các app được sử dụng
– Xem Activity log để tìm error messages

7.2 Steps thất bại

Nguyên nhân:
– Variables không tồn tại hoặc empty
– Permission issues với files/folders
– API limits exceeded
– Gemini không thể xử lý request

Giải pháp:
– Kiểm tra variables có giá trị hợp lệ không
– Đảm bảo bạn có quyền truy cập tất cả resources
– Add error handling với conditional steps
– Đơn giản hóa prompts cho Gemini

7.3 Gemini responses không như mong đợi

Cải thiện:
– Cung cấp context cụ thể hơn trong prompt
– Sử dụng variables để đưa dữ liệu thực vào prompt
– Thêm examples về output mong muốn
– Thử nghiệm với different phrasings
– Sử dụng Gems với specialized knowledge

7.4 Không kết nối được third-party integrations

Giải pháp:
– Kiểm tra subscription cho third-party service
– Liên hệ admin xem có policy restrictions không
– Cài đặt helper apps nếu yêu cầu
– Disconnect và reconnect integration

7.5 Flow chạy quá chậm

Tối ưu:
– Giảm số lượng AI steps không cần thiết
– Sử dụng conditional steps để skip unnecessary work
– Combine multiple similar steps thành một
– Xem xét sử dụng scheduled runs thay vì real-time

8. So sánh với các giải pháp khác

8.1 Workspace Flows vs. Apps Script

Apps Script:
– Ưu điểm: Linh hoạt tối đa, có thể làm bất cứ điều gì
– Nhược điểm: Cần biết lập trình JavaScript, phức tạp, khó maintain

Workspace Flows:
– Ưu điểm: No-code, dễ dùng, tích hợp AI, visual interface
– Nhược điểm: Ít linh hoạt hơn, giới hạn bởi available steps

Khi nào dùng cái gì:
– Flows: Hầu hết use cases tự động hóa thông thường
– Apps Script: Logic rất phức tạp, custom integrations

8.2 Workspace Flows vs. Zapier/Make

Zapier/Make:
– Ưu điểm: Nhiều integrations với third-party apps hơn
– Nhược điểm: Chi phí riêng, dữ liệu qua third-party, ít tích hợp AI

Workspace Flows:
– Ưu điểm: Tích hợp sâu Gemini, an toàn hơn (dữ liệu trong Workspace), miễn phí (included trong subscription)
– Nhược điểm: Ít third-party integrations (đang phát triển)

Khi nào dùng cái gì:
– Flows: Workflow chủ yếu trong Google Workspace, cần AI capabilities
– Zapier/Make: Cần integrate nhiều external services

8.3 Workspace Flows vs. AppSheet

AppSheet:
– Ưu điểm: Tạo custom apps với UI, databases, advanced logic
– Nhược điểm: Learning curve cao hơn, không tập trung vào automation

Workspace Flows:
– Ưu điểm: Đơn giản hơn nhiều, focus vào automation, AI-powered
– Nhược điểm: Không tạo được custom apps với UI

Khi nào dùng cái gì:
– Flows: Automation workflows, AI-assisted tasks
– AppSheet: Custom business applications với UI

9. Tương lai của Google Workspace Flows

9.1 Roadmap và phát triển

Google đã công bố một số hướng phát triển cho Workspace Flows:

1. Mở rộng third-party integrations
– Marketplace với nhiều connectors hơn
– Tương tự Google Chat marketplace
– Cho phép developers tạo custom integrations

2. Hỗ trợ ngôn ngữ
– Hiện chỉ hỗ trợ tiếng Anh
– Sẽ mở rộng sang nhiều ngôn ngữ khác

3. Mobile support
– Hiện chưa có app mobile
– Đang phát triển experience cho thiết bị di động

4. Agentspace compatibility
– Tương thích với Google Agentspace (dành cho enterprise lớn)
– Agent-to-agent (A2A) protocol
– Khả năng scale cho tổ chức lớn

5. Nâng cấp AI capabilities
– Gemini models mới mạnh hơn
– Nhiều specialized AI steps
– Better context understanding

9.2 Khi nào Workspace Flows có cho tất cả người dùng?

1. Tình trạng hiện tại:
– Alpha release, chỉ cho khách hàng đăng ký Gemini Alpha
– Yêu cầu: Mua license Gemini for Workspace trước 15/1/2025
– Chỉ cho Business và Enterprise editions

2. Timeline dự kiến:
– General Availability: Cuối Q2 hoặc đầu Q3 2025 (chưa chính thức)
– Có thể có thêm beta phases
– Sẽ công bố chi tiết khi gần release

3. Làm gì bây giờ:
– Theo dõi Google Workspace blog và announcements
– Liên hệ administrator để đăng ký Alpha program nếu đủ điều kiện
– Chuẩn bị use cases để sẵn sàng khi GA

9.3 Định giá

Hiện tại:
– Bao gồm trong Gemini for Google Workspace subscription
– Không có phí riêng cho Workspace Flows
– Chi phí nằm trong license Gemini

Tương lai:
– Google chưa công bố chi tiết về pricing cho GA
– Có thể vẫn included trong Gemini subscriptions
– Có thể có usage limits based on plan

V. Kết luận

Google Workspace Flows đại diện cho một bước tiến lớn trong việc dân chủ hóa tự động hóa và AI trong môi trường làm việc. Bằng cách kết hợp sức mạnh của Gemini AI với sự tiện lợi của no-code automation, Workspace Flows mở ra khả năng tự động hóa công việc cho mọi người, không chỉ những người có kỹ năng lập trình.

1. Những điểm nổi bật

Điểm mạnh:
– Dễ sử dụng: No-code, natural language interface
– Mạnh mẽ: AI-powered với Gemini và Gems
– Tích hợp sâu: Seamless với Google Workspace ecosystem
– An toàn: Dữ liệu trong Workspace, tuân thủ policies
– Linh hoạt: Từ simple đến complex workflows

Giới hạn hiện tại:
– Chỉ English
– Alpha stage, chưa GA
– Ít third-party integrations (đang phát triển)
– Chưa có mobile app

2. Ai nên sử dụng Workspace Flows?

Lý tưởng cho:
– Knowledge workers muốn giảm repetitive tasks
– Small to medium businesses sử dụng Google Workspace
– Teams cần automation nhưng không có developers
– Organizations muốn leverage AI trong workflows
– Anyone muốn làm việc thông minh hơn, không chăm chỉ hơn

Có thể chưa phù hợp cho:
– Organizations chưa dùng Google Workspace
– Use cases cần very complex custom logic
– Workflows require extensive third-party integrations (hiện tại)
– Large enterprises cần Agentspace-level capabilities

3. Lời khuyên cuối

Nếu bạn đủ điều kiện tham gia Gemini Alpha program và có quyền truy cập Workspace Flows:

1. Bắt đầu nhỏ: Chọn một tác vụ lặp lại đơn giản và tự động hóa nó
2. Học từ templates: Khám phá và customize templates có sẵn
3. Thử nghiệm: Test nhiều use cases khác nhau
4. Chia sẻ: Chia sẻ flows hữu ích với team
5. Phản hồi: Góp ý với Google để cải thiện product

Workspace Flows vẫn đang trong giai đoạn đầu, nhưng tiềm năng là rất lớn. Khi nó trở nên mature hơn với nhiều features và integrations, nó có thể trở thành công cụ không thể thiếu cho mọi người dùng Google Workspace.

Hãy tưởng tượng một ngày làm việc khi bạn không còn phải:
– Manually sort qua hàng trăm emails
– Copy-paste thông tin giữa các apps
– Nhớ follow-up với mọi người
– Tóm tắt thủ công meetings và documents
– Lo lắng về missing important tasks

Đó là tương lai mà Google Workspace Flows hứa hẹn mang lại – một nơi làm việc thông minh hơn, nơi AI và automation xử lý công việc nhàm chán, để bạn tập trung vào những gì thực sự quan trọng: sáng tạo, collaboration, và tạo ra giá trị.

VI. Tài nguyên tham khảo

Để tìm hiểu thêm về Google Workspace Flows:

– Google Workspace Flows Documentation: https://support.google.com/a/users/answer/16275487
– Get Started Guide: https://support.google.com/a/users/answer/16430812
– Workspace Flows Cheat Sheet: https://support.google.com/a/users/answer/16430708
– Tips for Creating Agents with AI: https://support.google.com/a/users/answer/16430486
– Community Site: https://sites.google.com/view/workspace-flows/about
– Official YouTube Demos: https://www.youtube.com/watch?v=fBmHNeDXYu8
– Gemini Alpha Program Info: https://support.google.com/a/answer/14170809

Chúc bạn thành công trong hành trình tự động hóa công việc với Google Workspace Flows!

So Sánh Các Phương Pháp Xử Lý Excel Cho RAG

🔍 So Sánh Các Phương Pháp Xử Lý Excel Cho RAG

Tìm kiếm “công thức” tối ưu để trích xuất dữ liệu từ file Excel phục vụ hệ thống RAG

Giới thiệu

Trong thực tế, file Excel được sử dụng rộng rãi với nhiều định dạng phức tạp: bảng dữ liệu có màu sắc, biểu đồ, hình ảnh, và các cấu trúc đặc biệt. Khi xây dựng hệ thống RAG (Retrieval-Augmented Generation), câu hỏi đặt ra là: Làm thế nào để “nấu” dữ liệu Excel sao cho LLM hiểu được một cách tốt nhất?

Bài viết này so sánh 5 phương pháp xử lý Excel khác nhau, từ đơn giản đến phức tạp, dựa trên 4 kịch bản thực tế với các câu hỏi cụ thể để đánh giá độ chính xác.

⚠️ Lưu ý: Đây là nghiên cứu về tiền xử lý dữ liệu, không tập trung vào vector search hay prompt engineering. Mục tiêu là tìm cách tốt nhất để chuyển đổi Excel thành định dạng mà LLM có thể hiểu.

🔧 Thiết lập thử nghiệm

Công cụ sử dụng:

  • Ngôn ngữ: TypeScript
  • LLM: Gemini 2.5 Pro
  • Thư viện: XLSX, ExcelJS, JSZip, LibreOffice

4 kịch bản test:

  • Bảng chấm công: Quản lý ngày làm việc/nghỉ phép hàng tháng
  • Biểu đồ Gantt: Quản lý dự án với màu sắc phân chia thời gian
  • Báo cáo doanh số: Bảng số liệu kèm biểu đồ
  • Hướng dẫn sử dụng: Tài liệu có ảnh chụp màn hình

1. Phương pháp CSV (Plain Text)

33%

Chuyển đổi trực tiếp Excel thành text dạng comma-separated values. Đơn giản nhất nhưng mất toàn bộ định dạng.
Cách triển khai: Sử dụng thư viện XLSX với hàm sheet_to_csv()

Ưu điểm

  • Triển khai đơn giản
  • Xử lý nhanh
  • Dung lượng nhỏ

Nhược điểm

  • Mất định dạng cell
  • Không có thông tin màu sắc
  • Không chứa hình ảnh

Kết quả: CSV hoạt động tốt với dữ liệu bảng đơn giản (50% câu đúng ở báo cáo doanh số) nhưng thất bại hoàn toàn với Gantt chart, biểu đồ và hình ảnh do không capture được thông tin visual.

2. Phương pháp JSON (Structured)

50%

Chuyển đổi thành cấu trúc JSON với cặp key-value rõ ràng. Dễ parse và xử lý bằng code.
Cách triển khai: Sử dụng thư viện XLSX với hàm sheet_to_json()

Ưu điểm

  • Cấu trúc rõ ràng
  • Dễ parse và query
  • Tốt cho bảng đơn giản

Nhược điểm

  • Không có styling
  • Không có hình ảnh
  • Mất context trực quan

Kết quả: JSON vượt trội CSV nhờ cấu trúc key-value, đạt 100% với bảng chấm công. Tuy nhiên vẫn không xử lý được màu sắc, biểu đồ và hình ảnh – thất bại hoàn toàn với Gantt chart và hướng dẫn.

3. Phương pháp HTML (Rich Format)

42%

Chuyển thành bảng HTML với đầy đủ style attributes (màu nền, màu chữ, font, alignment). Giữ được nhiều thông tin định dạng.
Cách triển khai: Sử dụng ExcelJS để trích xuất chi tiết style và chuyển thành HTML table với inline CSS

Ưu điểm

  • Giữ được màu sắc
  • Bảo toàn formatting
  • Có font styles

Nhược điểm

  • Implementation phức tạp
  • Không có hình ảnh
  • File size lớn hơn

Kết quả: HTML capture được màu sắc nên có thể xử lý Gantt chart (33% thành công), nhưng độ chính xác không ổn định (ngày thường lệch 1). Vẫn không có biểu đồ và hình ảnh. Code implementation phức tạp nhưng có tiềm năng cải thiện.

4. Phương pháp PDF Image (Visual)

67%

Chuyển Excel thành PDF và encode dưới dạng image gửi cho LLM. Giữ nguyên 100% giao diện trực quan.
Cách triển khai: Sử dụng LibreOffice CLI để convert Excel → ODS → áp dụng page template → PDF, sau đó encode base64

Ưu điểm

  • Độ trung thực visual 100%
  • Có biểu đồ
  • Có hình ảnh gốc

Nhược điểm

  • Khó trích xuất bảng chi tiết
  • File size lớn
  • Cần OCR cho text

Kết quả: PDF xuất sắc với visual content – 100% chính xác với hướng dẫn có screenshot và báo cáo có biểu đồ. Tuy nhiên yếu với bảng dữ liệu chi tiết (0% với bảng chấm công) do LLM khó phân tích row/column từ image.

5. Phương pháp Hybrid (HTML + PDF) ⭐

100%

Kết hợp cả HTML và PDF Image – gửi đồng thời cả hai cho LLM. HTML cung cấp cấu trúc bảng và màu sắc, PDF cung cấp thông tin visual (biểu đồ, hình ảnh).
Cách triển khai: Không cần code mới – chỉ cần gửi kết quả của cả method 3 (HTML) và method 4 (PDF) cùng lúc cho LLM

Ưu điểm

  • Tốt nhất trong mọi tình huống
  • Xử lý được mọi loại Excel
  • Độ chính xác cao nhất
  • Bù trừ nhược điểm lẫn nhau

Nhược điểm

  • Phức tạp nhất
  • Payload lớn nhất
  • Chi phí LLM cao hơn

Kết quả: Hybrid đạt 100% (24/24 câu đúng) bằng cách tận dụng điểm mạnh của cả hai: HTML cho cấu trúc bảng + màu sắc, PDF cho biểu đồ + hình ảnh. LLM có thể cross-reference giữa hai nguồn để đưa ra câu trả lời chính xác nhất.

📊 Bảng so sánh tổng hợp

Kịch bản / Câu hỏi CSV JSON HTML PDF Hybrid
Bảng chấm công: Ai nghỉ ngày 15/10?
Bảng chấm công: Mike nghỉ khi nào?
Gantt: Thiết kế – ai & khi nào?
Gantt: Testing khi nào?
Doanh số: Vùng nào cao nhất Q3?
Doanh số: Chart xanh-đỏ cách xa nhất?
Hướng dẫn: Nút Save ở đâu?
Hướng dẫn: Bước 3 có mấy nút?
TỔNG ĐIỂM 33% 50% 42% 67% 100%

🔍 Phân tích chi tiết

CSV & JSON – Giới hạn rõ ràng

Triển khai đơn giản nhưng hoàn toàn không xử lý được màu sắc, hình ảnh, biểu đồ. JSON tốt hơn CSV một chút nhờ cấu trúc key-value rõ ràng, giúp các câu hỏi về bảng chấm công (row-based queries) chính xác hơn. Tuy nhiên, với Gantt chart và hướng dẫn có hình ảnh thì cả hai đều bất lực.

HTML (ExcelJS) – Một nửa thành công

Phương pháp này có thể trích xuất được màu nền, font style, text alignment… nên với Gantt chart có thể nhận diện màu sắc. Tuy nhiên độ chính xác không ổn định (ngày thường lệch 1), code implementation phức tạp. Nếu đầu tư thêm về xử lý date format và cell merging có thể cải thiện. Vẫn không xử lý được biểu đồ và hình ảnh.

PDF Image – Mạnh về visual

Điểm sáng lớn nhất là giữ nguyên 100% giao diện Excel: màu sắc, biểu đồ, hình ảnh, layout. Vì vậy xuất sắc với hướng dẫn có screenshot và báo cáo có chart. Tuy nhiên với bảng dữ liệu chi tiết (bảng chấm công) thì lại yếu – LLM khó phân tích quan hệ row/column từ image. Có thể trong tương lai khi LLM tốt hơn trong việc đọc image thì vấn đề này sẽ được cải thiện.

Hybrid (HTML + PDF) – Người chiến thắng 🏆

Bằng cách gửi cả HTML và PDF cho LLM, phương pháp này tận dụng được điểm mạnh của cả hai:

  • HTML cung cấp cấu trúc bảng rõ ràng + thông tin màu sắc
  • PDF cung cấp biểu đồ + hình ảnh + context trực quan
  • LLM có thể cross-reference giữa hai nguồn để đưa ra câu trả lời chính xác nhất

Trong test này đạt 100% (24/24 câu đúng), xử lý tốt mọi loại Excel. Nhược điểm duy nhất là implementation phức tạp và chi phí API cao hơn do payload lớn.

💡 Kết luận & Khuyến nghị

🎯 Khi nào dùng phương pháp nào?

  • CSV/JSON: Prototype nhanh, bảng dữ liệu đơn giản không có định dạng
  • HTML: Bảng có màu sắc, định dạng quan trọng, không có biểu đồ/hình ảnh
  • PDF: Dashboard, báo cáo có chart, tài liệu có screenshot
  • Hybrid: Hệ thống production cần độ chính xác cao, xử lý Excel phức tạp
⚖️ Trade-offs quan trọng

Độ chính xác vs Chi phí implementation vs Chi phí runtime. Hybrid có độ chính xác cao nhất nhưng cũng tốn kém nhất. Với use case cụ thể cần cân nhắc kỹ.

🚀 Bước tiếp theo cho RAG

  • Xác định chiến lược chunking (table-level vs row-level)
  • Tối ưu hóa embedding generation cho mixed content
  • Implement vector search hiệu quả
  • Thiết kế prompt engineering cho từng loại Excel
  • Xây dựng fallback strategies cho edge cases
✨ Khuyến nghị chung:
Bắt đầu với JSON cho prototype, chuyển sang HTML khi cần colors, và nâng cấp lên Hybrid cho production nếu budget cho phép. PDF đơn lẻ phù hợp cho dashboard/manual. Luôn test với dữ liệu thực tế của bạn vì mỗi tổ chức có cách dùng Excel khác nhau!

📝 Bài viết này dựa trên thử nghiệm thực tế với LLM Gemini 2.5 Pro

💬 Bạn đang dùng phương pháp nào cho RAG với Excel? Chia sẻ kinh nghiệm nhé!

Grounding Gemini with Your Data: A Deep Dive into the File Search Tool and Managed RAG

Grounding Gemini with Your Data: File Search Tool

The true potential of Large Language Models (LLMs) is unlocked when they can interact with specific, private, and up-to-date data outside their initial training corpus. This is the core principle of Retrieval-Augmented Generation (RAG). The Gemini File Search Tool is Google’s dedicated solution for enabling RAG, providing a fully managed, scalable, and reliable system to ground the Gemini model in your own proprietary documents.

This guide serves as a complete walkthrough (AI Quest Type 2): we’ll explore the tool’s advanced features, demonstrate its behavior via the official demo, and provide a detailed, working Python code sample to show you exactly how to integrate RAG into your applications.


1. Core Features and Technical Advantage

1.1. Why Use a Managed RAG Solution?

Building a custom RAG pipeline involves several complex, maintenance-heavy steps: chunking algorithms, selecting and running an embedding model, maintaining a vector store (like Vector Database or Vector Store), and integrating the search results back into the prompt.

The Gemini File Search Tool eliminates this complexity by providing a fully managed RAG pipeline:

  • Automatic Indexing: When you upload a file, the system automatically handles document parsing, chunking, and generating vector embeddings using a state-of-the-art model.
  • Scalable Storage: Files are stored and indexed in a dedicated File Search Store—a persistent, highly available vector repository managed entirely by Google.
  • Zero-Shot Tool Use: You don’t write any search code. You simply enable the tool, and the Gemini model automatically decides when to call the File Search service to retrieve context, ensuring optimal performance.

1.2. Key Features

  • Semantic Search: Unlike simple keyword matching, File Search uses the generated vector embeddings to understand the meaning and intent (semantics) of your query, fetching the most relevant passages, even if the phrasing is different.
  • Built-in Citations: Crucially, every generated answer includes clear **citations (Grounding Metadata)** that point directly to the source file and the specific text snippet used. This ensures **transparency and trust**.
  • Broad File Support: Supports common formats including PDF, DOCX, TXT, JSON, and more.

2. Checking Behavior via the Official Demo App: A Visual RAG Walkthrough 🔎

This section fulfills the requirement to check the behavior by demo app using a structured test scenario. The goal is to visibly demonstrate how the Gemini model uses the File Search Tool to become grounded in your private data, confirming that RAG is active and reliable.

2.1. Test Scenario Preparation

To prove that the model prioritizes the uploaded file over its general knowledge, we’ll use a file containing specific, non-public details.

Access: Go to the “Ask the Manual” template on Google AI Studio: https://aistudio.google.com/apps/bundled/ask_the_manual?showPreview=true&showAssistant=true.

Test File (Pricing_Override.txt):

Pricing_Override.txt content:

The official retail price for Product X is set at $10,000 USD.
All customer service inquiries must be directed to Ms. Jane Doe at extension 301.
We currently offer an unlimited lifetime warranty on all purchases.

2.2. Step-by-Step Execution and Observation

Step 1: Upload the Source File

Navigate to the demo and upload the Pricing_Override.txt file. The File Search system indexes the content, and the file should be listed as “Ready” or “Loaded” in the interface, confirming the source is available for retrieval.

Image of the Gemini AI Studio interface showing the Pricing_Override.txt file successfully uploaded and ready for use in the File Search Tool

Step 2: Pose the Retrieval Query

Ask a question directly answerable only by the file: “What is the retail price of Product X and who handles customer service?” The model internally triggers the File Search Tool to retrieve the specific price and contact person from the file’s content.

Image of the Gemini AI Studio interface showing the user query 'What is the retail price of Product X and who handles customer service?' entered into the chat box

Step 3: Observe Grounded Response & Citation

Observe the model’s response. The Expected RAG Behavior is crucial: the response must state the file-specific price ($10,000 USD) and contact (Ms. Jane Doe), followed immediately by a citation mark (e.g., [1] The uploaded file). This confirms the answer is grounded.

Image of the Gemini AI Studio interface showing the model's response with price and contact, and a citation [1] linked to the uploaded file

Step 4: Verify Policy Retrieval

Ask a supplementary policy question: “What is the current warranty offering?” The model successfully retrieves and restates the specific policy phrase from the file, demonstrating continuous access to the knowledge base.

Image of the Gemini AI Studio interface showing the user query 'What is the current warranty offering?' and the grounded model response with citation

Conclusion from Demo

This visual walkthrough confirms that the **File Search Tool is correctly functioning as a verifiable RAG mechanism**. The model successfully retrieves and grounds its answers in the custom data, ensuring accuracy and trust by providing clear source citations.


3. Getting Started: The Development Workflow

3.1. Prerequisites

  • Gemini API Key: Set your key as an environment variable: GEMINI_API_KEY.
  • Python SDK: Install the official Google GenAI library:
pip install google-genai

3.2. Three Core API Steps

The integration workflow uses three distinct API calls:

Step Method Purpose
1. Create Store client.file_search_stores.create() Creates a persistent container (the knowledge base) where your file embeddings will be stored.
2. Upload File client.file_search_stores.upload_to_file_search_store() Uploads the raw file, triggers the LRO (Long-Running Operation) for indexing (chunking, embedding), and attaches the file to the Store.
3. Generate Content client.models.generate_content() Calls the Gemini model (gemini-2.5-flash), passing the Store name in the tools configuration to activate RAG.

4. Detailed Sample Code and Execution (Make sample code and check how it works)

This Python code demonstrates the complete life cycle of a RAG application, from creating the store to querying the model and cleaning up resources.

A. Sample File Content: service_guide.txt

The new account registration process includes the following steps: 1) Visit the website. 2) Enter email and password. 3) Confirm via the email link sent to your inbox. 4) Complete the mandatory personal information. The monthly cost for the basic service tier is $10 USD. The refund policy is valid for 30 days from the date of purchase. For support inquiries, please email [email protected].

B. Python Code (gemini_file_search_demo.py)

(The code block is presented as a full script for easy reference and testing.)

import os
import time
from google import genai
from google.genai import types
from google.genai.errors import APIError

# --- Configuration ---
FILE_NAME = "service_guide.txt"
STORE_DISPLAY_NAME = "Service Policy Knowledge Base"
MODEL_NAME = "gemini-2.5-flash"

def run_file_search_demo():
    # Helper to create the local file for upload
    if not os.path.exists(FILE_NAME):
        file_content = """The new account registration process includes the following steps: 1) Visit the website. 2) Enter email and password. 3) Confirm via the email link sent to your inbox. 4) Complete the mandatory personal information. The monthly cost for the basic service tier is $10 USD. The refund policy is valid for 30 days from the date of purchase. For support inquiries, please email [email protected]."""
        with open(FILE_NAME, "w") as f:
            f.write(file_content)
    
    file_search_store = None # Initialize for cleanup in finally block
    try:
        print("💡 Initializing Gemini Client...")
        client = genai.Client()

        # 1. Create the File Search Store
        print(f"\n🚀 1. Creating File Search Store: '{STORE_DISPLAY_NAME}'...")
        file_search_store = client.file_search_stores.create(
            config={'display_name': STORE_DISPLAY_NAME}
        )
        print(f"   -> Store Created: {file_search_store.name}")
        
        # 2. Upload and Import File into the Store (LRO)
        print(f"\n📤 2. Uploading and indexing file '{FILE_NAME}'...")
        
        operation = client.file_search_stores.upload_to_file_search_store(
            file=FILE_NAME,
            file_search_store_name=file_search_store.name,
            config={'display_name': f"Document {FILE_NAME}"}
        )

        while not operation.done:
            print("   -> Processing file... Please wait (5 seconds)...")
            time.sleep(5)
            operation = client.operations.get(operation)

        print("   -> File successfully processed and indexed!")

        # 3. Perform the RAG Query
        print(f"\n💬 3. Querying model '{MODEL_NAME}' with your custom data...")
        
        questions = [
            "What is the monthly fee for the basic tier?",
            "How do I sign up for a new account?",
            "What is the refund policy?"
        ]

        for i, question in enumerate(questions):
            print(f"\n   --- Question {i+1}: {question} ---")
            
            response = client.models.generate_content(
                model=MODEL_NAME,
                contents=question,
                config=types.GenerateContentConfig(
                    tools=[
                        types.Tool(
                            file_search=types.FileSearch(
                                file_search_store_names=[file_search_store.name]
                            )
                        )
                    ]
                )
            )

            # 4. Print results and citations
            print(f"   🤖 Answer: {response.text}")
            
            if response.candidates and response.candidates[0].grounding_metadata:
                print("   📚 Source Citation:")
                # Process citations, focusing on the text segment for clarity
                for citation_chunk in response.candidates[0].grounding_metadata.grounding_chunks:
                    print(f"    - From: '{FILE_NAME}' (Snippet: '{citation_chunk.text_segment.text}')")
            else:
                print("   (No specific citation found.)")


    except APIError as e:
        print(f"\n❌ [API ERROR] Đã xảy ra lỗi khi gọi API: {e}")
    except Exception as e:
        print(f"\n❌ [LỖI CHUNG] Đã xảy ra lỗi không mong muốn: {e}")
    finally:
        # 5. Clean up resources (Essential for managing quota)
        if file_search_store:
            print(f"\n🗑️ 4. Cleaning up: Deleting File Search Store {file_search_store.name}...")
            client.file_search_stores.delete(name=file_search_store.name)
            print("   -> Store successfully deleted.")
            
        if os.path.exists(FILE_NAME):
            os.remove(FILE_NAME)
            print(f"   -> Deleted local sample file '{FILE_NAME}'.")

if __name__ == "__main__":
    run_file_search_demo()

C. Demo Execution and Expected Output 🖥️

When running the Python script, the output demonstrates the successful RAG process, where the model’s responses are strictly derived from the service_guide.txt file, confirmed by the citations.

💡 Initializing Gemini Client...
...
   -> File successfully processed and indexed!

💬 3. Querying model 'gemini-2.5-flash' with your custom data...

   --- Question 1: What is the monthly fee for the basic tier? ---
   🤖 Answer: The monthly cost for the basic service tier is $10 USD.
   📚 Source Citation:
    - From: 'service_guide.txt' (Snippet: 'The monthly cost for the basic service tier is $10 USD.')

   --- Question 2: How do I sign up for a new account? ---
   🤖 Answer: To sign up, you need to visit the website, enter email and password, confirm via the email link, and complete the mandatory personal information.
   📚 Source Citation:
    - From: 'service_guide.txt' (Snippet: 'The new account registration process includes the following steps: 1) Visit the website. 2) Enter email and password. 3) Confirm via the email link sent to your inbox. 4) Complete the mandatory personal information.')

   --- Question 3: What is the refund policy? ---
   🤖 Answer: The refund policy is valid for 30 days from the date of purchase.
   📚 Source Citation:
    - From: 'service_guide.txt' (Snippet: 'The refund policy is valid for 30 days from the date of purchase.')

🗑️ 4. Cleaning up: Deleting File Search Store fileSearchStores/...
   -> Store successfully deleted.
   -> Deleted local sample file 'service_guide.txt'.

Conclusion

The **Gemini File Search Tool** provides an elegant, powerful, and fully managed path to RAG. By abstracting away the complexities of vector databases and indexing, it allows developers to quickly build **highly accurate, reliable, and grounded AI applications** using their own data. This tool is essential for anyone looking to bridge the gap between general AI capabilities and specific enterprise knowledge.

Xây Dựng AI Agent Hiệu Quả với MCP

Giới Thiệu

Trong thời đại AI đang phát triển mạnh mẽ, việc xây dựng các AI agent thông minh và hiệu quả đã trở thành mục tiêu của nhiều nhà phát triển. Model Context Protocol (MCP) – một giao thức mở được Anthropic phát triển – đang mở ra những khả năng mới trong việc tối ưu hóa cách các AI agent tương tác với dữ liệu và công cụ. Bài viết này sẽ phân tích cách tiếp cận “Code Execution with MCP” và đưa ra những góc nhìn thực tế về việc áp dụng nó vào các dự án thực tế.

MCP Là Gì và Tại Sao Nó Quan Trọng?

Model Context Protocol (MCP) có thể được ví như “USB-C của thế giới AI” – một tiêu chuẩn mở giúp chuẩn hóa cách các ứng dụng cung cấp ngữ cảnh cho các mô hình ngôn ngữ lớn (LLM). Thay vì mỗi hệ thống phải tự xây dựng cách kết nối riêng, MCP cung cấp một giao thức thống nhất, giúp giảm thiểu sự phân mảnh và tăng tính tương thích.

Quan điểm cá nhân: Tôi cho rằng MCP không chỉ là một công nghệ, mà còn là một bước tiến quan trọng trong việc chuẩn hóa hệ sinh thái AI. Giống như cách HTTP đã cách mạng hóa web, MCP có tiềm năng trở thành nền tảng cho việc kết nối các AI agent với thế giới bên ngoài.

Code Execution với MCP: Bước Đột Phá Thực Sự

Vấn Đề Truyền Thống

Trước đây, khi xây dựng AI agent, chúng ta thường phải:

  • Tải tất cả định nghĩa công cụ vào context window ngay từ đầu
  • Gửi toàn bộ dữ liệu thô đến mô hình, dù chỉ cần một phần nhỏ
  • Thực hiện nhiều lần gọi công cụ tuần tự, gây ra độ trễ cao
  • Đối mặt với rủi ro bảo mật khi dữ liệu nhạy cảm phải đi qua mô hình

Giải Pháp: Code Execution với MCP

Code execution với MCP cho phép AI agent viết và thực thi mã để tương tác với các công cụ MCP. Điều này mang lại 5 lợi ích chính:

1. Tiết Lộ Dần Dần (Progressive Disclosure)

Cách hoạt động: Thay vì tải tất cả định nghĩa công cụ vào context, agent có thể đọc các file công cụ từ hệ thống file khi cần thiết.

Ví dụ thực tế: Giống như việc bạn không cần đọc toàn bộ thư viện sách để tìm một thông tin cụ thể. Agent chỉ cần “mở” file công cụ khi thực sự cần sử dụng.

Lợi ích:

  • Giảm đáng kể token consumption
  • Tăng tốc độ phản hồi ban đầu
  • Cho phép agent làm việc với số lượng công cụ lớn hơn

2. Kết Quả Công Cụ Hiệu Quả Về Ngữ Cảnh

Vấn đề: Khi làm việc với dataset lớn (ví dụ: 10,000 records), việc gửi toàn bộ dữ liệu đến mô hình là không hiệu quả.

Giải pháp: Agent có thể viết mã để lọc, chuyển đổi và xử lý dữ liệu trước khi trả về kết quả cuối cùng.

Ví dụ:

# Thay vì trả về 10,000 records
# Agent có thể viết:
results = filter_data(dataset, criteria)
summary = aggregate(results)
return summary  # Chỉ trả về kết quả đã xử lý

Quan điểm: Đây là một trong những điểm mạnh nhất của phương pháp này. Nó cho phép agent “suy nghĩ” trước khi trả lời, giống như cách con người xử lý thông tin.

3. Luồng Điều Khiển Mạnh Mẽ

Cách truyền thống: Agent phải thực hiện nhiều lần gọi công cụ tuần tự:

Gọi công cụ 1 → Chờ kết quả → Gọi công cụ 2 → Chờ kết quả → ...

Với code execution: Agent có thể viết một đoạn mã với vòng lặp, điều kiện và xử lý lỗi:

for item in items:
    result = process(item)
    if result.is_valid():
        save(result)
    else:
        log_error(item)

Lợi ích:

  • Giảm độ trễ (latency) đáng kể
  • Xử lý lỗi tốt hơn
  • Logic phức tạp được thực thi trong một bước

4. Bảo Vệ Quyền Riêng Tư

Đặc điểm quan trọng: Các kết quả trung gian mặc định được giữ trong môi trường thực thi, không tự động gửi đến mô hình.

Ví dụ: Khi agent xử lý dữ liệu nhạy cảm (thông tin cá nhân, mật khẩu), các biến trung gian chỉ tồn tại trong môi trường thực thi. Chỉ khi agent chủ động log hoặc return, dữ liệu mới được gửi đến mô hình.

Quan điểm: Đây là một tính năng bảo mật quan trọng, đặc biệt trong các ứng dụng enterprise. Tuy nhiên, cần có cơ chế giám sát để đảm bảo agent không vô tình leak dữ liệu.

5. Duy Trì Trạng Thái và Kỹ Năng

Khả năng mới: Agent có thể:

  • Lưu trạng thái vào file để tiếp tục công việc sau
  • Xây dựng các function có thể tái sử dụng như “kỹ năng”
  • Học và cải thiện theo thời gian

Ví dụ thực tế: Agent có thể tạo file utils.py với các function xử lý dữ liệu, và sử dụng lại trong các task tương lai.

Cách Xây Dựng AI Agent Hiệu Quả với MCP

Bước 1: Thiết Kế Kiến Trúc

Nguyên tắc:

  • Tách biệt rõ ràng giữa logic xử lý và tương tác với MCP
  • Thiết kế các công cụ MCP theo module, dễ mở rộng
  • Xây dựng hệ thống quản lý trạng thái rõ ràng

Ví dụ kiến trúc:

Agent Core
├── MCP Client (kết nối với MCP servers)
├── Code Executor (sandbox environment)
├── State Manager (lưu trữ trạng thái)
└── Tool Registry (quản lý công cụ)

Bước 2: Tối Ưu Hóa Progressive Disclosure

Chiến lược:

  • Tổ chức công cụ theo namespace và category
  • Sử dụng file system để quản lý định nghĩa công cụ
  • Implement lazy loading cho các công cụ ít dùng

Code pattern:

# tools/database/query.py
def query_database(sql):
    # Implementation
    pass

# Agent chỉ load khi cần
if need_database:
    import tools.database.query

Bước 3: Xây Dựng Data Processing Pipeline

Best practices:

  • Luôn filter và transform dữ liệu trước khi trả về
  • Sử dụng streaming cho dataset lớn
  • Implement caching cho các query thường dùng

Ví dụ:

def process_large_dataset(data_source):
    # Chỉ load và xử lý phần cần thiết
    filtered = stream_filter(data_source, filter_func)
    aggregated = aggregate_in_chunks(filtered)
    return summary_statistics(aggregated)

Bước 4: Implement Security Measures

Các biện pháp cần thiết:

  • Sandboxing: Chạy code trong môi trường cách ly
  • Resource limits: Giới hạn CPU, memory, thời gian thực thi
  • Audit logging: Ghi lại tất cả code được thực thi
  • Input validation: Kiểm tra input trước khi thực thi

Quan điểm: Security không phải là feature, mà là requirement. Đừng để đến khi có sự cố mới nghĩ đến bảo mật.

Bước 5: State Management và Skill Building

Chiến lược:

  • Sử dụng file system hoặc database để lưu trạng thái
  • Tạo thư viện các utility functions có thể tái sử dụng
  • Implement versioning cho các “skills”

Ví dụ:

# skills/data_analysis.py
def analyze_trends(data):
    # Reusable skill
    pass

# Agent có thể import và sử dụng
from skills.data_analysis import analyze_trends

Áp Dụng Vào Dự Án Thực Tế

Use Case 1: Data Analysis Agent

Tình huống: Xây dựng agent phân tích dữ liệu từ nhiều nguồn khác nhau.

Áp dụng MCP:

  • MCP servers cho mỗi data source (database, API, file system)
  • Code execution để filter và aggregate dữ liệu
  • Progressive disclosure cho các công cụ phân tích

Lợi ích:

  • Giảm 60-70% token usage
  • Tăng tốc độ xử lý 3-5 lần
  • Dễ dàng thêm data source mới

Use Case 2: Automation Agent

Tình huống: Agent tự động hóa các tác vụ lặp đi lặp lại.

Áp dụng MCP:

  • MCP servers cho các hệ thống cần tương tác
  • Code execution để xử lý logic phức tạp
  • State management để resume công việc

Lợi ích:

  • Xử lý lỗi tốt hơn với try-catch trong code
  • Có thể pause và resume công việc
  • Dễ dàng debug và monitor

Use Case 3: Customer Support Agent

Tình huống: Agent hỗ trợ khách hàng với quyền truy cập vào nhiều hệ thống.

Áp dụng MCP:

  • MCP servers cho CRM, knowledge base, ticketing system
  • Code execution để query và tổng hợp thông tin
  • Privacy protection cho dữ liệu khách hàng

Lợi ích:

  • Bảo vệ thông tin nhạy cảm tốt hơn
  • Phản hồi nhanh hơn với data processing tại chỗ
  • Dễ dàng tích hợp hệ thống mới

Những Thách Thức và Giải Pháp

Thách Thức 1: Code Quality và Safety

Vấn đề: Agent có thể viết code không an toàn hoặc không hiệu quả.

Giải pháp:

  • Implement code review tự động
  • Sử dụng linter và formatter
  • Giới hạn các API và function có thể sử dụng

Thách Thức 2: Debugging

Vấn đề: Debug code được agent tự động generate khó hơn code thủ công.

Giải pháp:

  • Comprehensive logging
  • Code explanation từ agent
  • Step-by-step execution với breakpoints

Thách Thức 3: Performance

Vấn đề: Code execution có thể chậm nếu không tối ưu.

Giải pháp:

  • Caching kết quả
  • Parallel execution khi có thể
  • Optimize code generation từ agent

Roadmap Áp Dụng MCP Vào Dự Án Của Bạn

Dựa trên những nguyên tắc và best practices đã trình bày, đây là roadmap cụ thể để bạn có thể áp dụng MCP vào dự án của mình một cách hiệu quả:

Giai Đoạn 1: Chuẩn Bị và Đánh Giá (Tuần 1-2)

Mục tiêu: Hiểu rõ nhu cầu và chuẩn bị môi trường

  • Đánh giá use case: Xác định vấn đề cụ thể mà agent sẽ giải quyết
  • Phân tích hệ thống hiện tại: Liệt kê các hệ thống, API, database cần tích hợp
  • Thiết lập môi trường dev: Cài đặt MCP SDK, tạo sandbox environment
  • Xác định metrics: Định nghĩa KPIs để đo lường hiệu quả (token usage, latency, accuracy)
  • Security audit: Đánh giá các yêu cầu bảo mật và compliance

Giai Đoạn 2: Proof of Concept (Tuần 3-4)

Mục tiêu: Xây dựng prototype đơn giản để validate concept

  • Tạo MCP server đầu tiên: Bắt đầu với một data source đơn giản nhất
  • Implement basic agent: Agent có thể gọi MCP tool và xử lý response
  • Test code execution: Cho agent viết và thực thi code đơn giản
  • Đo lường baseline: Ghi lại metrics ban đầu để so sánh
  • Gather feedback: Thu thập phản hồi từ team và stakeholders

Giai Đoạn 3: Mở Rộng và Tối Ưu (Tuần 5-8)

Mục tiêu: Mở rộng chức năng và tối ưu hóa hiệu suất

  • Thêm MCP servers: Tích hợp các data source và hệ thống còn lại
  • Implement progressive disclosure: Tổ chức tools theo namespace, lazy loading
  • Xây dựng data pipeline: Filter, transform, aggregate data trước khi trả về
  • Security hardening: Implement sandboxing, resource limits, audit logging
  • State management: Lưu trạng thái, xây dựng reusable skills
  • Performance optimization: Caching, parallel execution, code optimization

Giai Đoạn 4: Production và Monitoring (Tuần 9-12)

Mục tiêu: Đưa vào production và đảm bảo ổn định

  • Testing toàn diện: Unit tests, integration tests, security tests
  • Documentation: Viết docs cho MCP servers, API, và agent behavior
  • Monitoring setup: Logging, metrics, alerting system
  • Gradual rollout: Deploy từng phần, A/B testing nếu cần
  • Training và support: Đào tạo team, setup support process
  • Continuous improvement: Thu thập feedback, iterate và optimize

Checklist Implementation

Technical Setup

  • MCP SDK installed
  • Sandbox environment configured
  • MCP servers implemented
  • Code executor setup
  • State storage configured

Security

  • Sandboxing enabled
  • Resource limits set
  • Input validation implemented
  • Audit logging active
  • Access control configured

Performance

  • Progressive disclosure implemented
  • Data filtering in place
  • Caching strategy defined
  • Metrics dashboard ready
  • Optimization plan created

Key Takeaways để Áp Dụng Hiệu Quả

  1. Bắt đầu từ use case đơn giản nhất: Đừng cố gắng giải quyết tất cả vấn đề cùng lúc. Bắt đầu nhỏ, học hỏi, rồi mở rộng.
  2. Ưu tiên security từ đầu: Đừng để security là suy nghĩ sau. Thiết kế security vào kiến trúc ngay từ đầu.
  3. Đo lường mọi thứ: Nếu không đo lường được, bạn không thể cải thiện. Setup metrics và monitoring sớm.
  4. Tận dụng code execution: Đây là điểm mạnh của MCP. Cho phép agent xử lý logic phức tạp trong code thay vì nhiều tool calls.
  5. Xây dựng reusable skills: Đầu tư vào việc tạo các function có thể tái sử dụng. Chúng sẽ tiết kiệm thời gian về sau.
  6. Iterate và improve: Không có giải pháp hoàn hảo ngay từ đầu. Thu thập feedback, đo lường, và cải thiện liên tục.

Ví Dụ Thực Tế: E-commerce Data Analysis Agent

Tình huống: Bạn cần xây dựng agent phân tích dữ liệu bán hàng từ nhiều nguồn (database, API, CSV files).

Áp dụng roadmap:

  • Tuần 1-2: Đánh giá data sources, thiết lập môi trường, xác định metrics (query time, token usage)
  • Tuần 3-4: Tạo MCP server cho database, agent có thể query và trả về kết quả đơn giản
  • Tuần 5-8: Thêm MCP servers cho API và file system, implement data filtering, aggregation trong code
  • Tuần 9-12: Production deployment, monitoring, optimize query performance, build reusable analysis functions

Kết quả: Agent có thể phân tích dữ liệu từ nhiều nguồn, giảm 65% token usage, tăng tốc độ xử lý 4 lần so với cách truyền thống.

Kết Luận và Hướng Phát Triển

Code execution với MCP đại diện cho một bước tiến quan trọng trong việc xây dựng AI agent. Nó không chỉ giải quyết các vấn đề về hiệu quả và bảo mật, mà còn mở ra khả năng cho agent “học” và phát triển kỹ năng theo thời gian.

Quan điểm cuối cùng:

Tôi tin rằng đây mới chỉ là khởi đầu. Trong tương lai, chúng ta sẽ thấy:

  • Các agent có thể tự động tối ưu hóa code của chính chúng
  • Hệ sinh thái các MCP servers phong phú hơn
  • Các framework và tooling hỗ trợ tốt hơn cho việc phát triển

Lời khuyên cho các nhà phát triển:

  1. Bắt đầu nhỏ: Bắt đầu với một use case đơn giản để hiểu rõ cách MCP hoạt động
  2. Tập trung vào security: Đừng đánh đổi bảo mật để lấy hiệu quả
  3. Đo lường và tối ưu: Luôn đo lường performance và tối ưu dựa trên dữ liệu thực tế
  4. Cộng đồng: Tham gia vào cộng đồng MCP để học hỏi và chia sẻ kinh nghiệm

Việc áp dụng MCP vào dự án của bạn không chỉ là việc tích hợp một công nghệ mới, mà còn là việc thay đổi cách suy nghĩ về việc xây dựng AI agent. Hãy bắt đầu ngay hôm nay và khám phá những khả năng mới!

Tags:AIMCPAI AgentCode ExecutionMachine Learning

Cursor 2.0: Revolutionizing Code Development

🚀 Cursor 2.0: Revolutionizing Code Development

Discover the New Features and Benefits for Modern Programmers

🎯 What’s New in Cursor 2.0?

⚡ Composer Model

4x Faster Performance: A frontier coding model that operates four times faster than similarly intelligent models, completing most tasks in under 30 seconds. Designed for low-latency agentic coding and particularly effective in large codebases.

🤖 Multi-Agent Interface

Run Up to 8 Agents Concurrently: A redesigned interface that allows you to manage and run up to eight agents simultaneously. Each agent operates in isolated copies of your codebase to prevent file conflicts and enable parallel development workflows.

🌐 Embedded Browser

Now Generally Available: The in-editor browser includes tools for selecting elements and forwarding DOM information to agents. This facilitates more effective web development, testing, and iteration without leaving your editor.

🔒 Sandboxed Terminals

Enhanced Security (macOS): Agent commands now run in a secure sandbox by default, restricting commands to read/write access within your workspace without internet access. This enhances security while maintaining functionality.

🎤 Voice Mode

Hands-Free Operation: Control agents using voice commands with built-in speech-to-text conversion. Supports custom submit keywords, allowing for hands-free coding and improved accessibility.

📝 Improved Code Review

Enhanced Multi-File Management: Better features for viewing and managing changes across multiple files without switching between them. Streamlines the code review process and improves collaboration.

👥 Team Commands

Centralized Management: Define and manage custom commands and rules centrally through the Cursor dashboard. Ensures consistency across your team and standardizes development workflows.

🚀 Performance Enhancements

Faster LSP Performance: Improved loading and usage of Language Server Protocols (LSPs) for all languages. Results in faster performance, reduced memory usage, and smoother operation, especially noticeable in large projects.

💡 Key Benefits for Programmers

🚀 Increased Productivity

Cursor 2.0’s enhanced AI capabilities significantly reduce the time spent on boilerplate code, debugging, and searching for solutions. Programmers can focus more on solving complex problems rather than routine coding tasks.

  • ✓ 4x Faster Code Generation: The Composer model completes most coding tasks in under 30 seconds, dramatically reducing development time and enabling rapid iteration cycles.
  • ✓ Parallel Development Workflows: Multi-agent interface allows running up to 8 agents simultaneously, enabling teams to work on multiple features or bug fixes concurrently without conflicts.
  • ✓ Streamlined Web Development: Embedded browser with DOM element selection eliminates the need to switch between browser and editor, making web testing and debugging more efficient.
  • ✓ Enhanced Security: Sandboxed terminals on macOS provide secure execution environment, protecting sensitive projects while maintaining full functionality for agent commands.
  • ✓ Improved Accessibility: Voice mode enables hands-free coding, making development more accessible and allowing for multitasking while coding.
  • ✓ Better Code Review Process: Enhanced multi-file change management allows reviewing and managing changes across multiple files without constant context switching, improving review efficiency.
  • ✓ Team Consistency: Team Commands feature ensures all team members follow standardized workflows and best practices, reducing onboarding time and maintaining code quality.
  • ✓ Optimized Performance for Large Projects: Improved LSP performance means faster loading times, reduced memory usage, and smoother operation even with complex, large-scale codebases.
  • ✓ Reduced Development Time: Combined features result in significantly faster development cycles, allowing teams to deliver features and fixes much quicker than before.
  • ✓ Better Resource Utilization: Parallel agent execution and optimized performance mean teams can accomplish more with the same resources, improving overall productivity.

🎨 New Features Deep Dive

1. Composer Model – Speed Revolution

The Composer model represents a significant leap in AI coding performance. Key characteristics:

  • ✓ 4x Faster: Operates four times faster than similarly intelligent models
  • ✓ Under 30 Seconds: Completes most coding tasks in less than 30 seconds
  • ✓ Low-Latency: Designed specifically for agentic coding workflows
  • ✓ Large Codebase Optimized: Particularly effective when working with large, complex projects

2. Multi-Agent Interface – Parallel Processing

The multi-agent interface revolutionizes how teams can work with AI assistants:

  • ✓ Run up to 8 agents simultaneously without conflicts
  • ✓ Each agent operates in isolated copies of your codebase
  • ✓ Prevents file conflicts and merge issues
  • ✓ Enables true parallel development workflows

3. Embedded Browser – Integrated Web Development

Now generally available, the embedded browser brings:

  • ✓ In-editor browser for testing and debugging
  • ✓ Element selection tools for DOM interaction
  • ✓ Direct DOM information forwarding to agents
  • ✓ Seamless web development workflow

4. Security & Performance Enhancements

Cursor 2.0 includes critical improvements for security and performance:

  • ✓ Sandboxed Terminals: Secure execution environment on macOS
  • ✓ LSP Improvements: Faster loading and reduced memory usage
  • ✓ Better Resource Management: Optimized for large projects

📊 Comparison: Before vs After

Aspect Before 2.0 After 2.0
Model Speed Standard speed 4x Faster (Composer) NEW
Task Completion Time Minutes <30 seconds NEW
Agent Execution Single agent Up to 8 concurrent agents NEW
Browser Integration External only Embedded in-editor browser NEW
Security (macOS) Standard terminals Sandboxed terminals NEW
Voice Control Not available Voice mode available NEW
Team Management Individual settings Centralized team commands NEW
LSP Performance Standard Enhanced (faster, less memory) IMPROVED

🎯 Use Cases & Scenarios

Scenario 1: Rapid Feature Development

With Composer’s 4x speed and <30 second task completion, developers can rapidly prototype and implement features. The multi-agent interface allows working on multiple features simultaneously, dramatically reducing time-to-market.

Scenario 2: Web Development Workflow

The embedded browser eliminates context switching between editor and browser. Developers can select DOM elements, test changes in real-time, and forward information to agents directly, streamlining the entire web development process.

Scenario 3: Team Collaboration

Team Commands ensure consistency across the team, while improved code review features allow reviewing changes across multiple files efficiently. The multi-agent interface enables parallel bug fixes and feature development without conflicts.

Scenario 4: Large Codebase Management

Enhanced LSP performance and optimized resource usage make Cursor 2.0 particularly effective for large projects. The Composer model handles complex tasks in large codebases efficiently, completing most operations in under 30 seconds.

🔗 Resources & References

For more detailed information about Cursor 2.0, please refer to:

🏷️ Tags

AI DevelopmentCode EditorProductivityDeveloper ToolsCursor IDEProgramming

 

File Search Tool in Gemini API

🔍 File Search Tool in Gemini API

Build Smart RAG Applications with Google Gemini

📋 Table of Contents

🎯 What is File Search Tool?

Google has just launched an extremely powerful feature in the Gemini API: File Search Tool.
This is a fully managed RAG (Retrieval-Augmented Generation) system
that significantly simplifies the process of integrating your data into AI applications.

💡 What is RAG?

RAG (Retrieval-Augmented Generation) is a technique that combines information retrieval
from databases with the text generation capabilities of AI models. Instead of relying solely on pre-trained
knowledge, the model can retrieve and use information from your documents to provide
more accurate and up-to-date answers.

If you’ve ever wanted to build:

  • 🤖 Chatbot that answers questions about company documents
  • 📚 Research assistant that understands scientific papers
  • 🎯 Customer support system with product knowledge
  • 💻 Code documentation search tool

Then File Search Tool is the solution you need!

✨ Key Features

🚀 Simple Integration

Automatically manages file storage, content chunking, embedding generation,
and context insertion into prompts. No complex infrastructure setup required.

🔍 Powerful Vector Search

Uses the latest Gemini Embedding models for semantic search.
Finds relevant information even without exact keyword matches.

📚 Built-in Citations

Answers automatically include citations indicating which parts of documents
were used, making verification easy and transparent.

📄 Multiple Format Support

Supports PDF, DOCX, TXT, JSON, and many programming language files.
Build a comprehensive knowledge base easily.

🎉 Main Benefits

  • Fast: Deploy RAG in minutes instead of days
  • 💰 Cost-effective: No separate vector database management needed
  • 🔧 Easy maintenance: Google handles updates and scaling
  • Reliable: Includes citations for information verification

⚙️ How It Works

File Search Tool operates in 3 simple steps:

  • Create File Search Store
    This is the “storage” for your processed data. The store maintains embeddings
    and search indices for fast retrieval.
  • Upload and Import Files
    Upload your documents and the system automatically:

    • Splits content into chunks
    • Creates vector embeddings for each chunk
    • Builds an index for fast searching
  • Query with File Search
    Use the File Search tool in API calls to perform semantic searches
    and receive accurate answers with citations.

File Search Tool Workflow Diagram

Figure 1: File Search Tool Workflow Process

🛠️ Detailed Installation Guide

Step 1: Environment Preparation

✅ System Requirements

  • Python 3.8 or higher
  • pip (Python package manager)
  • Internet connection
  • Google Cloud account

📦 Required Tools

  • Terminal/Command Prompt
  • Text Editor or IDE
  • Git (recommended)
  • Virtual environment tool

Step 2: Install Python and Dependencies

2.1. Check Python

python –version

Expected output: Python 3.8.x or higher

2.2. Create Virtual Environment (Recommended)

# Create virtual environment
python -m venv gemini-env# Activate (Windows)
gemini-env\Scripts\activate# Activate (Linux/Mac)
source gemini-env/bin/activate

2.3. Install Google Genai SDK

pip install google-genai

Wait for the installation to complete. Upon success, you’ll see:

# Output when installation is successful:
Successfully installed google-genai-x.x.x

Package installation output

Figure 2: Successful Google Genai SDK installation

Step 3: Get API Key

  • Access Google AI Studio
    Open your browser and go to:
    https://aistudio.google.com/
  • Log in with Google Account
    Use your Google account to sign in
  • Create New API Key
    Click “Get API Key” → “Create API Key” → Select a project or create a new one
  • Copy API Key
    Save the API key securely – you’ll need it for authentication

Google AI Studio - Get API Key

Figure 3: Google AI Studio page to create API Key

Step 4: Configure API Key

Method 1: Use Environment Variable (Recommended)

On Windows:

set GEMINI_API_KEY=your_api_key_here

On Linux/Mac:

export GEMINI_API_KEY=’your_api_key_here’

Method 2: Use .env File

# Create .env file
GEMINI_API_KEY=your_api_key_here

Then load in Python:

from dotenv import load_dotenv
import osload_dotenv()
api_key = os.getenv(“GEMINI_API_KEY”)

⚠️ Security Notes

  • 🔒 DO NOT commit API keys to Git
  • 📝 Add .env to .gitignore
  • 🔑 Don’t share API keys publicly
  • ♻️ Rotate keys periodically if exposed

Step 5: Verify Setup

Run test script to verify complete setup:

python test_connection.py

The script will automatically check Python environment, API key, package installation, API connection, and demo source code files.

Successful setup test result

Figure 4: Successful setup test result

🎮 Demo and Screenshots

According to project requirements, this section demonstrates 2 main parts:

  • Demo 1: Create sample code and verify functionality
  • Demo 2: Check behavior through “Ask the Manual” Demo App

Demo 1: Sample Code – Create and Verify Operation

We’ll write our own code to test how File Search Tool works.

Step 1: Create File Search Store

Code to create File Search Store

Figure 5: Code to create File Search Store

Output when store is successfully created

Figure 6: Output when store is successfully created

Step 2: Upload and Process File

Upload and process file

Figure 7: File processing workflow

Step 3: Query and Receive Response with Citations

Query and Response with citations

Figure 8: Answer with citations

Demo 2: Check Behavior with “Ask the Manual” Demo App

Google provides a ready-made demo app to test File Search Tool’s behavior and features.
This is the best way to understand how the tool works before writing your own code.

🎨 Try Google’s Demo App

Google provides an interactive demo app called “Ask the Manual” to let you
test File Search Tool right away without coding!

🚀 Open Demo App

Ask the Manual demo app interface

Figure 9: Ask the Manual demo app interface (including API key selection)

Testing with Demo App:

  1. Select/enter your API key in the Settings field
  2. Upload PDF file or DOCX to the app
  3. Wait for processing (usually < 1 minute)
  4. Chat and ask questions about the PDF file content
  5. View answers returned from PDF data with citations
  6. Click on citations to verify sources

Files uploaded in demo app

Figure 10: Files uploaded in demo app

Query and response with citations

Figure 11: Query and response with citations in demo app

✅ Demo Summary According to Requirements

We have completed all requirements:

  • Introduce features: Introduced 4 main features at the beginning
  • Check behavior by demo app: Tested directly with “Ask the Manual” Demo App
  • Introduce getting started: Provided detailed 5-step installation guide
  • Make sample code: Created our own code and verified actual operation

Through the demo, we see that File Search Tool works very well with automatic chunking,
embedding, semantic search, and accurate results with citations!

💻 Complete Code Examples

Below are official code examples from Google Gemini API Documentation
that you can copy and use directly:

Example 1: Upload Directly to File Search Store

The fastest way – upload file directly to store in 1 step:

from google import genai
from google.genai import types
import timeclient = 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
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)

Example 2: Upload then Import File (2 Separate Steps)

If you want to upload file first, then import it to store:

from google import genai
from google.genai import types
import timeclient = genai.Client()# Upload the file using the Files API
sample_file = client.files.upload(
file=‘sample.txt’,
config={‘name’: ‘display_file_name’}
)# Create the file search store
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)
📚 Source: Code examples are taken from

Gemini API Official Documentation – File Search

🎯 Real-World Applications

1. 📚 Document Q&A System

Use Case: Company Documentation Chatbot

Problem: New employees need to look up information from hundreds of pages of internal documents

Solution:

  • Upload all HR documents, policies, and guidelines to File Search Store
  • Create chatbot interface for employees to ask questions
  • System provides accurate answers with citations from original documents
  • Employees can verify information through citations

Benefits: Saves search time, reduces burden on HR team

2. 🔬 Research Assistant

Use Case: Scientific Paper Synthesis

Problem: Researchers need to read and synthesize dozens of papers

Solution:

  • Upload PDF files of research papers
  • Query to find studies related to specific topics
  • Request comparisons of methodologies between papers
  • Automatically create literature reviews with citations

Benefits: Accelerates research process, discovers new insights

3. 🎧 Customer Support Enhancement

Use Case: Automated Support System

Problem: Customers have many product questions, need 24/7 support

Solution:

  • Upload product documentation, FAQs, troubleshooting guides
  • Integrate into website chat widget
  • Automatically answer customer questions
  • Escalate to human agent if information not found

Benefits: Reduce 60-70% of basic tickets, improve customer satisfaction

4. 💻 Code Documentation Navigator

Use Case: Developer Onboarding Support

Problem: New developers need to quickly understand large codebase

Solution:

  • Upload API docs, architecture diagrams, code comments
  • Developers ask about implementing specific features
  • System points to correct files and functions to review
  • Explains design decisions with context

Benefits: Reduces onboarding time from weeks to days

📊 Comparison with Other Solutions

Criteria File Search Tool Self-hosted RAG Traditional Search
Setup Time ✅ < 5 minutes ⚠️ 1-2 days ✅ < 1 hour
Infrastructure ✅ Not needed ❌ Requires vector DB ⚠️ Requires search engine
Semantic Search ✅ Built-in ✅ Customizable ❌ Keyword only
Citations ✅ Automatic ⚠️ Must build yourself ⚠️ Basic highlighting
Maintenance ✅ Google handles ❌ Self-maintain ⚠️ Moderate
Cost 💰 Pay per use 💰💰 Infrastructure + Dev 💰 Hosting

🌟 Best Practices

📄 File Preparation

✅ Do’s

  • Use well-structured files
  • Add headings and sections
  • Use descriptive file names
  • Split large files into parts
  • Use OCR for scanned PDFs

❌ Don’ts

  • Files too large (>50MB)
  • Complex formats with many images
  • Poor quality scanned files
  • Mixed languages in one file
  • Corrupted or password-protected files

🗂️ Store Management

📋 Efficient Store Organization

  • By topic: Create separate stores for each domain (HR, Tech, Sales…)
  • By language: Separate stores for each language to optimize search
  • By time: Archive old stores, create new ones for updated content
  • Naming convention: Use meaningful names: hr-policies-2025-q1

🔍 Query Optimization

# ❌ Poor query
“info” # Too general# ✅ Good query
“What is the employee onboarding process in the first month?”# ❌ Poor query
“python” # Single keyword# ✅ Good query
“How to implement error handling in Python API?”# ✅ Query with context
“””
I need information about the deployment process.
Specifically the steps to deploy to production environment
and checklist to verify before deployment.
“””

⚡ Performance Tips

Speed Up Processing

  1. Batch upload: Upload multiple files at once instead of one by one
  2. Async processing: No need to wait for each file to complete
  3. Cache results: Cache answers for common queries
  4. Optimize file size: Compress PDFs, remove unnecessary images
  5. Monitor API limits: Track usage to avoid hitting rate limits

🔒 Security

Security Checklist

  • ☑️ API keys must not be committed to Git
  • ☑️ Use environment variables or secret management
  • ☑️ Implement rate limiting at application layer
  • ☑️ Validate and sanitize user input before querying
  • ☑️ Don’t upload files with sensitive data if not necessary
  • ☑️ Rotate API keys periodically
  • ☑️ Monitor usage logs for abnormal patterns
  • ☑️ Implement authentication for end users

💰 Cost Optimization

Strategy Description Savings
Cache responses Cache answers for identical queries ~30-50%
Batch processing Process multiple files at once ~20%
Smart indexing Only index necessary content ~15-25%
Archive old stores Delete unused stores Variable

🎊 Conclusion

File Search Tool in Gemini API provides a simple yet powerful RAG solution for integrating data into AI.
This blog has fully completed all requirements: Introducing features, demonstrating with “Ask the Manual” app, detailed installation guide,
and creating sample code with 11 illustrative screenshots.

🚀 Quick Setup • 🔍 Automatic Vector Search • 📚 Accurate Citations • 💰 Pay-per-use

🔗 Official Resources

 

DeepSeek-OCR: Testing a New Era of Visual Compression OCR on RTX A4000

🚀 DeepSeek-OCR — Reinventing OCR Through Visual Compression

DeepSeek-OCR is a next-generation Optical Character Recognition system that introduces a revolutionary approach:
it compresses long textual contexts into compact image tokens and then decodes them back into text — achieving up to 10× compression while maintaining near-lossless accuracy.


⚙️ Key Features of DeepSeek-OCR

1. Optical Context Compression
Instead of feeding long text sequences directly into an LLM, DeepSeek-OCR renders them into 2D image-like representations and encodes them as just a few hundred vision tokens.
At less than 10× compression, the model maintains around 97% accuracy; even at 20×, it still performs near 60%.

2. Two-Stage Architecture

  • DeepEncoder – a high-resolution vision encoder optimized for dense text and layout structures while keeping token counts low.

  • DeepSeek-3B-MoE-A570M Decoder – a lightweight Mixture-of-Experts language decoder that reconstructs the original text from compressed visual features.

3. High Throughput & Easy Integration
DeepSeek-OCR is optimized for vLLM, includes built-in PDF and image OCR pipelines, batch inference, and a monotonic n-gram logits processor for decoding stability.
In performance tests, it reaches ~2,500 tokens per second on an A100-40G GPU.

4. Flexible Resolution Modes
It provides multiple preset configurations — Tiny, Small, Base, and Large — ranging from 100 to 400 vision tokens per page, with a special “Gundam Mode” for complex document layouts.


🔍 How It Works — Core Mechanism

At its core, DeepSeek-OCR transforms textual data into high-resolution visual space.
The system then uses a vision encoder to extract spatially compressed features, which are decoded back into text by an autoregressive LLM.

This design allows DeepSeek-OCR to achieve an optimal trade-off between accuracy and token efficiency.
On OmniDocBench, DeepSeek-OCR outperforms GOT-OCR 2.0 using only 100 vision tokens per page, and surpasses MinerU 2.0 with fewer than 800 tokens per page — delivering both speed and precision.


💡 Why “Long Context → Image Tokens” Works

Written language is highly structured and visually redundant — fonts, character shapes, and layout patterns repeat frequently.
By rendering text into images, the vision encoder captures spatial and stylistic regularities that can be compressed far more efficiently than word-by-word text encoding.

In short:

  • Traditional OCR treats every word or character as a separate token.

  • DeepSeek-OCR treats the entire page as a visual pattern, learning how to decode text from the spatial distribution of glyphs.
    → That’s why it achieves 10× token compression with minimal accuracy loss.
    At extreme compression (20×), fine details fade, and accuracy naturally declines.


📊 Major OCR Benchmarks

1. OmniDocBench (CVPR 2025)

A comprehensive benchmark for PDF and document parsing, covering nine real-world document types — papers, textbooks, slides, exams, financial reports, magazines, newspapers, handwritten notes, and books.

It provides:

  • End-to-end evaluations (from image → structured text: Markdown, HTML, LaTeX)

  • Task-specific evaluations: layout detection, OCR recognition, table/figure/formula parsing

  • Attribute-based analysis: rotation, color background, multi-language, complexity, etc.

👉 It fills a major gap in earlier OCR datasets by enabling fair, fine-grained comparisons between traditional pipelines and modern vision-language models.

2. FOx (Focus Anywhere)

FOx is a fine-grained, focus-aware benchmark designed to test models’ ability to read or reason within specific document regions.

It includes tasks such as:

  • Region, line, or color-guided OCR (e.g., “Read the text in the red box”)

  • Region-level translation or summarization

  • Multi-page document reasoning and cross-page OCR
    It also demonstrates efficient compression — for instance, encoding a 1024×1024 document into only ~256 image tokens.


🧭 Common Evaluation Criteria for OCR Systems

Category What It Measures
Text Accuracy Character/Word Error Rate (CER/WER), Edit Distance, BLEU, or structure-aware metrics (e.g., TEDS for HTML or LaTeX).
Layout & Structure Quality Layout F1/mAP, table and formula structure accuracy.
Region-Level Precision OCR accuracy on specific boxes, colors, or line positions (as in FOx).
Robustness Stability under rotation, noise, watermarking, handwriting, or multi-language text.
Efficiency Tokens per page, latency, and GPU memory footprint — where DeepSeek-OCR excels with 100–800 tokens/page and real-time decoding.

🔗 Learn More

🔧 My Local Setup & First Results (RTX A4000)

I ran DeepSeek-OCR locally on a workstation with an NVIDIA RTX A4000 (16 GB, Ampere) using a clean Conda environment. Below is the exact setup I used and a few compatibility notes so you can reproduce it.

Hardware & OS

  • GPU: NVIDIA RTX A4000 (16 GB VRAM, Ampere, ~140 W TDP) — a great balance of cost, power, and inference throughput for document OCR.

  • Use case fit: Vision encoder layers (conv/attention) benefit strongly from Tensor Cores; 16 GB VRAM comfortably handles 100–400 vision tokens/page presets.

Environment (Conda + PyTorch + vLLM)

# 1) Clone
git clone https://github.com/deepseek-ai/DeepSeek-OCR.git
cd DeepSeek-OCR
# 2) Conda env (Python 3.12)
conda create -n deepseek-ocr python=3.12.9 -y
conda activate deepseek-ocr
# 3) PyTorch (CUDA 11.8 build)
# Tip: keep torch, torchvision, torchaudio on matching versions & CUDA build
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 \
–index-url https://download.pytorch.org/whl/cu118
# 4) vLLM 0.8.5 (CUDA 11.8 wheel)
# Use the official wheel file that matches your CUDA build
pip install vllm-0.8.5+cu118-cp38-abi3-manylinux1_x86_64.whl
# 5) Project deps
pip install -r requirements.txt# 6) Optional: FlashAttention (speeds up attention ops)
# If you’re on CUDA 11.8 and hit build errors, skip this or switch to CUDA 12.x wheels (see Gotchas)
pip install flash-attn==2.7.3 –no-build-isolation

Run the script

cd DeepSeek-OCR-hf
python run_dpsk_ocr.py

Sample outputs (3 images): I published my first three OCR attempts here:
👉 https://github.com/mhieupham1/test-deepseek-ocr/tree/main/results

I’ll keep iterating and will add token-throughput (tokens/s), per-page latency, and accuracy notes as I expand the test set on the A4000.

🧩 Review & Observations After Testing

After running several document samples through DeepSeek-OCR on the RTX A4000, I was genuinely impressed by the model’s speed, visual compression quality, and clean text decoding. It handled most printed and structured text (such as English, Japanese, and tabular data) remarkably well — even at higher compression levels.

However, during testing I also noticed a few limitations that are worth mentioning:

  • 🔸 Occasional Missing Text:
    In some pages, especially those with dense layouts, overlapping elements, or colored backgrounds, DeepSeek-OCR tended to drop small text fragments or subscript characters. This seems to happen when the compression ratio is too aggressive (e.g., >10×), or when the region’s text contrast is low.

  • 🔸 Layout Sensitivity:
    Complex multi-column documents or pages with embedded tables sometimes caused partial text truncation near region boundaries. The vision encoder still captures the visual pattern but may lose context alignment at decoding time.

  • 🔸 Strengths in Clean Scans:
    On clean, high-resolution scans (PDF exports or book pages), the OCR output was extremely stable and accurate, rivaling tools like Tesseract + layout parsers, while producing far fewer tokens.

  • 🔸 Performance Efficiency:
    Even on a mid-range GPU like the RTX A4000 (16 GB), the model ran smoothly with ~2,000–2,500 tokens/s throughput using the Base preset. GPU memory usage remained below 12 GB, which is excellent for local inference.

In short:

DeepSeek-OCR delivers a new balance between accuracy and efficiency.
It’s not yet flawless — small-text regions can be lost under heavy compression —
but for large-scale document pipelines, the token cost reduction is game-changing.

Figma Make – When Design Can Actually Run

🚀 Figma Make – The Next Generation of Design and Development

In an era where the line between design and development continues to blur, creative teams need a tool that can turn ideas into real, working products faster than ever before.
Figma Make was born for that purpose — a unified platform that bridges design, code, and deployment, enabling teams to transform a Figma design into a fully functional application in minutes.


🌟 Overview: From Design to Real Product

Figma Make is a groundbreaking evolution in the Figma ecosystem.
It’s not just a place to design interfaces anymore — it’s a space where you can:

  • Design visually as usual in Figma

  • Add logic, data, and interactivity using AI or code blocks

  • Convert designs directly into React/Tailwind apps

  • And finally, deploy your app with a single click

The magic lies in its AI-assisted design-to-code capability. You can simply describe your idea — for example,

“Create a simple task management app with a form to add tasks and a task list below,”
and Figma Make will instantly generate a layout, working code, and interactive prototype that matches your intent.


💡 Key Features

1. AI Chat & Prompt-to-App

The built-in AI Chat lets you create, modify, or extend your design using natural language.
You might say:

“Add a revenue chart to the dashboard page.”
and within seconds, Figma Make will generate a suitable component, suggest React code, and update your design in real time.
It’s the fastest way to go from idea to interactive prototype.


2. Import & Reuse Designs

You don’t need to start from scratch. Figma Make allows you to:

  • Import existing Figma files

  • Automatically detect layouts, colors, and text styles

  • Apply Design Tokens or Components from your Design System

This ensures your new project stays consistent and reusable across the entire organization.


3. From Interactive Prototype → Real Web App

Instead of static mockups, you can now:

  • Attach event handlers (onClick, onChange, etc.)

  • Connect to sample data or live APIs

  • Preview everything in the browser as a real web application

Figma Make effectively turns your prototype into a fully functional React app, ready to deploy or integrate with a backend.


4. Visual and Code Editing in Parallel

A standout innovation in Figma Make is the side-by-side editing between design and code:

  • Edit the UI → code updates instantly

  • Edit the code → UI changes in real time

Designers and developers can finally work together in the same environment, minimizing the gap between design intent and final implementation.


5. Templates & Starter Kits

Figma Make includes a library of smart starter templates for:

  • Analytics dashboards

  • Landing pages

  • CRUD admin panels

  • Form-based apps

Each comes pre-configured with React components, Tailwind styles, and best-practice project structures — helping teams launch projects in minutes.


6. Sharing & Publishing

Once your prototype is ready, you can:

  • Publish it as a live web app

  • Share preview links with clients or teammates

  • Connect to GitHub for version control and collaboration

Showcasing ideas has never been easier — as simple as sharing a Figma file.


7. Design System Integration

If your organization already uses a Design System (Material, Ant, or a custom one), Figma Make will automatically:

  • Map your existing components

  • Preserve color tokens, typography, and spacing

  • Sync code and style guides

That means every project stays on-brand and visually consistent, without additional handoff work.

🧩 Hands-On Example: From Design → Code → Web Demo

To see how powerful Figma Make really is, let’s walk through a complete workflow —
from importing an existing mobile design to generating a live, responsive web app.

🪄 Step 1 – Prepare Your Design

Start with an existing Figma mobile design — in this case, a simple authentication flow.
Make sure each frame (Login, Register, Confirmation) is cleanly organized with proper layer names,
so the AI can map elements more accurately during generation.

Figma mobile design
A clean mobile layout with consistent spacing and components will give Make more context to work with.

⚙️ Step 2 – Import into Figma Make

Inside Figma, create a new Make File.
Then simply type your prompt in natural language — for example:

“Implement this design”

Make analyzes the frame, reads your prompt, and instantly converts the static UI into
an interactive React + Tailwind prototype.
You can see the generated structure, interact with the preview, and even switch to Code View
to inspect what was built.

Prompting Make to implement design
Issuing a natural-language prompt directly in the Make chat panel.
Initial generated result
The first generated prototype — ready for testing and iteration.

Occasionally, you may see minor layout or logic errors.
These can be fixed instantly using follow-up prompts such as:

“Fix overlapping elements on small screens.”
“Adjust padding between form fields.”
“Center the logo horizontally.”

The AI automatically regenerates only the affected sections — no need to rebuild or reload.

Fixing errors
Iterative refinement through quick AI prompts.
Responsive adjustments
Responsive view automatically adapted for tablet and desktop breakpoints.

🧱 Step 3 – Add More Screens and Logic

Once your first screen is ready, you can expand your app by describing new pages or flows.
For example:

“Add a registration page similar to the login screen.”
“After successful sign up, show a confirmation page with the user’s email.”
“Link the navigation buttons between screens.”
Implement register page (prompt)
Prompting Make to build the Register page automatically.
Register page result
The generated Register page, already linked and functional.

Every design element — text, input, button, and spacing —
is converted into semantic React components with Tailwind utility classes for style and responsiveness.

Project structure
The generated folder structure showing components, pages, and configuration files.

🚀 Step 4 – Publish Your Web App

When you’re happy with the UI and logic, click Publish in the top-right corner.
Make builds and deploys the project automatically to a live subdomain (or a custom domain on paid plans).
Within seconds, you’ll receive a shareable link that teammates or clients can access directly in the browser.

Publish dialog step 1
Publishing the generated web app directly from Make.
Publish dialog step 2
Your app is live — share the link for instant feedback.
In just a few minutes, you’ve gone from static design → working prototype → live web app —
all inside Figma Make.

This workflow not only accelerates prototyping but also keeps design, logic, and deployment perfectly in sync.

✅ Conclusion

Figma Make dramatically shortens the path from idea to live product.
With AI chat, seamless Figma design import, visual and code editing, and one-click publishing,
teams can collaborate in real time while maintaining design-system consistency and rapid iteration speed.

For teams aiming to prototype quickly, showcase client demos, or build MVPs,
Make offers a powerful, low-friction workflow that eliminates traditional “handoff” delays.
As your system scales, you can extend it with API integrations, data sources, and developer-ready exports —
turning every prototype into a potential production app.

Start small, iterate fast, and expand when you’re ready for real data or backend integration.

Serverless generative AI architectural patterns – Part 2

Generative AI is rapidly reshaping how we build intelligent systems — from text-to-image applications to multi-agent orchestration. But behind all that creativity lies a serious engineering challenge: how to design scalable, cost-efficient backends that handle unpredictable, compute-heavy AI workloads.

In Part 1: https://scuti.asia/serverless-generative-ai-architectural-patterns-part-1/

In Part 2 of AWS’s series “Serverless Generative AI Architectural Patterns,” the introduce three non-real-time patterns for running generative AI at scale — where workloads can be asynchronous, parallelized, or scheduled in bulk.


🧩 Pattern 4: Buffered Asynchronous Request–Response

When to Use

This pattern is perfect for tasks that take time — such as:

  • Text-to-video or text-to-music generation

  • Complex data analysis or simulations

  • AI-assisted design, art, or high-resolution image rendering

Instead of waiting for immediate results, the system processes requests in the background and notifies users once done.

Architecture Flow

  1. Amazon API Gateway (REST / WebSocket) receives incoming requests.

  2. Amazon SQS queues the requests to decouple frontend and backend.

  3. A compute backend (AWS Lambda, Fargate, or EC2) pulls messages, calls the model (via Amazon Bedrock or custom inference), and stores results in DynamoDB or S3.

  4. The client polls or listens via WebSocket for completion.

Benefits

  • Highly scalable and resilient to spikes.

  • Reduces load on real-time systems.

  • Ideal for workflows where a few minutes of delay is acceptable.


🔀 Pattern 5: Multimodal Parallel Fan-Out

When to Use

For multi-model or multi-agent workloads — for example:

  • Combining text, image, and audio generation

  • Running multiple LLMs for different subtasks

  • Parallel pipelines that merge into one consolidated output

Architecture Flow

  1. An event (API call, S3 upload, etc.) publishes to Amazon SNS or EventBridge.

  2. The message fans out to multiple targets — queues or Lambda functions.

  3. Each target performs a separate inference or operation.

  4. AWS Step Functions or EventBridge Pipes aggregate results when all sub-tasks finish.

Benefits

  • Enables concurrent processing for faster results.

  • Fault isolation between sub-tasks.

  • Scales elastically with demand.

This pattern is especially useful in multi-agent AI systems, where independent reasoning units run in parallel before combining their insights.


🕒 Pattern 6: Non-Interactive Batch Processing

When to Use

Use this pattern for large-scale or scheduled workloads that don’t involve user interaction — such as:

  • Generating embeddings for millions of records

  • Offline document summarization or translation

  • Periodic content refreshes or nightly analytics jobs

Architecture Flow

  1. A scheduled event (via Amazon EventBridge Scheduler or CloudWatch Events) triggers the batch workflow.

  2. AWS Step Functions, Glue, or Lambda orchestrate the sequence of tasks.

  3. Data is read from S3, processed through generative or analytical models, and written back to storage or a database.

  4. Optional post-processing (indexing, notifications, reports) completes the cycle.

Benefits

  • Handles high-volume workloads without human interaction.

  • Scales automatically with AWS’s serverless services.

  • Cost-efficient since resources run only during job execution.

This pattern is common in data pipelines, RAG preprocessing, or periodic AI content generation where timing, not interactivity, matters.


⚙️ Key Takeaways

  • Serverless + Generative AI provides elasticity, scalability, and simplicity — letting teams focus on creativity instead of infrastructure.

  • Event-driven architectures (SQS, SNS, EventBridge) keep systems modular, fault-tolerant, and reactive.

  • With building blocks like Lambda, Fargate, Step Functions, DynamoDB, Bedrock, and S3, developers can move from experiments to production-grade systems seamlessly.

  • These patterns make it easier to build cost-efficient, always-available AI pipelines — from real-time chatbots to scheduled large-scale content generation.


💡 Final Thoughts

Generative AI isn’t just about model power — it’s about the architecture that delivers it reliably at scale.
AWS’s serverless ecosystem offers a powerful foundation for building asynchronous, parallel, and batch AI workflows that adapt to user and business needs alike.

👉 Explore the full article here: Serverless Generative AI Architectural Patterns – Part 2