成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

臨交工兩周,智能體演示全盤血崩!大牛頓悟:我只是做了個花式提示詞鏈!血淚重構血淚總結:AI智能體的五個進階等級(附完整代碼實現)

原創 精選
人工智能
不僅僅是串聯 API 調用,而是要管理狀態、決策、以及長流程控制。當這個邏輯打通后,一切都變得簡單了:代碼更清晰,邏輯更合理,結果更靠譜。這篇文章的目標,就是將智能體的設計拆解成五個難度等級,每一層都有對應的工作代碼。

編譯 | 云昭

作者 | Paolo Perrone

出品 | 51CTO技術棧(微信號:blog51cto)

在距離產品大限還有兩周時,我的智能體原型徹底崩了。

表面上看,它沒什么問題:能抓取數據、調用工具、還能解釋它的執行步驟。但其實全是裝的。它沒有狀態、沒有記憶、也沒有推理能力,只是用循環提示詞假裝自己很聰明。

直到一個邊界情況讓它徹底懵掉時,我才發現:我沒造出“智能體”,只是搞了一個花哨的提示詞鏈。

要修復它,我必須徹底重構——

不僅僅是串聯 API 調用,而是要管理狀態、決策、以及長流程控制。

當這個邏輯打通后,一切都變得簡單了:代碼更清晰,邏輯更合理,結果更靠譜。

這篇文章的目標,就是將智能體的設計拆解成五個難度等級,每一層都有對應的工作代碼。

不管你是剛起步,還是正在擴展真實業務,這篇文章都能幫你避開本人曾經踩過的坑,造出真正靠譜的 Agent。

一、構建智能體的 5 個等級

大家都知道,奧特曼對于 AGI 做了 5 級規劃,其中 Agent 屬于第三級別,現在,我們也把 Agent 的等級水平分為 5 級,看看你能實現哪一個層級。我把智能體分成以下五級:

Level 1:具備工具調用能力的智能體

Level 2:擁有知識檢索和記憶功能的智能體

Level 3:具備長期記憶和推理能力的智能體

Level 4:多智能體團隊協作

Level 5:智能體系統化部署

1.Level 1:工具 + 指令驅動的智能體

這是最基礎的版本——一個能執行指令并循環調用工具的 LLM。人們說的“Agent 就是 LLM + 工具調用”,指的就是這個層級(也側面說明他們探索得不深)。

指令告訴 Agent 要干嘛,工具讓它能動手做事:抓數據、調用 API、觸發流程等。雖然簡單,但已經可以實現不少自動化任務了。

from agno.agent import Agent 
from agno.models.openai import OpenAIChat 
from agno.tools.duckduckgo import DuckDuckGoTools

agno_assist = Agent(
  name="Agno AGI",
  model=0penAIChat(id="gpt-4.1"),
  descriptinotallow=dedent("""\
  You are "Agno AGI, an autonomous AI Agent that can build agents using the Agno)
  framework. Your goal is to help developers understand and use Agno by providing 
  explanations, working code examples, and optional visual and audio explanations
  of key concepts."""),
  instructinotallow="Search the web for information about Agno.",
  tools=[DuckDuckGoTools()],
  add_datetime_to_instructinotallow=True, 
  markdown=True,
)
  agno_assist.print_response("What is Agno?", stream=True)

2.Level 2:有知識 + 記憶能力的智能體

現實中大多數任務,LLM 本身的知識都不夠用。不能把所有內容都塞進 prompt,所以 Agent 需要能在運行時調用外部知識庫——這就涉及agentic RAG 或 動態 few-shot 提示。

最理想的方式是混合檢索(全文 + 語義)+ rerank 重排,這是目前 agent 檢索的最佳方案。

此外,持久化存儲讓 Agent 擁有記憶。LLM 本身是無狀態的,但通過記錄歷史對話和行為,它就能變成“有記憶”的狀態智能體。

... imports
# You can also use https://docs.agno.com/llms-full.txt for the full documentation
knowledge_base = UrlKnowledge(
  urls=["https://docs.agno.com/introduction.md"],
  vector_db=LanceDb(
    uri="tmp/lancedb",
    table_name="agno_docs",
    search_type=SearchType.hybrid,
    embedder=0penAIEmbedder(id="text-embedding-3-small"),
    reranker=CohereReranker(model="rerank-multilingual-v3.0"),
  ),
)
storage = SqliteStorage(table_name="agent_sessions", db_file="tmp/agent.db")

