Lộ trình đang học Current learning path

Developer Platform Developer Platform

Build và deploy apps trên Cloudflare. Build and deploy apps on Cloudflare.

Về trang lộ trình Track home

Phần 5: AI trên Developer Platform Part 5: AI on the Developer Platform · Bài 1/5 Lesson 1/5

Inference đầu tiên với Workers AI First inference with Workers AI

Thêm AI binding vào Worker, gọi model từ server-side và trả response tối thiểu. Bắt đầu bằng một task rõ ràng trước khi thêm chat UI hoặc nhiều provider. Add an AI binding to a Worker, call a model server-side, and return a minimal response. Start with one clear task before adding a chat UI or multiple providers.

First inference with Workers AI
Minh họa từ Cloudflare Reference Architecture (developers.cloudflare.com) Illustration from Cloudflare Reference Architecture (developers.cloudflare.com)

Các bước thực hiện Step-by-step

  1. Tạo Worker bằng `wrangler init` hoặc dùng Worker hiện có từ dp-2. Create a Worker with `wrangler init` or use the Worker from dp-2.
  2. Thêm Workers AI binding tên `AI` vào cấu hình Worker. Add a Workers AI binding named `AI` to the Worker configuration.
  3. Gọi một model cho một task cụ thể (ví dụ classification hoặc text generation) từ handler server-side. Call a model for one specific task (for example classification or text generation) from a server-side handler.
  4. Log model, latency và lỗi; test input hợp lệ, input rỗng và input quá dài trước khi thêm UI. Log the model, latency, and errors; test valid, empty, and overlong input before adding a UI.

Giải thích chi tiết Detailed explanation

Adoption tốt bắt đầu bằng một capability đo được, không phải chatbot chung chung. Giữ inference trong Worker để client không có quyền gọi model/binding trực tiếp. Healthy adoption starts with one measurable capability, not a generic chatbot. Keep inference in the Worker so the client cannot call a model or binding directly.

Lưu ý (best practices) Note (best practices)

Giữ model call và binding trong Worker. Đừng expose provider credential, binding identifier hoặc logic chọn model cho client; dùng environment-specific config và test trên preview trước production. Keep model calls and bindings in the Worker. Do not expose provider credentials, binding identifiers, or model-selection logic to the client; use environment-specific configuration and test in preview before production.

Nguồn: Source: Workers Best Practices Workers Best Practices

Ví dụ triển khai (Cloudflare Resources) Deployment examples (Cloudflare Resources)

Ví dụ chính thức từ Cloudflare Resources — gợi ý theo chủ đề bài học trong lộ trình này. Official examples from Cloudflare Resources — matched to this lesson within this path.

Tutorial Tutorial Developer Platform Developer Platform

Choose Right Text Generation Model Choose the Right Text Generation Model

Tóm tắt thực hành: Choose Right Text Generation Model trên Workers AI. There's a wide range of text generation models available through Workers AI. In an effort to aid you in your journey of finding the right model, this notebook will help you get to…

There's a wide range of text generation models available through Workers AI. In an effort to aid you in your journey of finding the right model, this notebook will help you get to know your options in a speed dating type of scenario.

Tìm hiểu thêm Learn more
Tutorial Tutorial Developer Platform Developer Platform

Explore Workers AI Models Using Jupyter Notebook Explore Workers AI Models Using a Jupyter Notebook

Tóm tắt thực hành: Explore Workers AI Models Using Jupyter Notebook trên Workers AI. This Jupyter notebook explores various models (including Whisper, Distilled BERT, LLaVA, and Meta Llama 3) using Python and the requests library.

This Jupyter notebook explores various models (including Whisper, Distilled BERT, LLaVA, and Meta Llama 3) using Python and the requests library.

Tìm hiểu thêm Learn more

Xem thêm ví dụ trong lộ trình → More examples in this path →

Tài liệu Cloudflare Developers Cloudflare Developer docs

Sơ đồ kiến trúc (Cloudflare Docs) Architecture diagrams (Cloudflare Docs)

Figure 1: Composable AI architecture

Composable AI architecture Composable AI architecture

The architecture diagram illustrates how AI applications can be built end-to-end on Cloudflare, or single services can be integrated with external infrastructure and services. The architecture diagram illustrates how AI applications can be built end-to-end on Cloudflare, or single services can be integrated with external infrastructure and services.

Thuật ngữ: Concepts: Workers AI · AI Gateway · External LLM · Composable stack

Sơ đồ chính thức ↗ Official diagram ↗ · AI Artificial Intelligence (AI)

Sản phẩm liên quan Related products

Học xong hoặc muốn đổi hướng? Finished or want a different path?

Ba lộ trình độc lập — mỗi lộ trình chỉ gồm bài học và tài liệu trong phạm vi đó. Chọn lộ trình khác khi sẵn sàng, không cần học song song. Three independent paths — each includes only lessons and materials for that scope. Switch when you are ready; no need to study paths in parallel.

Chưa chắc — làm bài chọn lộ trình Not sure — use the path selector · So sánh cả ba lộ trình Compare all three paths