refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s

- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
runny committed 2026-11-13 20:52:51 +08:00
1 parent 9097ee699d
commit 9058149576
3136 files changed
+18018 -18004

No files matched your search

@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -7,8 +7,8 @@ import (
"fmt"
"sort"
"github.com/Tencent/WeKnora/internal/application/attachment"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/application/attachment"
"academy/internal/types"
"gorm.io/gorm"
)
@@ -7,8 +7,8 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/application/attachment"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/application/attachment"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,8 +4,8 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/common"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -6,7 +6,7 @@ import (
"os"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -4,7 +4,7 @@ import (
"context"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// ListImageAssets returns one page of a knowledge base's images from
@@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"gorm.io/driver/postgres"
@@ -15,13 +15,13 @@ import (
)
// imageAssetBackends runs fn against in-memory SQLite and, when
// WEKNORA_REPOSITORY_TEST_POSTGRES_DSN points at a disposable database, against
// ACADEMY_REPOSITORY_TEST_POSTGRES_DSN points at a disposable database, against
// PostgreSQL too — the gallery query is spelled differently per dialect, so
// both spellings need the same assertions. For example:
//
// docker run -d --rm -e POSTGRES_PASSWORD=pg -e POSTGRES_DB=weknora -p 55432:5432 \
// docker run -d --rm -e POSTGRES_PASSWORD=pg -e POSTGRES_DB=academy -p 55432:5432 \
// paradedb/paradedb:v0.25.11-pg17
// WEKNORA_REPOSITORY_TEST_POSTGRES_DSN=postgres://postgres:pg@localhost:55432/weknora?sslmode=disable
// ACADEMY_REPOSITORY_TEST_POSTGRES_DSN=postgres://postgres:pg@localhost:55432/academy?sslmode=disable
//
// Both runs apply the real chunk_images migration, so the triggers and the
// backfill under test are the ones that ship.
@@ -32,9 +32,9 @@ func imageAssetBackends(t *testing.T, fn func(t *testing.T, db *gorm.DB)) {
fn(t, db)
})
t.Run("postgres", func(t *testing.T) {
dsn := os.Getenv("WEKNORA_REPOSITORY_TEST_POSTGRES_DSN")
dsn := os.Getenv("ACADEMY_REPOSITORY_TEST_POSTGRES_DSN")
if dsn == "" {
t.Skip("set WEKNORA_REPOSITORY_TEST_POSTGRES_DSN to run the PostgreSQL gallery query")
t.Skip("set ACADEMY_REPOSITORY_TEST_POSTGRES_DSN to run the PostgreSQL gallery query")
}
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
require.NoError(t, err)
@@ -6,7 +6,7 @@ import (
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/postgres"
"gorm.io/gorm"
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
@@ -7,7 +7,7 @@ import (
"time"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
@@ -18,9 +18,9 @@ func TestSyncLogRetentionPerSource(t *testing.T) {
t.Run(backend, func(t *testing.T) {
dialect := sqlite.Open(":memory:")
if backend == "postgres" {
dsn := os.Getenv("WEKNORA_REPOSITORY_TEST_POSTGRES_DSN")
dsn := os.Getenv("ACADEMY_REPOSITORY_TEST_POSTGRES_DSN")
if dsn == "" {
t.Skip("set WEKNORA_REPOSITORY_TEST_POSTGRES_DSN for PostgreSQL sync log retention tests")
t.Skip("set ACADEMY_REPOSITORY_TEST_POSTGRES_DSN for PostgreSQL sync log retention tests")
}
dialect = postgres.Open(dsn)
}
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -7,7 +7,7 @@ import (
"time"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/common"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -8,7 +8,7 @@ import (
"testing"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/common"
"academy/internal/types"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -7,7 +7,7 @@ import (
"time"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -3,7 +3,7 @@ package repository
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -87,7 +87,7 @@ func reloadKB(t *testing.T, db *gorm.DB, id string) types.KnowledgeBase {
}
// TestKnowledgeBase_VectorStoreID_Save_Immutable verifies that db.Save(kb)
// — which WeKnora's UpdateKnowledgeBase repository path uses today — does
// — which Academy's UpdateKnowledgeBase repository path uses today — does
// NOT overwrite the vector_store_id column, thanks to the GORM
// `<-:create` tag. This is the primary automated defense for the H1 review
// finding (silent overwrite of the binding via full-struct UPDATE).
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/google/uuid"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@@ -5,8 +5,8 @@ import (
"sync"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/google/uuid"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@@ -4,8 +4,8 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -5,9 +5,9 @@ import (
"sort"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/logger"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"gorm.io/gorm"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
)
// messageRepository implements the message repository interface
@@ -8,7 +8,7 @@ import (
"gorm.io/gorm"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// Artifacts live in message_artifacts, not on the message row. Every loader in
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
)
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
)
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/gorm"
)
@@ -1,7 +1,7 @@
package repository
import (
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/gorm"
)
@@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+2 -2
View File
@@ -3,8 +3,8 @@ package repository
import (
"context"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -3,7 +3,7 @@ package repository
import (
"context"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// IsReferencedByKnowledgeBase accepts only explicit bindings to live documents.
@@ -8,7 +8,7 @@ import (
"sort"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
)
const envDorisCompatMode = "DORIS_COMPAT_MODE"
@@ -24,7 +24,7 @@ func TestMoveIndicesLegacyUpdatesOnlyExactSourceDocument(t *testing.T) {
repo, mock, _, cleanup := newTestRepo(t)
defer cleanup()
primeCompatMode(repo, dorisCompatModeLegacy, nil)
mock.ExpectExec("UPDATE `weknora_embeddings_2` SET knowledge_base_id = \\?, tag_id = '' WHERE "+
mock.ExpectExec("UPDATE `academy_embeddings_2` SET knowledge_base_id = \\?, tag_id = '' WHERE "+
"knowledge_base_id = \\? AND knowledge_id = \\?").
WithArgs("target", "source", "doc").
WillReturnResult(sqlmock.NewResult(0, 3))
@@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// 字段名常量。Doris 是 SQL 库,字段名要在 SELECT/WHERE/INSERT 多处复用,
@@ -7,14 +7,14 @@ import (
"os"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/logger"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/google/uuid"
)
const (
defaultTableBaseName = "weknora_embeddings"
defaultTableBaseName = "academy_embeddings"
envDorisTablePrefix = "DORIS_TABLE_PREFIX"
)
@@ -14,8 +14,8 @@ import (
"time"
"github.com/DATA-DOG/go-sqlmock"
"github.com/Tencent/WeKnora/internal/types"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/types"
secutils "academy/internal/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -54,8 +54,8 @@ func newTestRepo(t *testing.T) (*dorisRepository, sqlmock.Sqlmock, *httptest.Ser
feHTTPBase: srv.URL,
username: "u",
password: "p",
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
}
cleanup := func() {
@@ -196,11 +196,11 @@ func TestPartialUpdateRows_HappyPath(t *testing.T) {
{"id": "id2", "is_enabled": false},
}
require.NoError(t, repo.partialUpdateRows(context.Background(),
"weknora_embeddings_768", []string{"id", "is_enabled"}, rows))
"academy_embeddings_768", []string{"id", "is_enabled"}, rows))
require.NotNil(t, captured)
assert.Equal(t, http.MethodPut, captured.Method)
assert.Equal(t, "/api/weknora/weknora_embeddings_768/_stream_load", captured.URL.Path)
assert.Equal(t, "/api/academy/academy_embeddings_768/_stream_load", captured.URL.Path)
assert.Equal(t, "true", captured.Header.Get("partial_columns"))
assert.Equal(t, "true", captured.Header.Get("strip_outer_array"))
@@ -348,7 +348,7 @@ func TestDeleteByChunkIDList_SQLShape(t *testing.T) {
repo, mock, _, cleanup := newTestRepo(t)
defer cleanup()
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_768.* WHERE chunk_id IN \(\?, \?\)`).
mock.ExpectExec(`DELETE FROM .*academy_embeddings_768.* WHERE chunk_id IN \(\?, \?\)`).
WithArgs("c1", "c2").
WillReturnResult(sqlmock.NewResult(0, 2))
@@ -371,7 +371,7 @@ func TestVectorRetrieve_SQLShape(t *testing.T) {
defer cleanup()
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings_3").
WithArgs("academy", "academy_embeddings_3").
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(1))
// Doris does not support placeholders for LIMIT, so TopK is inlined as a
@@ -406,7 +406,7 @@ func TestVectorRetrieve_SQLShape_LegacyMode(t *testing.T) {
primeCompatMode(repo, dorisCompatModeLegacy, nil)
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings_3").
WithArgs("academy", "academy_embeddings_3").
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(1))
mock.ExpectQuery(`SELECT id, content, .*cosine_distance_approximate.*HAVING score >= \? ORDER BY score DESC LIMIT \d+`).
@@ -452,9 +452,9 @@ func TestKeywordsRetrieve_SQLShape(t *testing.T) {
defer cleanup()
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings\\_%").
WithArgs("academy", "academy_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).
AddRow("weknora_embeddings_768"))
AddRow("academy_embeddings_768"))
// LIMIT is inlined (see VectorRetrieve), so only is_enabled and the
// MATCH_ANY query string are bound arguments.
@@ -488,25 +488,25 @@ func TestBatchUpdateChunkEnabledStatus_RewritesRows(t *testing.T) {
repo := &dorisRepository{
db: db,
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
}
primeCompatMode(repo, dorisCompatModeInnerProductDuplicate, nil)
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
mock.ExpectQuery(`SELECT id, content, source_id, source_type, chunk_id, knowledge_id, knowledge_base_id, tag_id, is_enabled, embedding FROM .*weknora_embeddings_768.* WHERE chunk_id IN`).
WithArgs("academy", "academy_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
mock.ExpectQuery(`SELECT id, content, source_id, source_type, chunk_id, knowledge_id, knowledge_base_id, tag_id, is_enabled, embedding FROM .*academy_embeddings_768.* WHERE chunk_id IN`).
WithArgs("c1").
WillReturnRows(sqlmock.NewRows([]string{
"id", "content", "source_id", "source_type",
"chunk_id", "knowledge_id", "knowledge_base_id", "tag_id",
"is_enabled", "embedding",
}).AddRow("row-1", "hello", "src1", 0, "c1", "k1", "kb1", "t1", true, "[1,2,3]"))
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_768.* WHERE id IN \(\?\)`).
mock.ExpectExec(`DELETE FROM .*academy_embeddings_768.* WHERE id IN \(\?\)`).
WithArgs("row-1").
WillReturnResult(sqlmock.NewResult(0, 1))
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_768.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
mock.ExpectExec(`INSERT INTO .*academy_embeddings_768.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
WithArgs("row-1", "hello", "src1", 0, "c1", "k1", "kb1", "t1", false).
WillReturnResult(sqlmock.NewResult(0, 1))
@@ -521,9 +521,9 @@ func TestBatchUpdateChunkEnabledStatus_LegacyModeUsesPartialUpdate(t *testing.T)
primeCompatMode(repo, dorisCompatModeLegacy, nil)
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
mock.ExpectQuery(`SELECT id, chunk_id FROM .*weknora_embeddings_768.* WHERE chunk_id IN`).
WithArgs("academy", "academy_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
mock.ExpectQuery(`SELECT id, chunk_id FROM .*academy_embeddings_768.* WHERE chunk_id IN`).
WithArgs("c1").
WillReturnRows(sqlmock.NewRows([]string{"id", "chunk_id"}).AddRow("row-1", "c1"))
@@ -539,8 +539,8 @@ func TestEnsureTable_DDLShape(t *testing.T) {
repo := &dorisRepository{
db: db,
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
bucketsNum: 5,
replicationNum: 2,
}
@@ -548,16 +548,16 @@ func TestEnsureTable_DDLShape(t *testing.T) {
// 表不存在
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings_768").
WithArgs("academy", "academy_embeddings_768").
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(0))
// CREATE TABLE 应包含关键属性和 Doris 支持的 inner_product ANN metric
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*weknora_embeddings_768.*metric_type"="inner_product".*DUPLICATE KEY\(id\).*BUCKETS 5.*replication_num.*=.*2`).
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*academy_embeddings_768.*metric_type"="inner_product".*DUPLICATE KEY\(id\).*BUCKETS 5.*replication_num.*=.*2`).
WillReturnResult(sqlmock.NewResult(0, 0))
// SHOW INDEX 一次即返回 ANN 已 FINISHED
mock.ExpectQuery(`SHOW INDEX FROM .*weknora_embeddings_768.*`).
mock.ExpectQuery(`SHOW INDEX FROM .*academy_embeddings_768.*`).
WillReturnRows(
sqlmock.NewRows([]string{"Table", "Key_name", "State"}).
AddRow("weknora_embeddings_768", "idx_emb", "FINISHED"),
AddRow("academy_embeddings_768", "idx_emb", "FINISHED"),
)
require.NoError(t, repo.ensureTable(context.Background(), 768))
@@ -574,22 +574,22 @@ func TestEnsureTable_DDLShape_LegacyMode(t *testing.T) {
repo := &dorisRepository{
db: db,
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
bucketsNum: 5,
replicationNum: 2,
}
primeCompatMode(repo, dorisCompatModeLegacy, nil)
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings_768").
WithArgs("academy", "academy_embeddings_768").
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(0))
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*weknora_embeddings_768.*metric_type"="cosine_distance".*UNIQUE KEY\(id\).*enable_unique_key_merge_on_write.*true`).
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*academy_embeddings_768.*metric_type"="cosine_distance".*UNIQUE KEY\(id\).*enable_unique_key_merge_on_write.*true`).
WillReturnResult(sqlmock.NewResult(0, 0))
mock.ExpectQuery(`SHOW INDEX FROM .*weknora_embeddings_768.*`).
mock.ExpectQuery(`SHOW INDEX FROM .*academy_embeddings_768.*`).
WillReturnRows(
sqlmock.NewRows([]string{"Table", "Key_name", "State"}).
AddRow("weknora_embeddings_768", "idx_emb", "FINISHED"),
AddRow("academy_embeddings_768", "idx_emb", "FINISHED"),
)
require.NoError(t, repo.ensureTable(context.Background(), 768))
@@ -605,16 +605,16 @@ func TestBatchSave_SQLShape(t *testing.T) {
repo := &dorisRepository{
db: db,
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
}
primeCompatMode(repo, dorisCompatModeInnerProductDuplicate, nil)
repo.initializedTables.Store(3, true) // 跳过 ensureTable
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_3.* WHERE id IN \(\?\)`).
mock.ExpectExec(`DELETE FROM .*academy_embeddings_3.* WHERE id IN \(\?\)`).
WithArgs("src1").
WillReturnResult(sqlmock.NewResult(0, 0))
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
mock.ExpectExec(`INSERT INTO .*academy_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
WithArgs(
"src1", "hello", "src1", 0,
"c1", "k1", "kb1", "",
@@ -648,13 +648,13 @@ func TestBatchSave_SQLShape_LegacyMode(t *testing.T) {
repo := &dorisRepository{
db: db,
database: "weknora",
tableBaseName: "weknora_embeddings",
database: "academy",
tableBaseName: "academy_embeddings",
}
primeCompatMode(repo, dorisCompatModeLegacy, nil)
repo.initializedTables.Store(3, true)
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
mock.ExpectExec(`INSERT INTO .*academy_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
WithArgs(
"src1", "hello", "src1", 0,
"c1", "k1", "kb1", "",
@@ -687,17 +687,17 @@ func TestResolveCompatMode_RejectsExistingModeSwitch(t *testing.T) {
repo.compatModeRequested = dorisCompatModeLegacy
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
mock.ExpectQuery(`SHOW CREATE TABLE .*weknora_embeddings_768.*`).
WithArgs("academy", "academy_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
mock.ExpectQuery(`SHOW CREATE TABLE .*academy_embeddings_768.*`).
WillReturnRows(sqlmock.NewRows([]string{"Table", "Create Table"}).AddRow(
"weknora_embeddings_768",
"CREATE TABLE `weknora_embeddings_768` (id VARCHAR(64)) ENGINE=OLAP DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 10 PROPERTIES(\"replication_num\"=\"1\")",
"academy_embeddings_768",
"CREATE TABLE `academy_embeddings_768` (id VARCHAR(64)) ENGINE=OLAP DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 10 PROPERTIES(\"replication_num\"=\"1\")",
))
_, err := repo.resolveCompatMode(context.Background())
require.Error(t, err)
assert.Contains(t, err.Error(), "not interchangeable after weknora_embeddings_*")
assert.Contains(t, err.Error(), "not interchangeable after academy_embeddings_*")
assert.Contains(t, err.Error(), string(dorisCompatModeInnerProductDuplicate))
assert.NoError(t, mock.ExpectationsWereMet())
}
@@ -708,7 +708,7 @@ func TestResolveCompatMode_AutoPrefersInnerProductDuplicate(t *testing.T) {
repo.compatModeRequested = dorisCompatModeAuto
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
WithArgs("weknora", "weknora_embeddings\\_%").
WithArgs("academy", "academy_embeddings\\_%").
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}))
mock.ExpectQuery(`SELECT inner_product_approximate\(\[1.0\],\[1.0\]\)`).
WillReturnRows(sqlmock.NewRows([]string{"v"}).AddRow(1.0))
@@ -6,7 +6,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
)
// 默认的桶数 / 副本数。Doris 在 PROPERTIES 不指定时会用集群默认值,
@@ -126,7 +126,7 @@ func (r *dorisRepository) createTable(ctx context.Context, tableName string, dim
//
// 关键点:
// - DUPLICATE KEY(id):兼容当前 Doris/SelectDB 对 ANN 索引的表模型要求。
// WeKnora 在 Go 端用 delete + insert 保持按 id 替换的写入语义。
// Academy 在 Go 端用 delete + insert 保持按 id 替换的写入语义。
// - INVERTED 索引覆盖所有过滤字段 + 中文分词的 content 全文索引。
// - ANN 索引使用 HNSW + inner_product;Doris 写入/查询前会对向量单位化,
// 因此整体仍保持与其他向量库一致的 cosine 相似度语义。
@@ -11,8 +11,8 @@ import (
"net/url"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// Stream Load 相关常量。
@@ -4,7 +4,7 @@ import (
"maps"
"slices"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// VectorEmbedding defines the Elasticsearch document structure for vector embeddings
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
typesLocal "github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
typesLocal "academy/internal/types"
"academy/internal/types/interfaces"
"github.com/elastic/go-elasticsearch/v7"
)
@@ -14,11 +14,11 @@ import (
"fmt"
"strings"
elasticsearchRetriever "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
typesLocal "github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
elasticsearchRetriever "academy/internal/application/repository/retriever/elasticsearch"
"academy/internal/config"
"academy/internal/logger"
typesLocal "academy/internal/types"
"academy/internal/types/interfaces"
"github.com/elastic/go-elasticsearch/v7"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/google/uuid"
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
typesLocal "github.com/Tencent/WeKnora/internal/types"
typesLocal "academy/internal/types"
)
// Regression test for #3156: the script_score source must floor the cosine
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
typesLocal "github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
typesLocal "academy/internal/types"
"academy/internal/types/interfaces"
"github.com/elastic/go-elasticsearch/v8"
)
@@ -6,11 +6,11 @@ import (
"fmt"
"strings"
elasticsearchRetriever "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
typesLocal "github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
elasticsearchRetriever "academy/internal/application/repository/retriever/elasticsearch"
"academy/internal/config"
"academy/internal/logger"
typesLocal "academy/internal/types"
"academy/internal/types/interfaces"
"github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/go-elasticsearch/v8/typedapi/core/bulk"
"github.com/elastic/go-elasticsearch/v8/typedapi/core/search"
@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
typesLocal "github.com/Tencent/WeKnora/internal/types"
typesLocal "academy/internal/types"
)
// Regression test for #3156: the script_score source must floor the cosine
@@ -333,7 +333,7 @@ func newCopyMilvusHarness(t *testing.T, rows []copyTestRow) *copyMilvusHarness {
return &copyMilvusHarness{
repo: &milvusRepository{
client: c,
collectionBaseName: "weknora_embeddings",
collectionBaseName: "academy_embeddings",
metricType: entity.IP,
},
fake: fake,
@@ -7,8 +7,8 @@ import (
"os"
"testing"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/logger"
"academy/internal/types"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
@@ -87,7 +87,7 @@ func newKeywordsMilvusHarness(t *testing.T, collections []string,
t.Cleanup(func() { _ = c.Close(context.Background()) })
return &keywordsMilvusHarness{
repo: &milvusRepository{client: c, collectionBaseName: "weknora_embeddings"},
repo: &milvusRepository{client: c, collectionBaseName: "academy_embeddings"},
fake: fake,
}
}
@@ -165,7 +165,7 @@ func captureMilvusLogs(t *testing.T) *bytes.Buffer {
func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T) {
logs := captureMilvusLogs(t)
harness := newKeywordsMilvusHarness(t,
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536", "other_collection"},
[]string{"academy_embeddings_1024", "academy_embeddings_1536", "other_collection"},
func(string) (*milvuspb.SearchResults, error) { return failedMilvusSearch(), nil },
)
@@ -176,7 +176,7 @@ func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T
require.Contains(t, err.Error(), "milvus keyword search unavailable")
require.Nil(t, results, "no result set may accompany the error")
require.Equal(t,
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"}, harness.fake.searches,
[]string{"academy_embeddings_1024", "academy_embeddings_1536"}, harness.fake.searches,
"only base-name collections are searched",
)
require.NotContains(t, logs.String(), "No keyword matches found",
@@ -190,9 +190,9 @@ func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T
func TestMilvusKeywordsRetrieveKeepsResultsWhenOnlySomeCollectionsFail(t *testing.T) {
logs := captureMilvusLogs(t)
harness := newKeywordsMilvusHarness(t,
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"},
[]string{"academy_embeddings_1024", "academy_embeddings_1536"},
func(name string) (*milvuspb.SearchResults, error) {
if name == "weknora_embeddings_1024" {
if name == "academy_embeddings_1024" {
return failedMilvusSearch(), nil
}
return milvusSearchHits("chunk-1", "invoice total 42"), nil
@@ -221,7 +221,7 @@ func TestMilvusKeywordsRetrieveKeepsResultsWhenOnlySomeCollectionsFail(t *testin
// conclusion log still fires.
func TestMilvusKeywordsRetrieveReportsNoMatchesWhenNothingFailed(t *testing.T) {
logs := captureMilvusLogs(t)
harness := newKeywordsMilvusHarness(t, []string{"weknora_embeddings_1024"},
harness := newKeywordsMilvusHarness(t, []string{"academy_embeddings_1024"},
func(string) (*milvuspb.SearchResults, error) { return emptyMilvusSearch(), nil },
)
@@ -240,9 +240,9 @@ func TestMilvusKeywordsRetrieveReportsNoMatchesWhenNothingFailed(t *testing.T) {
func TestMilvusKeywordsRetrieveMarksPartialFailureWhenNothingHit(t *testing.T) {
logs := captureMilvusLogs(t)
harness := newKeywordsMilvusHarness(t,
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"},
[]string{"academy_embeddings_1024", "academy_embeddings_1536"},
func(name string) (*milvuspb.SearchResults, error) {
if name == "weknora_embeddings_1024" {
if name == "academy_embeddings_1024" {
return failedMilvusSearch(), nil
}
return emptyMilvusSearch(), nil
@@ -15,7 +15,7 @@ import (
"github.com/milvus-io/milvus/client/v2/index"
client "github.com/milvus-io/milvus/client/v2/milvusclient"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
)
const defaultMultilingualMigrationBatchSize = 64
@@ -56,7 +56,7 @@ type MigrationSummary struct {
MigratedRows int
}
// MigrateLegacyCollections copies all legacy WeKnora Milvus collections to a
// MigrateLegacyCollections copies all legacy Academy Milvus collections to a
// new multilingual collection base. Existing dense vectors are reused; only
// Milvus's BM25 sparse vectors are regenerated from content and language.
//
@@ -11,22 +11,22 @@ import (
)
func TestCollectionDimensionForBase(t *testing.T) {
dimension, ok := collectionDimensionForBase("weknora_embeddings_1536", "weknora_embeddings")
dimension, ok := collectionDimensionForBase("academy_embeddings_1536", "academy_embeddings")
require.True(t, ok)
require.Equal(t, 1536, dimension)
_, ok = collectionDimensionForBase("weknora_embeddings_multilingual_1536", "weknora_embeddings")
_, ok = collectionDimensionForBase("academy_embeddings_multilingual_1536", "academy_embeddings")
require.False(t, ok)
_, ok = collectionDimensionForBase("weknora_embeddings", "weknora_embeddings")
_, ok = collectionDimensionForBase("academy_embeddings", "academy_embeddings")
require.False(t, ok)
_, ok = collectionDimensionForBase("weknora_embeddings_1536_backup", "weknora_embeddings")
_, ok = collectionDimensionForBase("academy_embeddings_1536_backup", "academy_embeddings")
require.False(t, ok)
require.True(t, matchesDimensionCollection(
"weknora_embeddings_multilingual_1536",
"weknora_embeddings_multilingual",
"academy_embeddings_multilingual_1536",
"academy_embeddings_multilingual",
))
require.False(t, matchesDimensionCollection("weknora_embeddings_1536", "weknora_embeddings_multilingual"))
require.False(t, matchesDimensionCollection("academy_embeddings_1536", "academy_embeddings_multilingual"))
}
func TestParseMetricType(t *testing.T) {
@@ -15,15 +15,15 @@ import (
"github.com/milvus-io/milvus/client/v2/index"
client "github.com/milvus-io/milvus/client/v2/milvusclient"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/logger"
"academy/internal/types"
"academy/internal/types/interfaces"
)
const (
envMilvusCollection = "MILVUS_COLLECTION"
envMilvusMetricType = "MILVUS_METRIC_TYPE"
defaultCollectionName = "weknora_embeddings"
defaultCollectionName = "academy_embeddings"
fieldSourceID = "source_id"
fieldSourceType = "source_type"
fieldChunkID = "chunk_id"
@@ -83,7 +83,7 @@ func (m *milvusRepository) getCollectionName(dimension int) string {
}
// collectionAnalyzerMode inspects a collection once and caches whether it
// uses the multilingual schema. Older WeKnora collections do not have the
// uses the multilingual schema. Older Academy collections do not have the
// language field, so they must continue using the legacy upsert and search
// paths until they are migrated.
func (m *milvusRepository) collectionAnalyzerMode(
@@ -142,7 +142,7 @@ func (m *milvusRepository) ensureCollection(ctx context.Context, dimension int)
// Define schema
schema := &entity.Schema{
CollectionName: collectionName,
Description: fmt.Sprintf("WeKnora embeddings collection with dimension %d", dimension),
Description: fmt.Sprintf("Academy embeddings collection with dimension %d", dimension),
AutoID: false,
Fields: []*entity.Field{
entity.NewField().
@@ -230,7 +230,7 @@ func (m *milvusRepository) ensureCollection(ctx context.Context, dimension int)
log.Infof("[Milvus] Successfully created collection %s", collectionName)
m.collectionAnalyzerModes.Store(collectionName, collectionAnalyzerMulti)
} else {
// Existing collections may have been created by an older WeKnora
// Existing collections may have been created by an older Academy
// version. Keep them readable and writable until they are migrated.
if _, err := m.collectionAnalyzerMode(ctx, collectionName); err != nil {
return err
@@ -1407,7 +1407,7 @@ func convertResultSet(resultSet []client.ResultSet) ([]*MilvusVectorEmbeddingWit
// metricToSimilarity converts a raw vector-search score into cosine
// similarity, the scale callers rank and threshold on. IP and COSINE already
// are for the L2-normalized embeddings WeKnora indexes. Milvus L2 returns
// are for the L2-normalized embeddings Academy indexes. Milvus L2 returns
// the squared Euclidean distance (smaller is better), which for unit vectors
// is 2 - 2cos; passing it through ranked the farthest hits first.
func (m *milvusRepository) metricToSimilarity(score float64) float64 {
@@ -5,7 +5,7 @@ import (
"errors"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -45,13 +45,13 @@ func TestUpdateChunkEnabledStatusInCollectionSkipsEmptyChunkIDs(t *testing.T) {
require.NoError(t, repo.updateChunkEnabledStatusInCollection(
context.Background(),
"weknora_embeddings_1024",
"academy_embeddings_1024",
nil,
false,
))
require.NoError(t, repo.updateChunkEnabledStatusInCollection(
context.Background(),
"weknora_embeddings_1024",
"academy_embeddings_1024",
[]string{},
true,
))
@@ -61,12 +61,12 @@ func TestUpdateChunkEnabledStatusInCollectionsPropagatesFailure(t *testing.T) {
wantErr := errors.New("upsert failed")
err := updateChunkEnabledStatusInCollections(
context.Background(),
[]string{"other_collection", "weknora_embeddings_1024"},
"weknora_embeddings",
[]string{"other_collection", "academy_embeddings_1024"},
"academy_embeddings",
nil,
[]string{"chunk-1"},
func(_ context.Context, collection string, _ []string, enabled bool) error {
if collection == "weknora_embeddings_1024" && !enabled {
if collection == "academy_embeddings_1024" && !enabled {
return wantErr
}
return nil
@@ -82,11 +82,11 @@ func TestUpdateChunkEnabledStatusInCollectionsIgnoresExtendedPrefix(t *testing.T
context.Background(),
[]string{
"other_collection",
"weknora_embeddings_1024",
"weknora_embeddings_multilingual_1024",
"weknora_embeddings_1024_backup",
"academy_embeddings_1024",
"academy_embeddings_multilingual_1024",
"academy_embeddings_1024_backup",
},
"weknora_embeddings",
"academy_embeddings",
[]string{"chunk-1"},
nil,
func(_ context.Context, collection string, _ []string, _ bool) error {
@@ -98,5 +98,5 @@ func TestUpdateChunkEnabledStatusInCollectionsIgnoresExtendedPrefix(t *testing.T
},
)
require.NoError(t, err)
require.Equal(t, []string{"weknora_embeddings_1024"}, seen)
require.Equal(t, []string{"academy_embeddings_1024"}, seen)
}
@@ -6,9 +6,9 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/logger"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
)
Loaded 100 of 3136 files, more files were not shown because too many files have changed in this diff. Show more