Bước 1 Step 1 ជំហាន 1
Tạo Agent đầu tiên Create Your first Agent បង្កើត Agent ដំបូង
- Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
- A Cloudflare Workers application that makes use of an Agent.
- Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
- The Agent starter provides common interfaces for Agents.
// Create new Agent from a template
npx create-cloudflare@latest —template cloudflare/agents-starter my-first-agent// Navigate to your new project
cd my-first-agent// Install dependencies and start development server
npm install// Update your OPENAI_API_KEY with a valid key.npm start ⚡ Local server running at http://localhost:5173 - npm not found: Install Node.js v20+ from nodejs.org
- Permission denied: Use sudo npm install -g wrangler (macOS/Linux)
- Build errors: Delete node_modules and run npm install again
Bước 2: Xem tool có sẵn Step 2: Explore available tools ជំហាន 2: មើល tool ដែលមាន
- Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
- The starter shows how tools can be defined.
- Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
- Agents often have tools that can run with or without human intervention.
# If your local server has stopped
npm start Khám phá tool Explore the tools ស្វែងយល់ tool
- Via the Chat Interface ask: What is the time in Vegas?
- Go explore src/tools.ts and find the implementation of getLocalTime
- Via the chat interface ask: What is the current weather in Las Vegas?
- Navigate to src/tools.ts and locate the definition of getWeatherInfomration
- In src/tools.ts locate the exported executions object.
Bước 3: Xem schedule task Step 3: Explore scheduling tasks ជំហាន 3: មើលការកំណត់ពេល task
- Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
- The starter provides some tools that expose the internal scheduling API.
- Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
- When you have state, and the ability to schedule, all sorts of new use cases arise.
# If your local server has stopped
npm start Xem phần triển khai Explore the implementation មើលការអនុវត្ត
- Via the chat interface ask for a specific timing: In twenty seconds say supdawg
- In src/tools.ts, note how the tools getScheduledTasks and cancelScheduledTask are using RPC methods based on the response from getCurrentAgent
- Via the chat interface ask to make a recurring tast: Every 15 seconds say supdawg
- Stop that from happening “Cancel the recurring task”
✅ Great work! You now have a functional Agent Starter that allows you to call tools both autonomously and keeping the human in the loop. You’re ready to add custom tools in Step 2!
✅ Great work! You now have a functional Agent Starter that allows you to call tools both autonomously and keeping the human in the loop. You’re ready to add custom tools in Step 2!
✅ Great work! You now have a functional Agent Starter that allows you to call tools both autonomously and keeping the human in the loop. You’re ready to add custom tools in Step 2!