MCPcopy Create free account
hub / github.com/diillson/chatcli / Search

Method Search

cli/knowledge_adapter.go:54–72  ·  view source on GitHub ↗

Search runs hybrid retrieval and renders cited passages.

(query, kb string, topK int)

Source from the content-addressed store, hash-verified

52
53// Search runs hybrid retrieval and renders cited passages.
54func (a *knowledgePluginAdapter) Search(query, kb string, topK int) (string, error) {
55 mgr := a.manager()
56 if mgr == nil {
57 return "", fmt.Errorf("context manager unavailable in this session")
58 }
59 if topK <= 0 {
60 topK = ctxmgr.DefaultRetrievalTopK
61 }
62 if topK > knowledgeSearchMaxTopK {
63 topK = knowledgeSearchMaxTopK
64 }
65 ctx, cancel := context.WithTimeout(context.Background(), knowledgeOpTimeout)
66 defer cancel()
67 hits, err := mgr.KnowledgeSearch(ctx, a.sessionID(), kb, query, topK)
68 if err != nil {
69 return "", err
70 }
71 return ctxmgr.FormatKnowledgeHits(query, hits), nil
72}
73
74// Get returns one page of a document plus explicit pagination guidance.
75func (a *knowledgePluginAdapter) Get(source, kb string, offset int) (string, error) {

Calls 5

managerMethod · 0.95
sessionIDMethod · 0.95
FormatKnowledgeHitsFunction · 0.92
ErrorfMethod · 0.80
KnowledgeSearchMethod · 0.80