页面简介
Learn Vibe Coding from Zero to Advanced - Master AI programming with Claude Code, Cursor, and other AI IDE tools
正文摘录
Dify Basics and Knowledge Base Integration Review of the Previous Lesson In the previous lessons, we learned in groups the basics of AI coding, prompt engineering, and AI image generation. These topics helped us build an initial understanding of the boundaries and capabilities of different large language models (LLMs) and generative models.To help you review the previous lesson, think through these quick questions:What is AI programming? How can you use an AI coding tool (for example, z.ai) to create a webpage?What is a large language model? What are prompt engineering and context engineering? How should you write a complex prompt?Across text, AI coding, and image generation, where do you think model strengths and weaknesses show up most clearly?What is an API? How do you use z.ai to connect to third-party APIs?If any question still feels unclear, you can revisit the previous lesson docs or ask directly in the WeChat group.In this lesson, we move from simple AI text/image tools to workflow-building platforms closer to real business deployment. We go from chatbots to AI agents and AI workflows, and then use APIs to turn them into interactive "intelligent" chatbot pages.During hands-on operation, if any step is hard to understand, do not worry. A recommended approach is to take a screenshot of the page you are on and ask a model directly. Current models can already resolve most common issues.If you still cannot solve it after asking, keep trying. Do not be afraid of mistakes. Every attempt is part of learning and progress. With more practice, you will become increasingly fluent and confident.What You Will Learn in This Lesson Why we need to move from chatbots to agents and workflow orchestration.What an agent/workflow development platform is, and how to turn AI capability into SOP-style, orchestratable processes.What Dify is, and how to quickly build applications on this open-source LLM platform, especially a knowledge-base QA chatbot.How RAG works and why retrieval-augmented generation is needed.How to learn Dify and AI IDE Trae (Extra Knowledge 4 - What is AI IDE and Trae) from 0 to 1, including building agents, workflows, and a frontend chatbot webpage using Dify API.Basic Dify principles, agent/workflow building methods, and API invocation.AI IDE usage and AI-assisted coding workflow.A frontend agent program that can chat.1. From Conversation to Agent In the previous stage, we learned how to use prompts to make models play roles, generate text, or write simple code. But if you think carefully, there is a key issue: a chatbot itself cannot actually do work.It can answer "how to check an order," but it cannot truly query your database for the order number. It can describe what a weekly report should include, but it cannot automatically collect project data and send the email. This "can say but cannot do" limitation makes pure conversational AI hard to truly embed into business processes.To upgrade AI from chat companion to digital employee, we need to give it three core capabilities:Proprietary knowledge: let it read and understand your product docs, customer materials, and internal policies.Tool calling (or plugins): let it operate databases and call APIs.Structured execution: let it complete tasks step by step with predefined logic, not free improvisation.This is the prototype of an AI Agent: an automation unit with goals, knowledge, tools, and an execution path.Note: In current industry usage, "simple agents" usually mean enhanced applications built from LLM + tools + knowledge base, not fully autonomous planning agents. Even though these simple agents do not have true long-horizon reasoning and planning, they are already enough for many enterprise automation scenarios. We will introduce truly autonomous agents in later chapters.1.1 The Simplest Agent: Knowledge-Base QA Chatbot After clarifying the core capabilities of an agent, a natural question follows: can we build a practical basic agent by implementing only one of these capabilities? The answer is yes.In many real business scenarios, users do not need AI to execute complex operations (such as API orchestration across multiple systems). Their core need is accurate, reliable QA grounded in company-specific materials. This maps exactly to the first core capability: proprietary knowledge service.That leads to the simplest and most widely used agent form: a knowledge-base QA chatbot.Although it does not yet include tool calling or autonomous planning, the key breakthrough is this: model answers are no longer generated "from thin air." They become evidence-grounded. How is that achieved? We need to solve one core challenge: when there are thousands of pages of internal docs, how can the model quickly find the most relevant parts for each user question?One solution is Retrieval-Augmented Generation (RAG).The core RAG idea is: when a user asks a question, the system first retrieves the most semantically relevant text chunks from enterprise knowledge (for example, one paragraph from a product manual, one policy clause from HR docs), then injects these chunks into model context so the answer is generated based on real source material.Image source: https://www.datacamp.com/blog/what-is-retrieval-augmented-generation-ragThis means responses no longer rely only on generalized training knowledge. They are anchored to enterprise-authoritative information. The goal of RAG is exactly this dynamic external-knowledge injection, which significantly improves answer truthfulness, accuracy, and consistency. It can even enforce response persona/style, such as customer-support tone or technical-document style.In real business, this is especially important because models can hallucinate. For example, if you ask for concrete metrics as a CFO or consultant, a model may fabricate dates and events. With RAG, controllability and reliability improve significantly.Image source: https://www.databricks.com/glossary/retrieval-augmented-generation-ragIn this lesson's hands-on section, we will use Dify, a popular AI workflow platform, to build a knowledge-base QA chatbot. You can easily turn many kinds of proprietary materials into a knowledge base, such as product manuals, company policy docs, project docs, research papers, knowledge-base articles, and even personal notes.After setup, you can test with questions such as:"What are the major upgrades in the latest version of Product A?""According to the employee handbook, how is annual leave policy defined this year?""In project XX, how did we solve technical challenge 'XXX'?""What is the core research method described in this paper?"You will directly feel how RAG transforms static, scattered documents into a precise intelligent knowledge base that supports high-accuracy QA across scenarios.1.2 From Conversational Agent to Workflow However, even "enhanced agents" with knowledge base and tool calling are still insufficient for more complex business processes.Imagine this request: "What new features were released in our newly launched SaaS product recently? Can you organize them into a client-facing brief?"This looks simple, but behind the scenes it requires coordinated steps: first retrieve the last month's release notes from internal docs or Notion knowledge base; then filter customer-facing key features; then call an LLM to rewrite technical descriptions into customer-friendly language; and finally send the generated content to the marketing team's email or save it into a Google Docs template.If we rely only on a single LLM to reason freely, it is hard to execute the entire process in one dialogue. Even if it does, it can miss key details, confuse internal terms with customer language, or fail to output in structured form. More importantly, enterprises need an auditable, reusable, monitorable standardized execution path, not one-off improvisation in each run. Monitoring and reproducibility are crucial for enterprise risk control.This leads to a higher-level AI application pattern: AI Workflow.Workflow means decomposing a complex task into ordered, configurable, automatically executable sub-steps, then orchestrating logic between steps (conditionals, loops, parallelism) visually or via code. Turning AI capability into SOP means solidifying "how AI completes this task" into reusable templates.This brings multiple benefits: non-technical roles (such as product managers or operators) can build AI apps quickly via drag-and-drop; developers can encapsulate RAG retrieval, LLM calls, API tools as standard nodes for reuse across business scenarios; and the full process can be tracked, debugged, and optimized continuously to satisfy enterprise requirements for stability and compliance.AI workflow users are broad. Product managers can design full interaction flows without writing code; operations can quickly build customer-service bots, content generators, or notification systems; developers and ML engineers can modularize capabilities for frontend integration; founders and indie developers can validate AI MVPs at low cost and launch prototypes with query + generation + actions in days.Also note that AI workflows are usually described by an intermediate representation. Platform specifics differ, but most use structured files (JSON, YAML, etc.) to define node types, inputs/outputs, and execution logic, as shown below:In short, if agents let AI move from "can chat" to "can do," workflows let AI move from "occasionally complete one task" to "stably, reliably, and at scale complete a class of tasks." In the following practice, we will build a full AI workflow on Dify and experience the full path from idea to runnable app.1.3 Common Agent / Workflow Platforms As generative AI develops rapidly, many low-code and no-code agent/workflow platforms have emerged to help developers and business users build intelligent processes quickly without falling into low-level coding complexity.First, clarify what low-code means: development tools that significant