agno_assist = Agent(
  name="Agno AGI",
  model=OpenAIChat(id="gpt-4.1"),
  descriptinotallow=..., 
  instructinotallow=...,
  tools=[PythonTools(), DuckDuckGoTools()],
  add_datetime_to_instructinotallow=True,
# Agentic RAG is enabled by default when 'knowledge' is provided to the Agent.
  knowledge=knowledge_base,
# Store Agent sessions in a sqlite database
  storage=storage,
# Add the chat history to the messages
  add_history_to_messages=True,
# Number of history runs
  num_history_runs=3, 
  markdown=True,
)

if __name_ == "__main__":
# Load the knowledge base, comment after first run
# agno_assist.knovledge.load(recreate=True)
  agno _assist.print_response("What is Agno?", stream=True)

3.Level 3:長期記憶 + 推理能力的智能體

長期記憶意味著 Agent 能記住跨會話的信息,比如用戶偏好、過去執行失敗的任務,從而逐漸適應用戶和上下文。這就開啟了個性化和持續改進的可能性。

推理能力則是進一步升級——讓 Agent 更擅長拆解任務、做決策、處理多步驟任務。不僅能“理解”,還能提升任務完成率。

... imports

knowledge_base = ...

memory = Memory(
# Use any model for creating nemories
  model=0penAIChat(id="gpt-4.1"),
  db=SqliteMemoryDb(table_name="user_menories", db_file="tmp/agent.db"),
  delete_memories=True, 
  clear_memories=True,
)

  storage =

agno_assist = Agent(
  name="Agno AGI",
  model=Claude (id="claude-3-7-sonnet-latest"),
# User for the memories
  user_id="ava", 
  descriptinotallow=..., 
  instructinotallow=...,
# Give the Agent the ability to reason
  tools=[PythonTools(), DuckDuckGoTools(), 
  ReasoningTools(add_instructinotallow=True)],
  ...
# Store memories in a sqlite database
  memory=memory,
# Let the Agent manage its menories
  enable_agentic_memory=True,
)

if __name__ == "__main__":
# You can comment this out after the first run and the agent will remember
  agno_assist.print_response("Always start your messages with 'hi ava'", stream=True)
  agno_assist.print_response("What is Agno?", stream=True)

4.Level 4:多智能體團隊

最有效的 Agent 往往是專注的:在某一垂類擅長任務,配有有限(<10 個)的專用工具。

如果任務更復雜,就需要多個 Agent 協作。每個智能體負責一塊子任務,團隊一起解決更大的問題。

但問題是:缺乏推理能力的“團隊領導”會在復雜問題上一團亂。目前大多數自主多智能體系統仍然不穩定,成功率不到一半。

框架層面的支持可以緩解這點,例如 Agno 提供的三種執行模式:協調(coordinate)、路由(route)、協作(collaborate),搭配內建記憶和上下文管理,能大大提高可行性。

... imports

web agent = Agent(
  name="Web Search Agent",  
  role="Handle web search requests", 
  model= OpenAIChat(id="gpt-4o-mini"),
  tools=[DuckDuckGoTools()],
  instructinotallow="Always include sources",
)

finance_agent= Agent(
  name="Finance Agent",
  role="Handle financial data requests",
  model=OpenAIChat(id="gpt-4o-mini"),
  tools=[YFinanceTools()],
  instructinotallow=[
    "You are a financial data specialist. Provide concise and accurate data.",
    "Use tables to display stock prices, fundamentals (P/E, Market Cap)",
  ],
)


team_leader = Team (
  name="Reasoning Finance Team Leader", 
  mode="coordinate",
  model=Claude(id="claude-3-7-sonnet-latest"),
  members=[web_agent, finance_agent],
  tools=[ReasoningTools(add_instructinotallow=True)],
  instructinotallow=[
    "Use tables to display data",
    "Only output the final answer, no other text.",
  ],
  show_members_respnotallow=True, 
  enable_agentic_cnotallow=True, 
  add_datetime_to_instructinotallow=True,
  success_criteria="The team has successfully completed the task.",
)


