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

Method stats

pkg/middleware/logic_memory_tools.go:198–226  ·  view source on GitHub ↗
(ctx context.Context, namespace string)

Source from the content-addressed store, hash-verified

196}
197
198func (t *LogicMemoryQueryTool) stats(ctx context.Context, namespace string) (string, error) {
199 stats, err := t.manager.GetStats(ctx, namespace)
200 if err != nil {
201 return "", fmt.Errorf("failed to get stats: %w", err)
202 }
203
204 var builder strings.Builder
205 builder.WriteString("## Logic Memory Statistics\n\n")
206 builder.WriteString(fmt.Sprintf("- **Total Memories**: %d\n", stats.TotalCount))
207 builder.WriteString(fmt.Sprintf("- **Average Confidence**: %.1f%%\n", stats.AverageConfidence*100))
208 builder.WriteString(fmt.Sprintf("- **Last Updated**: %s\n\n", stats.LastUpdated.Format("2006-01-02 15:04:05")))
209
210 if len(stats.CountByType) > 0 {
211 builder.WriteString("### By Type\n")
212 for memType, count := range stats.CountByType {
213 builder.WriteString(fmt.Sprintf("- %s: %d\n", memType, count))
214 }
215 builder.WriteString("\n")
216 }
217
218 if len(stats.CountByScope) > 0 {
219 builder.WriteString("### By Scope\n")
220 for scope, count := range stats.CountByScope {
221 builder.WriteString(fmt.Sprintf("- %s: %d\n", scope, count))
222 }
223 }
224
225 return builder.String(), nil
226}
227
228func (t *LogicMemoryQueryTool) formatMemoriesAsMarkdown(memories []*logic.LogicMemory) string {
229 if len(memories) == 0 {

Callers 1

ExecuteMethod · 0.95

Calls 2

GetStatsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected