Skip to content

Thiết kế AI-Native App

Mở đầu

Sao 1 số AI product khiến ngạc nhiên, còn 1 số chỉ là "vỏ ChatGPT"? Khác biệt không ở model dùng mạnh cỡ nào, mà product có design từ underlying xoay quanh đặc tính AI hay không. AI-native app không phải "thêm chat box" lên app traditional, mà rethink toàn bộ user interaction, system architecture, product logic.

Bạn sẽ học:

  • Paradigm: hiểu khác biệt bản chất AI-native vs traditional
  • Design principles: core principle cho AI-native product
  • Prompt engineering: design prompt chất lượng cao drive AI capability
  • Interaction: new pattern UX của AI era
  • Architecture: full lifecycle request của AI app
ChươngNội dung
1Architecture comparison
2Design principles
3Prompt engineering
4Interaction patterns
5Request flow

0. Toàn cảnh: từ "thêm AI" → "AI-native"

Mấy năm trước, path AI hoá nhiều product: có app sẵn, thêm 1 nút "AI assistant" ở góc nào đó. Như lắp engine lên xe ngựa — chạy được, nhưng không bằng design 1 chiếc xe hơi từ đầu.

AI-native app = product thinking mới: từ dòng code đầu, AI là capability core, không phải feature add sau.

Traditional vs AI-native

  • Traditional: user action → deterministic logic → deterministic result. Mỗi lần click "submit order", flow y nhau.
  • AI-native: user intent → AI hiểu → probabilistic result. Cùng question, mỗi lần answer hơi khác.
  • Core shift: từ "viết rule" → "mô tả intent", từ "deterministic" → "probabilistic", từ "operation UI" → "dialogue UI".

1. Architecture comparison

Traditional architecture = "request-response": user click, backend execute deterministic logic, return deterministic result. Cả quá trình predictable, testable, reproducible.

AI-native introduce role mới — LLM. Như "smart middleware", nhận natural language input, output natural language. Mang thay đổi architecture căn bản.

传统应用 vs AI 原生应用
切换视图,对比两种架构的核心差异
传统应用架构
🖥️
前端 UI
用户界面与交互
⚙️
业务逻辑层
硬编码的规则引擎
🗄️
数据存储
结构化数据管理
🔌
API 接口
固定的请求/响应
🖥️ 前端 UI
基于确定性的表单、按钮、页面路由。用户操作触发固定的业务流程,所有交互路径在开发时已经确定。
典型技术
ReactVueHTML/CSS
💡 核心区别:传统应用的逻辑由开发者用 if/else 硬编码,行为完全确定。
DimTraditionalAI-native
InputForm, button, dropdownNatural language, image, voice
Logicif-else, rule engineLLM reasoning, prompt-driven
OutputDeterministic, reproducibleProbabilistic, mỗi lần khác
Latencymss (cần streaming)
Error handlingError code rõHallucination, refusal, off-topic
CostCompute cố địnhPay per token, fluctuate

3 stage architecture evolution

  1. AI-augmented: nhúng AI vào app sẵn (autocomplete, smart recommend)
  2. AI-collaborative: AI là interaction core, nhưng vẫn traditional UI làm fallback (Notion AI, GitHub Copilot)
  3. AI-native: cả product xoay quanh AI, bỏ AI = product không tồn tại (ChatGPT, Cursor, Midjourney)

2. Design principles: "hiến pháp" AI-native

Không copy thinking của traditional software. Probabilistic + latency + unpredictable của AI yêu cầu principle mới.

AI 原生设计原则
点击卡片,深入了解每条设计原则
🛡️
优雅降级
AI 失败时,系统仍然可用
🤝
人机协作
关键决策由人类确认
🔍
透明可解释
让用户理解 AI 的推理过程
🔄
反馈闭环
用户反馈驱动持续改进
🛡️ 优雅降级
AI 模型可能超时、返回错误、产生幻觉。优雅降级意味着:当 AI 不可用时,系统应该有兜底方案,而不是直接崩溃。这是 AI 原生应用与玩具项目的分水岭。
实践对比
❌ 反面示例
模型 API 超时后,页面显示空白错误页,用户只能刷新重试。
✅ 正确做法
模型超时后,显示缓存的上一次回答或推荐相关文档,同时后台自动重试。
检查清单
设置合理的 API 超时时间(通常 30-60s)
准备降级方案:缓存、规则引擎、人工转接
向用户透明地展示当前状态
记录失败日志用于后续优化

5 core principles

  1. Embrace uncertainty: AI output không 100% reliable, design phải cân nhắc "AI có thể sai". Provide edit, retry, feedback. User luôn control.
  2. Progressive trust: đừng cho AI decision high-risk từ đầu. Build trust ở low-risk trước, expand quyền tự chủ AI.
  3. Transparent + explainable: cho user biết AI làm gì, sao làm vậy. Show reasoning, citation, confidence.
  4. Human-AI collaboration: AI không thay người, mà augment người. Best design: AI làm draft, người final review.
  5. Graceful degradation: AI down hoặc kết quả tệ, product vẫn dùng được. Luôn có Plan B.

