refactor: reorganize rag modules

This commit is contained in:
shenlan 2025-08-09 18:42:19 +08:00
parent 2cf5788d18
commit 4c7082b7fd
29 changed files with 26 additions and 26 deletions

View File

@ -63,7 +63,7 @@ init-db:
build: build-cli build-server build-homepage build-panel
build-cli:
$(MAKE) -C cmd/cli build
$(MAKE) -C cmd/xcontrol-cli build
build-server:
$(MAKE) -C server build

View File

@ -6,9 +6,9 @@ import (
"log"
"runtime"
cfgpkg "xcontrol/internal/rag/config"
"xcontrol/internal/rag/ingest"
"xcontrol/server/proxy"
cfgpkg "xcontrol/server/rag/config"
"xcontrol/server/rag/ingest"
)
func main() {

View File

@ -12,12 +12,12 @@ import (
"strings"
"time"
rconfig "xcontrol/internal/rag/config"
"xcontrol/internal/rag/embed"
"xcontrol/internal/rag/ingest"
"xcontrol/internal/rag/store"
rsync "xcontrol/internal/rag/sync"
"xcontrol/server/proxy"
rconfig "xcontrol/server/rag/config"
"xcontrol/server/rag/embed"
"xcontrol/server/rag/ingest"
"xcontrol/server/rag/store"
rsync "xcontrol/server/rag/sync"
)
// main loads server RAG configuration and triggers a manual sync by

View File

@ -78,7 +78,7 @@ func Embed(text string) ([]float32, error) { /* 调用 Embedding 模型 */ }
## 5. 项目代码规划
```
server/rag/
internal/rag/
├── sync/ # Git 克隆/更新
├── ingest/ # 文档转换与分块
├── embed/ # 向量化

View File

@ -64,7 +64,7 @@
## 6. Go 代码模块划分
```
server/rag/
internal/rag/
├── config/ # 仓库与模型配置
├── sync/ # GitHub 同步逻辑
├── ingest/ # Markdown 解析与分块

View File

@ -4,7 +4,7 @@ WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /xcontrol ./cmd/api
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /xcontrol ./cmd/xcontrol-server
FROM gcr.io/distroless/base-debian12
WORKDIR /

View File

@ -3,7 +3,7 @@ package ingest
import (
"strings"
cfgpkg "xcontrol/server/rag/config"
cfgpkg "xcontrol/internal/rag/config"
)
// Chunk represents a piece of text prepared for embedding.

View File

@ -4,7 +4,7 @@ import (
"strings"
"testing"
cfgpkg "xcontrol/server/rag/config"
cfgpkg "xcontrol/internal/rag/config"
)
func TestBuildChunksHeading(t *testing.T) {

View File

@ -8,10 +8,10 @@ import (
"github.com/jackc/pgx/v5"
cfgpkg "xcontrol/server/rag/config"
"xcontrol/server/rag/embed"
"xcontrol/server/rag/store"
rsync "xcontrol/server/rag/sync"
cfgpkg "xcontrol/internal/rag/config"
"xcontrol/internal/rag/embed"
"xcontrol/internal/rag/store"
rsync "xcontrol/internal/rag/sync"
)
// Options control ingestion behaviour.
@ -41,7 +41,7 @@ func IngestRepo(ctx context.Context, cfg *cfgpkg.Config, ds cfgpkg.DataSource, o
chunkCfg := cfg.ResolveChunking()
embCfg := cfg.ResolveEmbedding()
workdir := filepath.Join("server", "rag", ds.Name)
workdir := filepath.Join("internal", "rag", ds.Name)
if _, err := rsync.SyncRepo(ctx, ds.Repo, workdir); err != nil {
st.Errors = append(st.Errors, err)
return st, err

View File

@ -7,9 +7,9 @@ import (
"github.com/jackc/pgx/v5"
pgvector "github.com/pgvector/pgvector-go"
"xcontrol/server/rag/config"
"xcontrol/server/rag/embed"
"xcontrol/server/rag/store"
"xcontrol/internal/rag/config"
"xcontrol/internal/rag/embed"
"xcontrol/internal/rag/store"
)
type Service struct {

View File

@ -1,5 +1,5 @@
APP_NAME := xcontrol-server
MAIN_FILE := ../cmd/api/main.go
MAIN_FILE := ../cmd/xcontrol-server/main.go
MODULE := xcontrol
PORT := 8080
OS := $(shell uname -s)

View File

@ -6,7 +6,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"
rsync "xcontrol/server/rag/sync"
rsync "xcontrol/internal/rag/sync"
)
// registerKnowledgeRoutes sets up knowledge base endpoints.

View File

@ -5,10 +5,10 @@ import (
"github.com/gin-gonic/gin"
"xcontrol/internal/rag"
rconfig "xcontrol/internal/rag/config"
"xcontrol/internal/rag/store"
"xcontrol/server/proxy"
"xcontrol/server/rag"
rconfig "xcontrol/server/rag/config"
"xcontrol/server/rag/store"
)
// ragSvc handles RAG document storage and retrieval.