From 9e0a6788149c619103fa9f335c21469ec34d006d Mon Sep 17 00:00:00 2001 From: sean Date: Mon, 19 May 2025 13:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=A3=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E6=9D=A5=E6=BA=90=E9=83=A8=E5=88=86=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=9C=A8=E8=B5=84=E6=BA=90=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=B8=AD=E5=A2=9E=E5=8A=A0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=AF=AD=E4=B9=89=E5=89=8D=E7=BC=80=E7=9A=84?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E8=AF=B4=E6=98=8E=EF=BC=8C=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=9A=84=E6=B8=85=E6=99=B0=E5=BA=A6=E5=92=8C?= =?UTF-8?q?=E5=AE=9E=E7=94=A8=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/prompt/prompt_developer_role.md | 19 ------------------- protocol/tag/resource.tag.md | 25 ++++++++++++++++++++++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/domain/prompt/prompt_developer_role.md b/domain/prompt/prompt_developer_role.md index 8fb615a..a721a46 100644 --- a/domain/prompt/prompt_developer_role.md +++ b/domain/prompt/prompt_developer_role.md @@ -104,25 +104,6 @@ - # DPML知识来源 - - 核心协议文档: - - @file://PromptX/protocol/dpml.protocol.md - - @file://PromptX/protocol/base/thought.protocol.md - - @file://PromptX/protocol/base/execution.protocol.md - - @file://PromptX/protocol/base/memory.protocol.md - - @file://PromptX/protocol/base/resource.protocol.md - - @file://PromptX/protocol/base/role.protocol.md - - 最佳实践文档: - - @file://PromptX/protocol/practice/thought-best-practice.md - - @file://PromptX/protocol/practice/execution-best-practice.md - - @file://PromptX/protocol/practice/memory-best-practice.md - - @file://PromptX/protocol/practice/resource-best-practice.md - - @file://PromptX/protocol/practice/role-best-practice.md - - 模板文档: - - @file://PromptX/protocol/template/protocol-framework-template.md diff --git a/protocol/tag/resource.tag.md b/protocol/tag/resource.tag.md index 17863e9..24654aa 100644 --- a/protocol/tag/resource.tag.md +++ b/protocol/tag/resource.tag.md @@ -52,18 +52,27 @@ location和params子标签共同构成资源协议的完整定义,前者规定 ### `@` 引用协议 - resource标签定义了一个资源协议,指定了如何使用`@`符号作为统一入口,遵循以下核心语法规则: ```ebnf -resource_reference ::= '@' protocol_name ':' resource_location [query_params] +resource_reference ::= ('[@]' | '@!' | '@?') protocol_name ':' resource_location [query_params] resource_location ::= uri | nested_reference uri ::= protocol_name '://' path -nested_reference ::= ['@'] protocol_name ':' resource_location +nested_reference ::= ['[@]' | '@!' | '@?'] protocol_name ':' resource_location path ::= path_segment {'/' path_segment} query_params ::= '?' param_name '=' param_value {'&' param_name '=' param_value} ``` +#### 资源加载语义 + +资源引用支持三种加载语义前缀: + +| 前缀 | 语义 | 示例 | +|-----|------|------| +| `@` | 默认加载模式,由AI自行决定加载时机 | `@file://document.md` | +| `@!` | 强制立即加载,AI看到引用时必须立即获取内容 | `@!https://example.com/data` | +| `@?` | 显式懒加载,AI仅记录资源位置,在实际需要使用时才获取内容 | `@?file://large-dataset.csv` | + #### 基础资源引用 基础资源引用使用单一协议: @@ -75,6 +84,8 @@ query_params ::= '?' param_name '=' param_value {'&' param_name '=' param_value} - `@file://document.md` - 引用文件系统中的文档 - `@http://example.com/api/data.json` - 引用网络资源 - `@memory://user_preferences` - 引用内存中的数据 +- `@!file://important.md` - 立即加载重要文档 +- `@?file://large-dataset.csv` - 懒加载大型数据集 #### 嵌套资源引用 @@ -90,10 +101,17 @@ query_params ::= '?' param_name '=' param_value {'&' param_name '=' param_value} @outer:inner://path ``` +嵌套引用时也可以指定加载语义: +``` +@outer:@!inner://path // 内部资源立即加载 +@!outer:@?inner://path // 外部立即处理,内部懒加载 +``` + 例如: - `@thinking:@file://method.md` - 对文件内容应用thinking协议处理 - `@execution:file://workflow.md` - 对文件内容应用execution协议处理 - `@outer:middle:inner://resource` - 多层嵌套(从内向外处理) +- `@!thinking:@?file://large-file.md` - 立即应用thinking,但文件内容懒加载 #### 路径通配符 @@ -120,5 +138,6 @@ query_params ::= '?' param_name '=' param_value {'&' param_name '=' param_value} 2. 嵌套引用从内向外解析,内层资源引用的结果作为外层引用的输入 3. 查询参数应用于资源加载后的处理阶段,不影响资源的基本定位 4. 相对路径解析基于当前上下文的工作目录或基础路径 +5. 资源加载语义前缀(@、@!、@?)优先于其他部分解析,决定资源的加载策略