(ctx context.Context, namespace string, input map[string]any)
| 129 | } |
| 130 | |
| 131 | func (t *LogicMemoryQueryTool) list(ctx context.Context, namespace string, input map[string]any) (string, error) { |
| 132 | // 构建过滤器 |
| 133 | filters := []logic.Filter{} |
| 134 | |
| 135 | if scope, ok := input["scope"].(string); ok && scope != "" { |
| 136 | filters = append(filters, logic.WithScope(logic.MemoryScope(scope))) |
| 137 | } |
| 138 | |
| 139 | if minConf, ok := input["min_confidence"].(float64); ok { |
| 140 | filters = append(filters, logic.WithMinConfidence(minConf)) |
| 141 | } |
| 142 | |
| 143 | limit := 10 |
| 144 | if l, ok := input["limit"].(float64); ok { |
| 145 | limit = int(l) |
| 146 | } |
| 147 | filters = append(filters, logic.WithTopK(limit)) |
| 148 | |
| 149 | // 检索 Memory |
| 150 | memories, err := t.manager.RetrieveMemories(ctx, namespace, filters...) |
| 151 | if err != nil { |
| 152 | return "", fmt.Errorf("failed to retrieve memories: %w", err) |
| 153 | } |
| 154 | |
| 155 | return t.formatMemoriesAsMarkdown(memories), nil |
| 156 | } |
| 157 | |
| 158 | func (t *LogicMemoryQueryTool) get(ctx context.Context, namespace string, input map[string]any) (string, error) { |
| 159 | key, ok := input["key"].(string) |
no test coverage detected