MCPcopy Create free account
hub / github.com/astercloud/aster / demonstrateBuilderPattern

Function demonstrateBuilderPattern

examples/recipe/main.go:105–133  ·  view source on GitHub ↗

演示 Builder 模式

()

Source from the content-addressed store, hash-verified

103
104// 演示 Builder 模式
105func demonstrateBuilderPattern() {
106 fmt.Println("\n📋 Builder 模式创建 Recipe")
107 fmt.Println(repeatStr("-", 50))
108
109 // 使用 Builder 创建 Recipe
110 r, err := recipe.NewBuilder().
111 Title("Writing Assistant").
112 Description("帮助撰写和编辑文档的 AI 助手").
113 Instructions(`你是一个专业的写作助手。你擅长:
114- 文章撰写和润色
115- 语法和风格检查
116- 结构优化建议
117- 多语言翻译`).
118 Prompt("请帮我改进这篇文章的结构和表达。").
119 Tools("Read", "Write", "Search").
120 PermissionMode(recipe.PermissionSmartApprove).
121 Build()
122
123 if err != nil {
124 log.Fatalf("创建 Recipe 失败: %v", err)
125 }
126
127 fmt.Printf(" ✓ 使用 Builder 创建 Recipe\n")
128 fmt.Printf("\n 📖 Recipe 信息:\n")
129 fmt.Printf(" 标题: %s\n", r.Title)
130 fmt.Printf(" 版本: %s\n", r.Version)
131 fmt.Printf(" 工具: %v\n", r.Tools)
132 fmt.Printf(" 权限模式: %s\n", r.PermissionMode)
133}
134
135// 演示 MCP 扩展
136func demonstrateMCPExtensions(tmpDir string) {

Callers 1

mainFunction · 0.85

Calls 10

NewBuilderFunction · 0.92
PermissionModeMethod · 0.80
InstructionsMethod · 0.80
TitleMethod · 0.80
PrintfMethod · 0.80
repeatStrFunction · 0.70
BuildMethod · 0.65
ToolsMethod · 0.65
PromptMethod · 0.65
DescriptionMethod · 0.65

Tested by

no test coverage detected