惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
小众软件
小众软件
F
Fortinet All Blogs
爱范儿
爱范儿
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
C
Check Point Blog
博客园 - 聂微东
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
宝玉的分享
宝玉的分享
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
用FROST写一个你的第一个Agent,只用10分钟
llimage · 2026-06-28 · via DEV Community

llimage

用FROST写一个你的第一个Agent,只用10分钟

你好,FROST

周末好!今天不聊深奥的理论,就来点实际的:手把手教你用FROST写一个会聊天的Agent

整个过程只需要10分钟,代码不超过30行。

什么是FROST?

先简单介绍一下。FROST是一个教学用的轻量Agent框架,只有500行代码,核心概念只有三个:

  • Agent:执行者
  • Skill:技能(类似函数)
  • Store:记忆(存储上下文)

听起来简单?没错,它就是为你设计的——让你从第一行代码开始,就清楚地知道自己在做什么。

GitHub: https://gitee.com/liao_liang_7514/frost

开始之前

你需要:

  • Python 3.10+
  • 一颗想学习的心

安装FROST:

pip install frost-ai

或者直接clone源码:

git clone https://gitee.com/liao_liang_7514/frost.git

实战:写一个"翻译助手"

让我们写一个简单的翻译Agent。它能接收中文,翻译成英文。

第一步:定义技能

from frost import Skill, Store, Agent

class TranslateSkill(Skill):
    """翻译技能"""
    def __call__(self, store, text, target_lang="en"):
        # 这里你可以接入任何翻译API
        # 为了演示,我们用一个简单的mock
        translations = {
            ("你好", "en"): "Hello",
            ("今天天气怎么样", "en"): "How is the weather today?",
            ("再见", "en"): "Goodbye"
        }
        result = translations.get((text, target_lang), f"[翻译中] {text}")
        store.set("last_translation", result)
        return result

看到了吗?Skill就是一个普通的Python类,继承Skill,实现__call__方法。

第二步:创建Agent

# 创建记忆存储
store = Store()

# 把技能交给Agent
agent = Agent(skills=[TranslateSkill()], store=store)

# 运行!
response = agent.run("你好")
print(response)  # 输出: Hello

完整的代码就这些:

from frost import Skill, Store, Agent

class TranslateSkill(Skill):
    def __call__(self, store, text, target_lang="en"):
        translations = {
            ("你好", "en"): "Hello",
            ("今天天气怎么样", "en"): "How is the weather today?",
        }
        return translations.get((text, target_lang), f"[翻译中] {text}")

store = Store()
agent = Agent(skills=[TranslateSkill()], store=store)
print(agent.run("你好"))

30行代码,一个翻译Agent就这么跑起来了。

为什么选FROST?

可能有同学会问:我直接用LangChain不就好了吗?

好问题。对比一下:

对比项 LangChain FROST
代码量 几十万行 500行
上手难度 😰 较高 ✅ 轻松
理解底层 😰 很难 ✅ 一目了然
适用场景 生产开发 学习原理

FROST不是用来替代LangChain的。

它的定位是:让你理解Agent是怎么工作的

当你用FROST弄懂了Agent的核心逻辑,再去用LangChain,会发现"原来那些API背后是这么回事"——学习效率翻倍。

还能做什么?

目前FROST已经有几个现成的示例:

1. 搜索助手

class SearchSkill(Skill):
    def __call__(self, store, query):
        result = web_search(query)
        store.set("last_search", result)
        return result

2. 记忆助手

# Store可以存储Agent的"记忆"
store.set("user_name", "小明")
store.set("user_preference", "喜欢简洁的设计")

3. 多技能组合

agent = Agent(
    skills=[SearchSkill(), TranslateSkill()],
    store=store
)
# Agent会自动选择合适的技能完成任务

写给想深入的你

FROST的源码非常适合作为学习材料。

整个框架的核心代码在这里:

frost/
├── agent.py      # Agent主体 (~100行)
├── skill.py      # Skill基类 (~50行)
├── store.py      # Store存储 (~50行)
└── __init__.py   # 导出接口 (~20行)

你可以一边读源码,一边改代码,看看会发生什么。学习 Agent 最好的方式就是自己动手实现一个。

工程版预告

如果你觉得FROST的教学理念有意思,想看看"同样思想在生产环境长什么样"——

FROST-SOP 即将开源!

FROST-SOP是基于FROST思想打造的工程级Agent开发平台,包含完整的企业级功能(FROST-SOP Gitee仓库正在筹备中)。

  • FROST:教学框架,揭示本质
  • FROST-SOP:工程平台,用于生产

两者共享同样的设计哲学:分形架构 + 家族治理

写在最后

周末抽10分钟,给自己一个小挑战:

试着修改上面的翻译Agent,让它支持更多语言,或者添加一个新技能(比如"计算字数")。

学习编程最好的方式就是动手写代码。

如果你完成了,欢迎在评论区分享你的作品!


如果你喜欢这种轻松的学习风格,欢迎关注并转发。

Tags: #AI #Agent #Python #开源 #教程 #FROST