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

Function demonstrateSearch

examples/session-enhanced/main.go:142–177  ·  view source on GitHub ↗
(ctx context.Context, agentID string, st store.Store)

Source from the content-addressed store, hash-verified

140}
141
142func demonstrateSearch(ctx context.Context, agentID string, st store.Store) {
143 // 创建搜索器
144 searcher := session.NewSearcher(session.SearcherConfig{
145 Store: st,
146 })
147
148 // 搜索示例
149 searchQueries := []string{
150 "Paris",
151 "food",
152 "Eiffel",
153 }
154
155 for _, query := range searchQueries {
156 fmt.Printf("Searching for: '%s'\n", query)
157
158 results, err := searcher.SearchHistory(ctx, session.SearchOptions{
159 Query: query,
160 AgentID: agentID,
161 Limit: 3,
162 MatchMode: "contains",
163 })
164
165 if err != nil {
166 log.Printf("Search failed: %v", err)
167 continue
168 }
169
170 fmt.Printf("Found %d results:\n", len(results))
171 for i, result := range results {
172 fmt.Printf(" %d. [Relevance: %.2f] %s\n",
173 i+1, result.Relevance, truncate(result.Snippet, 80))
174 }
175 fmt.Println()
176 }
177}
178
179func createTemplateRegistry() *agent.TemplateRegistry {
180 registry := agent.NewTemplateRegistry()

Callers 1

mainFunction · 0.85

Calls 4

SearchHistoryMethod · 0.95
NewSearcherFunction · 0.92
PrintfMethod · 0.80
truncateFunction · 0.70

Tested by

no test coverage detected