mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-08-29 02:04:30 +08:00
chore(cli): adapt ListKnowledgeChunks interface to variadic chunk_type filter
Upstream commit 5c0243cd ("feat: Support filtering chunks by multiple
chunk_type params") extended client.Client.ListKnowledgeChunks with a
trailing `chunkTypes ...string` variadic. The two narrow service
interfaces in cli/ — ListService in cli/cmd/chunk/list.go and
chunkListService in cli/internal/mcp/tools.go — plus the two fake
implementations in their *_test.go siblings, are updated to match so
*client.Client continues to satisfy them via duck typing.
No CLI flag surfaced yet; both call sites pass no filter and behavior
is unchanged. Exposing `--chunk-type` as a flag on `weknora chunk list`
and as an input field on the MCP `chunk_list` tool is a candidate for a
follow-up commit, per the broader SDK-required → CLI-required alignment
discussion.
Pre-flight: go build ./... clean; go test -count=1 ./... 28/28 packages
pass; go vet ./... clean; gofmt -l . empty.
This commit is contained in:
@@ -36,7 +36,7 @@ var chunkListFields = []string{
|
||||
|
||||
// ListService is the narrow SDK surface this command depends on.
|
||||
type ListService interface {
|
||||
ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int) ([]sdk.Chunk, int64, error)
|
||||
ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int, chunkTypes ...string) ([]sdk.Chunk, int64, error)
|
||||
}
|
||||
|
||||
type ListOptions struct {
|
||||
|
||||
@@ -28,7 +28,7 @@ type fakeListSvc struct {
|
||||
callIdx int
|
||||
}
|
||||
|
||||
func (f *fakeListSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int) ([]sdk.Chunk, int64, error) {
|
||||
func (f *fakeListSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int, _ ...string) ([]sdk.Chunk, int64, error) {
|
||||
f.calls = append(f.calls, listCall{docID, page, pageSize})
|
||||
defer func() { f.callIdx++ }()
|
||||
if f.callIdx >= len(f.pages) {
|
||||
|
||||
@@ -92,7 +92,7 @@ type agentService interface {
|
||||
// separate from knowledgeService because the chunk subtree is its own
|
||||
// domain on the server side (/api/v1/chunks/...).
|
||||
type chunkListService interface {
|
||||
ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int) ([]sdk.Chunk, int64, error)
|
||||
ListKnowledgeChunks(ctx context.Context, knowledgeID string, page, pageSize int, chunkTypes ...string) ([]sdk.Chunk, int64, error)
|
||||
}
|
||||
|
||||
// agentInvokeService composes the two SDK methods agent_invoke needs
|
||||
|
||||
@@ -128,7 +128,7 @@ func (f *fakeSvc) AgentQAStreamWithRequest(_ context.Context, sess string, req *
|
||||
}
|
||||
return f.agentStreamErr
|
||||
}
|
||||
func (f *fakeSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int) ([]sdk.Chunk, int64, error) {
|
||||
func (f *fakeSvc) ListKnowledgeChunks(_ context.Context, docID string, page, pageSize int, _ ...string) ([]sdk.Chunk, int64, error) {
|
||||
f.calls.chunkDocID = docID
|
||||
f.calls.chunkPage = page
|
||||
f.calls.chunkPageSize = pageSize
|
||||
|
||||
Reference in New Issue
Block a user