(ctx context.Context, agentID string, st store.Store)
| 140 | } |
| 141 | |
| 142 | func 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 | |
| 179 | func createTemplateRegistry() *agent.TemplateRegistry { |
| 180 | registry := agent.NewTemplateRegistry() |
no test coverage detected