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

推荐订阅源

量子位
F
Fortinet All Blogs
小众软件
小众软件
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
有赞技术团队
有赞技术团队
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
A
About on SuperTechFans
I
InfoQ
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog

博客园 - 荣锋亮

pg-boss 基于pg 的node 队列job 服务 Omnigres 基于pg的开发平台 zerofs 支持native kernel client multigres pg 版的Vitess drizzle-duckdb duckdb drizzle orm client dumbodb 面向文档db 的版本管理db doltlite sqlite 的版本控制 doltgresql pg 的dolt 服务 TokenHub 基于golang 的llm proxy 服务 duckgres PostHog 开源的通过pg协议暴露duckdb服务能力 jenkins 2.568.1 publish over ssh java.lang.NoSuchMethodError: 'java.lang.Object jenkins.plugins.publish_over_ssh.BapSshHostConfiguration 问题 scriptc vercel 开源的ts 转native 编译器 itty-router 轻量的microrouter drizzle-proxy 格式简单说明 drizzle-proxy 简单说明 duckdb iceberg rest catalog连接的一个问题 supabase wrappers pg 扩展服务 ice 运行简单说明 pgnats pg 的nats 扩展 ice 轻量iceberg rest catalog 服务 zerofs v2.1.0 支持无缝的ha 以及恢复了 liteparse 的可视化引用 VaultS3 与zerofs 集成测试 VaultS3 一个轻量的s3 兼容服务 liteparse-server liteparse rest&grpc服务 smoothdb 兼容postgrest的服务 fluxbase 基于golang 开发的兼容supabase的服务 pg_durable 微软开源的基于pg 的持久运行扩展 liteparse ocr api 规范 基于litserve 以及RapidOCR扩展一个liteparse ocr 服务
llama-agents 的resource对象
荣锋亮 · 2026-05-14 · via 博客园 - 荣锋亮

llama-agents 的resource对象从定位来说就是可以注入外部依赖可以方便在step中复用共享,为了方便处理,同时还提供了一个基于json 配置的resource配置,而且resource 以及resourceconfig 可以组合使用

参考玩法

  • resource
def get_memory(*args, **kwargs):
    return Memory.from_defaults("user_id_123", token_limit=60000)


class SecondEvent(Event):
    msg: str


class WorkflowWithResource(Workflow):
    @step
    async def first_step(
        self,
        ev: StartEvent,
        memory: Annotated[Memory, Resource(get_memory)],
    ) -> SecondEvent:
        print("Memory before step 1", memory)
        await memory.aput(
            ChatMessage(role="user", content="This is the first step")
        )
        print("Memory after step 1", memory)
        return SecondEvent(msg="This is an input for step 2")

    @step
    async def second_step(
        self, ev: SecondEvent, memory: Annotated[Memory, Resource(get_memory)]
    ) -> StopEvent:
        print("Memory before step 2", memory)
        await memory.aput(ChatMessage(role="user", content=ev.msg))
        print("Memory after step 2", memory)
        return StopEvent(result="Messages put into memory")
  • 基于配置的
class ClassifierConfig(BaseModel):
    categories: list[str]
    threshold: float


class DocumentClassifier(Workflow):
    @step
    async def classify(
        self,
        ev: StartEvent,
        config: Annotated[
            ClassifierConfig,
            ResourceConfig(config_file="classifier.json"),
        ],
    ) -> StopEvent:
        # config is loaded from classifier.json and validated as ClassifierConfig
        return StopEvent(result=f"Using threshold: {config.threshold}")

说明

resource 实际可以作为存储以及配置管理的一些依赖,效果上相比默认的状态管理,灵活性更方便一些

参考资料

https://developers.llamaindex.ai/python/llamaagents/workflows/resources/