3. Prompt engineering: "programming language" của AI app

Traditional: viết code bảo máy làm gì. AI-native: viết Prompt bảo model làm gì. Prompt = programming language của AI era — viết tốt AI ấn tượng; viết tệ AI bịa.

Prompt 工程实验室
修改 Prompt 结构,观察输出质量的变化
System Prompt(系统指令)
User Prompt(用户输入)
模拟输出
点击"模拟生成"查看效果
💡 Prompt 技巧:没有 System Prompt,没有上下文,问题过于模糊 —— AI 只能猜测你的意图。

4 layer Prompt

  1. System Prompt: define role, capability boundary, behavior. Instruction cấp "hiến pháp", user không thấy nhưng luôn effective.
  2. Context injection: doc retrieved qua RAG, user history → background AI cần.
  3. User Message: question/instruction thực của user.
  4. Format constraint: chỉ định output format (JSON, Markdown, template), đảm bảo parse được.
TechniqueNoteEffect
Role setting"Bạn là senior FE engineer"Tăng quality domain answer
Few-shotCho 2-3 input-output exampleModel hiểu format + style
Chain of Thought"Suy nghĩ từng bước"Tăng accuracy reasoning phức tạp
Output constraint"Trả lời JSON"Output parse được
Negative instruction"Đừng bịa info không chắc"Giảm hallucination

4. Interaction: UX của AI era

AI-native sinh nhiều pattern mới. Traditional UX = "click-wait-view", AI app = "dialogue-observe-adjust".

AI 原生交互模式
点击卡片,体验每种 AI 交互模式的效果
💬
流式输出
逐字生成,即时反馈
智能加载态
分阶段展示处理进度
📊
置信度指示
展示 AI 的确定程度
🛡️
优雅降级
不确定时的兜底策略

4 core interaction pattern

  1. Streaming: AI gen content hiện từng chữ, không chờ gen hết. Giảm perceived waiting time, user judge direction sớm.
  2. Multi-turn: dialogue liên tục qua context memory, user refine progressively. Challenge: context window management + history compression.
  3. Multimodal: support text, image, voice, file. AI cũng output image, code, table.
  4. Agentic: AI không chỉ answer, mà tự plan + execute multi-step task. User cho goal, AI tự breakdown + complete.

5. Request flow: 1 AI call lifecycle

User gửi message trong AI app, background xảy ra gì? Hiểu full flow = foundation build reliable AI app.

AI 应用请求处理流程
点击"发送请求",观察一次 AI 请求的完整生命周期
👤
用户输入
User Input
🔧
预处理
Preprocessing
🧠
模型推理
Model Inference
🛡️
后处理
Post-processing
💬
响应输出
Response
💡 关键洞察: AI 应用的请求链路比传统应用更长,模型推理通常占总耗时的 60-80%。 优化重点在于:Prompt 缓存、流式输出、异步处理。

6 stage processing

  1. Input preprocess: validate user input, content safety, sensitive info redact
  2. Context assembly: ghép system prompt + retrieve relevant doc (RAG) + load history
  3. Model call: send assembled prompt tới LLM API, open streaming
  4. Output postprocess: format, content safety filter, extract structured data
  5. Cache: cache common question result, giảm cost + latency
  6. Monitor: log token usage, response time, user feedback → continuous optimize
StageKeyCommon issue
Input preprocessInjection protection, length limitPrompt injection, jailbreak
Context assemblyToken budget, info priorityContext overflow, key info truncated
Model callTimeout, retry, streamingAPI rate limit, network timeout
Output postprocessFormat check, hallucination detectOutput format không match
CacheSemantic vs exact cacheHit rate thấp
MonitoringCost monitor, quality evalToken cost out of control

Tổng kết

AI-native design không phải chỉ đắp AI lên traditional, mà refactor toàn diện về architecture, interaction, engineering.

Key:

  1. Architecture shift: từ deterministic logic → probabilistic reasoning
  2. Design principle: embrace uncertainty, progressive trust, transparent, human-AI collab, graceful degradation
  3. Prompt là core: "programming language" của AI app, quyết product quality
  4. Interaction revolution: streaming, multi-turn, multimodal, Agent — redefine UX
  5. Full-chain thinking: từ input preprocess đến monitoring, mỗi mắt xích design riêng cho AI

2026 cho VN dev

  • Streaming là must: dùng Server-Sent Events (SSE) hoặc WebSocket cho UX tốt
  • Generative UI: Vercel AI SDK, Vercel v0 — AI gen UI component dynamic
  • Cost monitor: LangSmith, Helicone, Langfuse track cost + quality
  • Eval framework: Promptfoo, Braintrust auto eval prompt
  • Safety: Llama Guard, OpenAI Moderation API check input/output
  • VN case: build CS bot e-commerce → dùng RAG với product DB + structured output cho recommendations
  • Bài tập: clone Cursor mini — IDE-like editor + chat sidebar + streaming

Tài liệu