Version: 0.9.65.dev.260503

后端:
1. 阶段 1.5/1.6
收口 llm-service / rag-service,统一模型出口与检索基础设施入口,清退 backend/infra/llm 与 backend/infra/rag 旧实现;
2. 同步更新相关调用链与微服务迁移计划文档
This commit is contained in:
Losita
2026-05-03 23:21:03 +08:00
parent a6c1e5d077
commit 9902ca3563
65 changed files with 550 additions and 376 deletions

View File

@@ -0,0 +1,19 @@
package rerank
import (
"context"
"errors"
"github.com/LoveLosita/smartflow/backend/services/rag/core"
)
// EinoReranker 是 Eino 重排器占位实现。
type EinoReranker struct{}
func NewEinoReranker() *EinoReranker {
return &EinoReranker{}
}
func (r *EinoReranker) Rerank(_ context.Context, _ string, _ []core.ScoredChunk, _ int) ([]core.ScoredChunk, error) {
return nil, errors.New("eino reranker is not implemented yet")
}

View File

@@ -0,0 +1,30 @@
package rerank
import (
"context"
"sort"
"github.com/LoveLosita/smartflow/backend/services/rag/core"
)
// NoopReranker 是默认重排器(仅按原 score 排序)。
type NoopReranker struct{}
func NewNoopReranker() *NoopReranker {
return &NoopReranker{}
}
func (r *NoopReranker) Rerank(_ context.Context, _ string, candidates []core.ScoredChunk, topK int) ([]core.ScoredChunk, error) {
if len(candidates) == 0 {
return nil, nil
}
sorted := make([]core.ScoredChunk, len(candidates))
copy(sorted, candidates)
sort.SliceStable(sorted, func(i, j int) bool {
return sorted[i].Score > sorted[j].Score
})
if topK <= 0 || topK >= len(sorted) {
return sorted, nil
}
return sorted[:topK], nil
}