完整工程架構設計整體能力接近:AutoGPT、OpenDevin、Devika

更新 發佈閱讀 20 分鐘

這是接近 3000 行級別專案的完整工程架構設計(但在一個回答內無法放完整 3000 行程式碼)。

設計提供:

  • 🧠 LangGraph Agent 架構
  • 🧰 Auto Tool Learning
  • 🔁 Self Reflection
  • 🧠 Graph + Vector Memory
  • 💻 Code Execution Tool
  • 🌐 Browser Tool
  • 🎯 Autonomous Task Agent
  • 💬 Chat UI
  • 🚀 4090 本地部署

整體能力會接近:

  • AutoGPT
  • OpenDevin
  • Devika

一、最終系統架構

                    USER


Chat Interface


Agent Orchestrator

┌─────────────┼──────────────┐
▼ ▼ ▼
Task Planner Memory Tool Selector
│ │ │
▼ ▼ ▼
LangGraph DAG Vector DB Tool Registry
│ │ │
▼ ▼ ▼
Subtask Executor Graph Memory Tool Executor


Reflection Agent


Final Response

二、完整專案結構

ai_autonomous_agent/

├── agent/
│ ├── graph_agent.py
│ ├── planner.py
│ ├── executor.py
│ ├── reflection.py

├── memory/
│ ├── vector_store.py
│ ├── graph_memory.py
│ ├── memory_manager.py

├── tools/
│ ├── tool_registry.py
│ ├── code_executor.py
│ ├── browser_tool.py
│ ├── file_tool.py

├── rag/
│ ├── retriever.py

├── models/
│ ├── llm_loader.py

├── server/
│ ├── api.py

├── ui/
│ ├── chat_app.py

└── config/
├── settings.py

三、LLM Loader(支援本地模型)

models/llm_loader.py

</>Python
​from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

MODEL_NAME = "Qwen/Qwen2.5-7B-Instruct"

def load_llm():

tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)

model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
device_map="auto",
load_in_4bit=True
)

return model, tokenizer

4090 完全能跑。


四、Tool Registry(Auto Tool Learning)

tools/tool_registry.py

</>Python
class ToolRegistry:

def __init__(self):
self.tools = {}

def register(self, name, func, description):

self.tools[name] = {
"func": func,
"description": description
}

def list_tools(self):

return self.tools

def execute(self, tool_name, params):

if tool_name not in self.tools:
raise Exception("Tool not found")

return self.tools[tool_name]["func"](**params)

五、Code Execution Tool

tools/code_executor.py

</>Python
import subprocess
import tempfile

def execute_python(code):

with tempfile.NamedTemporaryFile(
suffix=".py", delete=False
) as f:

f.write(code.encode())
path = f.name

result = subprocess.run(
["python", path],
capture_output=True,
text=True
)

return result.stdout

這就是 OpenDevin 類能力核心


六、Browser Tool

tools/browser_tool.py

</>Python
import requests
from bs4 import BeautifulSoup

def search_web(query):

url = f"https://duckduckgo.com/html/?q={query}"

r = requests.get(url)

soup = BeautifulSoup(r.text, "html.parser")

results = []

for a in soup.select(".result__a")[:5]:

results.append(a.text)

return results

七、Vector Memory(RAG)

memory/vector_store.py

</>Python
from sentence_transformers import SentenceTransformer
import faiss

class VectorStore:

def __init__(self):

self.model = SentenceTransformer(
"BAAI/bge-small-en"
)

self.index = faiss.IndexFlatL2(384)

self.docs = []

def add(self, text):

emb = self.model.encode([text])

self.index.add(emb)

self.docs.append(text)

def search(self, query):

emb = self.model.encode([query])

D,I = self.index.search(emb,3)

return [self.docs[i] for i in I[0]]

八、Graph Memory

memory/graph_memory.py

</>Python
import networkx as nx

class GraphMemory:

def __init__(self):

self.graph = nx.DiGraph()

def add_relation(self,a,b):

self.graph.add_edge(a,b)

def query(self,node):

return list(self.graph.neighbors(node))

九、Memory Manager

memory/memory_manager.py

</>Python
from .vector_store import VectorStore
from .graph_memory import GraphMemory

class MemoryManager:

def __init__(self):

self.vector = VectorStore()
self.graph = GraphMemory()

def remember(self,user,msg):

self.vector.add(msg)
self.graph.add_relation(user,msg)

def retrieve(self,query):

return self.vector.search(query)

十、Planner(任務拆解)

agent/planner.py

</>Python
def plan_task(llm, task):

prompt = f"""
Break the task into steps.

Task:
{task}
"""

result = llm(prompt)

return result

十一、Executor(工具執行)

