refactor(mcp-go): 拆除 search.Hybrid 残骸(T4.F)
- search.Hybrid 空转(NewHybrid 返空、Query 返 nil TODO)、构造后存进 Gateway 却从不被调用(真实 RAG 走 rag.Engine)→ 纯误导性死重量 - 删 internal/search 包 + gateway.go 字段/构造参数 + main.go 接线 - build/vet 干净;wiki_search 不受影响(本就用 g.rag) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/mcp"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/search"
|
||||
|
||||
"github.com/sundynix/sundynix-shared/otelx"
|
||||
"github.com/sundynix/sundynix-shared/prompts"
|
||||
@@ -58,8 +57,7 @@ func main() {
|
||||
defer b.Close()
|
||||
log.Printf("[mcp_go] connected %s", natsURL)
|
||||
|
||||
engine := search.NewHybrid() // LLM Wiki 混合检索:Bleve + Milvus + Neo4j
|
||||
mem := memory.Open(pgDSN) // 偏好记忆:sundynix_user_profile(连不上则降级)
|
||||
mem := memory.Open(pgDSN) // 偏好记忆:sundynix_user_profile(连不上则降级)
|
||||
defer mem.Close()
|
||||
hist := history.Open(redisAddr) // 会话短期历史:Redis(连不上则降级)
|
||||
defer hist.Close()
|
||||
@@ -104,7 +102,7 @@ func main() {
|
||||
log.Printf("[mcp_go] subscribe prompts: %v", err)
|
||||
}
|
||||
|
||||
gw := mcp.NewGateway(b, engine, mem, hist, ragEngine, pgDSN)
|
||||
gw := mcp.NewGateway(b, mem, hist, ragEngine, pgDSN)
|
||||
|
||||
log.Println("[mcp_go] serving MCP over sundynix.tools.go.* (Ctrl-C to quit)")
|
||||
if err := gw.Serve(ctx); err != nil && err != context.Canceled {
|
||||
|
||||
@@ -21,13 +21,11 @@ import (
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/office"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
||||
"github.com/sundynix/sundynix-mcp-go/internal/search"
|
||||
)
|
||||
|
||||
// Gateway 暴露 MCP 协议端点,经共享 bus 订阅 sundynix.tools.go.* 响应调用。
|
||||
type Gateway struct {
|
||||
bus *sharedbus.Bus
|
||||
search *search.Hybrid
|
||||
memory *memory.Store
|
||||
history *history.Store
|
||||
rag *rag.Engine
|
||||
@@ -60,8 +58,8 @@ type toolDef struct {
|
||||
handler func(context.Context, *contract.ToolCall) *contract.ToolResult
|
||||
}
|
||||
|
||||
func NewGateway(b *sharedbus.Bus, s *search.Hybrid, m *memory.Store, h *history.Store, r *rag.Engine, pgDSN string) *Gateway {
|
||||
g := &Gateway{bus: b, search: s, memory: m, history: h, rag: r, pgDSN: pgDSN}
|
||||
func NewGateway(b *sharedbus.Bus, m *memory.Store, h *history.Store, r *rag.Engine, pgDSN string) *Gateway {
|
||||
g := &Gateway{bus: b, memory: m, history: h, rag: r, pgDSN: pgDSN}
|
||||
g.tools = g.buildRegistry()
|
||||
return g
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Package search 实现 LLM Wiki 混合检索引擎。
|
||||
// Hybrid Search = Bleve(全文/BM25) + Milvus(向量) + Neo4j(知识图谱) 融合排序。
|
||||
package search
|
||||
|
||||
import "context"
|
||||
|
||||
// Hybrid 聚合三路检索后端并做 RRF/加权融合。
|
||||
type Hybrid struct {
|
||||
// bleve *bleve.Index // Go 全文检索
|
||||
// milvus client.Client // Vector DB (Milvus Go SDK)
|
||||
// neo4j neo4j.DriverWithContext // Knowledge Graph
|
||||
}
|
||||
|
||||
func NewHybrid() *Hybrid {
|
||||
// TODO: 打开 bleve 索引;连接 Milvus;连接 Neo4j
|
||||
return &Hybrid{}
|
||||
}
|
||||
|
||||
// Result 是融合后的检索结果。
|
||||
type Result struct {
|
||||
ID string
|
||||
Score float64
|
||||
Text string
|
||||
}
|
||||
|
||||
// Query 并行查询三路后端并融合排序。
|
||||
func (h *Hybrid) Query(ctx context.Context, q string, topK int) ([]Result, error) {
|
||||
// TODO: 并发 bleve.Search + milvus.Search + neo4j Cypher,做 RRF 融合
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user