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

Method search

pkg/middleware/logic_memory_tools.go:172–196  ·  view source on GitHub ↗
(ctx context.Context, namespace string, input map[string]any)

Source from the content-addressed store, hash-verified

170}
171
172func (t *LogicMemoryQueryTool) search(ctx context.Context, namespace string, input map[string]any) (string, error) {
173 memoryType, ok := input["type"].(string)
174 if !ok || memoryType == "" {
175 return "", errors.New("type is required for 'search' action")
176 }
177
178 filters := []logic.Filter{logic.WithType(memoryType)}
179
180 if minConf, ok := input["min_confidence"].(float64); ok {
181 filters = append(filters, logic.WithMinConfidence(minConf))
182 }
183
184 limit := 10
185 if l, ok := input["limit"].(float64); ok {
186 limit = int(l)
187 }
188 filters = append(filters, logic.WithTopK(limit))
189
190 memories, err := t.manager.RetrieveMemories(ctx, namespace, filters...)
191 if err != nil {
192 return "", fmt.Errorf("failed to search memories: %w", err)
193 }
194
195 return t.formatMemoriesAsMarkdown(memories), nil
196}
197
198func (t *LogicMemoryQueryTool) stats(ctx context.Context, namespace string) (string, error) {
199 stats, err := t.manager.GetStats(ctx, namespace)

Callers 6

ExecuteMethod · 0.95
MemoryResourceClass · 0.80
client.test.tsFile · 0.80
memory.test.tsFile · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 5

WithTypeFunction · 0.92
WithMinConfidenceFunction · 0.92
WithTopKFunction · 0.92
RetrieveMemoriesMethod · 0.80

Tested by

no test coverage detected