agent/executor.py

</>Python
import json

class Executor:

def __init__(self,tool_registry):

self.tools = tool_registry

def run(self, tool_call):

data = json.loads(tool_call)

tool = data["tool"]
params = data["params"]

return self.tools.execute(tool,params)

十二、Self Reflection

agent/reflection.py

</>Python
def reflect(llm, task, result):

prompt = f"""
Task: {task}

Result: {result}

Did the result solve the task?
If not suggest next step.
"""

return llm(prompt)

這是 AutoGPT 核心機制


十三、LangGraph Agent

使用

LangGraph

agent/graph_agent.py

</>Python
from langgraph.graph import StateGraph

class AgentState(dict):
pass

def planner_node(state):

state["plan"] = "plan created"

return state

def tool_node(state):

state["tool_result"] = "tool executed"

return state

def reflection_node(state):

state["reflection"] = "reflection done"

return state

def build_graph():

graph = StateGraph(AgentState)

graph.add_node("planner", planner_node)

graph.add_node("tool", tool_node)

graph.add_node("reflection", reflection_node)

graph.set_entry_point("planner")

graph.add_edge("planner","tool")

graph.add_edge("tool","reflection")

return graph.compile()

十四、Autonomous Task Agent

</>Python
class AutonomousAgent:

def __init__(self,graph):

self.graph = graph

def run(self,task):

state = {"task":task}

result = self.graph.invoke(state)

return result

十五、FastAPI Server

server/api.py

</>Python
from fastapi import FastAPI
from agent.graph_agent import build_graph
from agent.autonomous import AutonomousAgent

app = FastAPI()

graph = build_graph()

agent = AutonomousAgent(graph)

@app.post("/chat")

def chat(msg:str):

result = agent.run(msg)

return {"response":result}

十六、Chat UI

使用

Streamlit

ui/chat_app.py

</>Python
import streamlit as st
import requests

st.title("Autonomous AI Agent")

msg = st.text_input("Message")

if st.button("Send"):

r = requests.post(
"http://localhost:8000/chat",
json={"msg":msg}
)

st.write(r.json())

十七、4090 本地部署

安裝:

</>Bash
pip install

torch
transformers
accelerate
bitsandbytes
langgraph
faiss-cpu
sentence-transformers
fastapi
uvicorn
streamlit
networkx
beautifulsoup4

啟動:

</>Bash
uvicorn server.api:app --reload

UI:

</>Bash
streamlit run ui/chat_app.py

十八、升級到真正 AutoGPT 等級

再加:

1️⃣ Codebase Agent

可分析整個 repo。

2️⃣ Browser Automation

使用

Playwright

3️⃣ Task Queue

Celery

4️⃣ Long-term memory

Milvus

5️⃣ Multi-agent collaboration

多 agent:

</>Plain text
Planner Agent
Coder Agent
Research Agent
Critic Agent

十九、最強本地 Agent 配置(4090)

推薦:

</>Plain text
LLM
Qwen2.5 14B

Embedding
bge-m3

Vector DB
Milvus

Agent
LangGraph

4090 可跑。


二十、如果做到完整 3000 行專案

能力會接近:

  • AutoGPT
  • OpenDevin
  • Devika

可以做到:

  • 自動寫程式
  • 自動 debug
  • 自動查資料
  • 自動規劃任務