if __name__ == "__main__":
  team_leader.print_response(
    """\
    Analyze the impact of recent US tariffs on market performance across
these key sectors:
- Steel & Aluminum: (X, NUE, AA)
- Technology Hardware: (AAPL, DELL, HPQ)

For each sector:
1. Compare stock performance before and after tariff implementation
2. Identify supply chain disruptions and cost impact percentages
3. Analyze companies' strategic responses (reshoring, price adjustments, supplier
diversification)""",
  stream=True, 
  stream_intermediate_steps=True, 
  show_full_reasnotallow=True,
)

5.Level 5:智能體系統化(Agentic Systems)

到了這個級別,Agent 不再是“功能”或“助手”,而是整個系統的核心基礎設施。

Agentic Systems 就是全棧 API 系統——用戶發起請求,系統異步啟動任務,并在中途持續返回結果。

聽起來很酷,做起來很難。

你得做這些事:

  • 請求一來就持久化狀態
  • 啟動后臺任務并跟蹤進度
  • 實時推送輸出結果
  • 建立 websocket 或等效機制來流式更新

很多團隊都低估了后端系統的復雜性。

要真正讓 Agent 落地為產品,你得從架構層做起,不只是“做個功能”。

二、從失敗演示到真實落地:Agent 構建的關鍵教訓

構建 AI Agent,不是疊 buzzword,不是玩“框架競賽”,而是搞清楚基本功。

從最簡單的工具使用,到異步系統集成,每一步都必須建立在扎實的設計之上。

絕大多數失敗都不是因為缺了框架,而是沒打好基礎:邊界不清晰、推理不可靠、記憶設計混亂、或是不知道何時應該讓“人”來接手。

建議:從簡單開始,按需加復雜性,不預先堆太多結構。你就不會只造出個“酷玩意”,而是造出真正可用的智能體系統。

參考鏈接:https://medium.com/data-science-collective/ai-agents-in-5-levels-of-difficulty-with-full-code-implementation-15d794becfb8

責任編輯:武曉燕 來源: 51CTO技術棧
相關推薦

2025-07-03 06:39:16

2023-12-29 16:33:12

大規模語言模型人工智能

2025-05-14 07:00:00

智能體自主式AI

2025-05-20 08:00:45

2025-06-19 03:30:00

智能體DifyMCP

2024-11-26 00:14:08

2025-05-06 08:23:56

Llama 4AutoGenAI智能體

2024-11-18 19:06:21

2025-04-28 08:29:04

AIMCP智能體

2025-04-25 01:10:00

智能體AI人工智能

2023-07-05 15:18:42

AI自動駕駛

2025-05-28 02:00:00

AI智能體文本

2024-01-29 01:26:22

AI進程GAAM

2025-04-07 02:00:00

2013-01-10 09:53:40

智能手表PebbleCES 2013

2022-08-18 15:08:16

智能AI

2024-11-29 20:41:21

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲精品视频一区 | 黄色片在线网站 | 久久国产精品久久久久久 | 午夜精品久久久久久久久久久久久 | 国产激情一区二区三区 | 久久久久亚洲 | 国产欧美精品一区二区三区 | 亚洲狠狠爱 | 五月婷婷亚洲 | 五月天婷婷综合 | 成人片免费看 | 成人一区二区视频 | 国产伦精品一区二区三区精品视频 | www九色 | 欧美精品欧美精品系列 | 国产精品综合色区在线观看 | 国产探花在线精品一区二区 | 成人高清在线 | 麻豆av在线免费观看 | 婷婷久久久久 | 亚洲精品自在在线观看 | 国产一级久久久久 | 国产美女一区二区三区 | 99免费精品 | 成人片免费看 | 欧美片网站免费 | 欧美小视频在线观看 | 亚洲精品日韩在线 | 国产美女在线精品免费 | 国产精品福利在线观看 | 一a一片一级一片啪啪 | 日韩在线视频一区二区三区 | 日韩黄a| 亚洲36d大奶网 | 91在线中文字幕 | 欧美精品欧美精品系列 | 日韩成人中文字幕 | 成人午夜激情 | 精品一区二区观看 | 亚洲成人精品国产 | 久久精品中文字幕 |