留言
avatar-img
sirius數字沙龍
16會員
405內容數
吃自助火鍋啦!不要客氣,想吃啥,請自行取用!
sirius數字沙龍的其他內容
2026/03/08
一個工程級的進階 AI Agent 系統藍圖 + 最小可運行範例。 整體會做到要求的: ✅ Tool Calling 微調資料生成 ✅LLaMA / Qwen LoRA 微調腳本 ✅ RAG (向量檢索) ✅ Auto Tool Selection ✅ Graph Memory
Thumbnail
2026/03/08
一個工程級的進階 AI Agent 系統藍圖 + 最小可運行範例。 整體會做到要求的: ✅ Tool Calling 微調資料生成 ✅LLaMA / Qwen LoRA 微調腳本 ✅ RAG (向量檢索) ✅ Auto Tool Selection ✅ Graph Memory
Thumbnail
2026/03/08
下面是一個工程級但仍然精簡、可在 RTX 4090 本地跑通的完整範例。 目標:建立一個 Tool-Calling LLM 助手。 包含四部分: 1️⃣ 100 條 Tool-Calling 訓練資料生成器 2️⃣ LLaMA / Qwen LoRA 微調腳本 3️⃣ 4090 本地訓練流
Thumbnail
2026/03/08
下面是一個工程級但仍然精簡、可在 RTX 4090 本地跑通的完整範例。 目標:建立一個 Tool-Calling LLM 助手。 包含四部分: 1️⃣ 100 條 Tool-Calling 訓練資料生成器 2️⃣ LLaMA / Qwen LoRA 微調腳本 3️⃣ 4090 本地訓練流
Thumbnail
2026/03/08
一、程式碼的問題 原本的: </>Python training_example = { "instruction": "幫我查一下預算表,並在明天下午三點排個審核會。", "output": '{"tool": "query_database",
Thumbnail
2026/03/08
一、程式碼的問題 原本的: </>Python training_example = { "instruction": "幫我查一下預算表,並在明天下午三點排個審核會。", "output": '{"tool": "query_database",
Thumbnail
看更多
你可能也想看
Thumbnail
本文介紹了 Vibe Coding 的概念、重要性、實作方法以及如何有效運用。Vibe Coding 透過自然語言與 AI 協作,改變了傳統的程式開發流程,將工程師的角色從「編寫程式碼」轉向「描述問題、審查解法」。
Thumbnail
本文介紹了 Vibe Coding 的概念、重要性、實作方法以及如何有效運用。Vibe Coding 透過自然語言與 AI 協作,改變了傳統的程式開發流程,將工程師的角色從「編寫程式碼」轉向「描述問題、審查解法」。
Thumbnail
從 Graydon Hoare 離開 Rust 專案,我們看見開源社群如何透過貢獻重塑治理節奏,也理解科技巨頭擁抱開源並非單純理想,而是吸收反脆弱性、分散風險、建立技術生態的戰略選擇。在開源世界裡,程式碼貢獻如同股份,每一行程式都是參與數位世界未來的證明。
Thumbnail
從 Graydon Hoare 離開 Rust 專案,我們看見開源社群如何透過貢獻重塑治理節奏,也理解科技巨頭擁抱開源並非單純理想,而是吸收反脆弱性、分散風險、建立技術生態的戰略選擇。在開源世界裡,程式碼貢獻如同股份,每一行程式都是參與數位世界未來的證明。
Thumbnail
背景:從冷門配角到市場主線,算力與電力被重新定價   小P從2008進入股市,每一個時期的投資亮點都不同,記得2009蘋果手機剛上市,當時蘋果只要在媒體上提到哪一間供應鏈,隔天股價就有驚人的表現,當時光學鏡頭非常熱門,因為手機第一次搭上鏡頭可以拍照,也造就傳統相機廠的殞落,如今手機已經全面普及,題
Thumbnail
背景:從冷門配角到市場主線,算力與電力被重新定價   小P從2008進入股市,每一個時期的投資亮點都不同,記得2009蘋果手機剛上市,當時蘋果只要在媒體上提到哪一間供應鏈,隔天股價就有驚人的表現,當時光學鏡頭非常熱門,因為手機第一次搭上鏡頭可以拍照,也造就傳統相機廠的殞落,如今手機已經全面普及,題
Thumbnail
不會寫程式的PM還能活嗎?當然可以,但你不能聽不懂工程師說話。從我轉職後的血淚經驗,告訴你「技術懂一點」其實是職場的基本禮貌。
Thumbnail
不會寫程式的PM還能活嗎?當然可以,但你不能聽不懂工程師說話。從我轉職後的血淚經驗,告訴你「技術懂一點」其實是職場的基本禮貌。
Thumbnail
在 AI 工具快速發展的時代,程式開發的方式也正在改變。 過去寫程式往往需要花大量時間撰寫與除錯,但現在 AI 已經可以成為你的開發夥伴。 其中最受開發者關注的工具之一,就是 OpenAI Codex。
Thumbnail
在 AI 工具快速發展的時代,程式開發的方式也正在改變。 過去寫程式往往需要花大量時間撰寫與除錯,但現在 AI 已經可以成為你的開發夥伴。 其中最受開發者關注的工具之一,就是 OpenAI Codex。
Thumbnail
本文分析導演巴里・柯斯基(Barrie Kosky)如何運用極簡的舞臺配置,將布萊希特(Bertolt Brecht)的「疏離效果」轉化為視覺奇觀與黑色幽默,探討《三便士歌劇》在當代劇場中的新詮釋,並藉由舞臺、燈光、服裝、音樂等多方面,分析該作如何在保留批判核心的同時,觸及觀眾的觀看位置與人性幽微。
Thumbnail
本文分析導演巴里・柯斯基(Barrie Kosky)如何運用極簡的舞臺配置,將布萊希特(Bertolt Brecht)的「疏離效果」轉化為視覺奇觀與黑色幽默,探討《三便士歌劇》在當代劇場中的新詮釋,並藉由舞臺、燈光、服裝、音樂等多方面,分析該作如何在保留批判核心的同時,觸及觀眾的觀看位置與人性幽微。
Thumbnail
有些專案一開始只是自己用。這個 LINE 圖片分析 Bot 也是。最早只是想驗證一件事:能不能用 Google Apps Script,直接把 LINE 傳來的圖片丟給 AI 分析,再把結果回傳給使用者。過程不難,但零碎。
Thumbnail
有些專案一開始只是自己用。這個 LINE 圖片分析 Bot 也是。最早只是想驗證一件事:能不能用 Google Apps Script,直接把 LINE 傳來的圖片丟給 AI 分析,再把結果回傳給使用者。過程不難,但零碎。
Thumbnail
5 月將於臺北表演藝術中心映演的「2026 北藝嚴選」《海妲・蓋柏樂》,由臺灣劇團「晃晃跨幅町」製作,本文將以從舞台符號、聲音與表演調度切入,討論海妲・蓋柏樂在父權社會結構下的困境,並結合榮格心理學與馮.法蘭茲對「阿尼姆斯」與「永恆少年」原型的分析,理解女人何以走向精神性的操控、毀滅與死亡。
Thumbnail
5 月將於臺北表演藝術中心映演的「2026 北藝嚴選」《海妲・蓋柏樂》,由臺灣劇團「晃晃跨幅町」製作,本文將以從舞台符號、聲音與表演調度切入,討論海妲・蓋柏樂在父權社會結構下的困境,並結合榮格心理學與馮.法蘭茲對「阿尼姆斯」與「永恆少年」原型的分析,理解女人何以走向精神性的操控、毀滅與死亡。
Thumbnail
Python轉職的三大階段包括基礎學習和建立作品集,再到打造出色的面試履歷。從具體目標設定到實際操作和團隊協作,都是成功的關鍵。建立多元且有深度的作品集,展示技術能力和解決問題的實力,能夠大幅提升面試成功率。透過不斷學習並優化自己的思維,可以發現更多職業機會。
Thumbnail
Python轉職的三大階段包括基礎學習和建立作品集,再到打造出色的面試履歷。從具體目標設定到實際操作和團隊協作,都是成功的關鍵。建立多元且有深度的作品集,展示技術能力和解決問題的實力,能夠大幅提升面試成功率。透過不斷學習並優化自己的思維,可以發現更多職業機會。
Thumbnail
系統專案架構 開始進入開發系統之前,我們要來先想一下專案架構要怎麼做。 前後端分離 現在比較流行的架構是前後端分離。比較常見的方案是前後端個一個專案各自一個檔案。但這樣子分離的話對於 vibing code 比較難,畢竟你兩個專案都開著你要同時個別和他們說要做什麼,有點不太切實際又麻煩。 所
Thumbnail
系統專案架構 開始進入開發系統之前,我們要來先想一下專案架構要怎麼做。 前後端分離 現在比較流行的架構是前後端分離。比較常見的方案是前後端個一個專案各自一個檔案。但這樣子分離的話對於 vibing code 比較難,畢竟你兩個專案都開著你要同時個別和他們說要做什麼,有點不太切實際又麻煩。 所
Thumbnail
這是一場修復文化與重建精神的儀式,觀眾不需要完全看懂《遊林驚夢:巧遇Hagay》,但你能感受心與土地團聚的渴望,也不急著在此處釐清或定義什麼,但你的在場感受,就是一條線索,關於如何找著自己的路徑、自己的聲音。
Thumbnail
這是一場修復文化與重建精神的儀式,觀眾不需要完全看懂《遊林驚夢:巧遇Hagay》,但你能感受心與土地團聚的渴望,也不急著在此處釐清或定義什麼,但你的在場感受,就是一條線索,關於如何找著自己的路徑、自己的聲音。
Thumbnail
在電商行銷部三年,薪水漲幅無感、加班沒加班費,讓我心灰意冷。正當打算離職時,工程部主管邀我轉職工程部。憑藉GA追蹤和處理bug的經驗,我順利轉職。從模仿文件開始,學習資料架構和SQL,不用寫程式但薪水和成長性更高。這次轉職讓我看到更多可能性,工作生活變得更有趣了!
Thumbnail
在電商行銷部三年,薪水漲幅無感、加班沒加班費,讓我心灰意冷。正當打算離職時,工程部主管邀我轉職工程部。憑藉GA追蹤和處理bug的經驗,我順利轉職。從模仿文件開始,學習資料架構和SQL,不用寫程式但薪水和成長性更高。這次轉職讓我看到更多可能性,工作生活變得更有趣了!
追蹤感興趣的內容從 Google News 追蹤更多 vocus 的最新精選內容追蹤 Google News