Move RAG module under rag-server (#526)
This commit is contained in:
parent
92a3458f4e
commit
522eb4c6fd
@ -78,7 +78,7 @@ func Embed(text string) ([]float32, error) { /* 调用 Embedding 模型 */ }
|
||||
## 5. 项目代码规划
|
||||
|
||||
```
|
||||
internal/rag/
|
||||
rag-server/internal/rag/
|
||||
├── sync/ # Git 克隆/更新
|
||||
├── ingest/ # 文档转换与分块
|
||||
├── embed/ # 向量化
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
## 6. Go 代码模块划分
|
||||
|
||||
```
|
||||
internal/rag/
|
||||
rag-server/internal/rag/
|
||||
├── config/ # 仓库与模型配置
|
||||
├── sync/ # GitHub 同步逻辑
|
||||
├── ingest/ # Markdown 解析与分块
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
APP_NAME := xcontrol-server
|
||||
MAIN_FILE := ../cmd/xcontrol-server/main.go
|
||||
MAIN_FILE := cmd/xcontrol-server/main.go
|
||||
MODULE := xcontrol
|
||||
PORT := 8090
|
||||
OS := $(shell uname -s)
|
||||
@ -69,30 +69,30 @@ dev:
|
||||
fi
|
||||
|
||||
clean:
|
||||
@echo ">>> 清理构建产物"
|
||||
rm -f $(APP_NAME)
|
||||
@echo ">>> 清理构建产物"
|
||||
rm -f $(APP_NAME)
|
||||
|
||||
init-db:
|
||||
@echo ">>> 初始化 RAG schema ($(SCHEMA_FILE))"
|
||||
@$(PSQL) -f $(SCHEMA_FILE)
|
||||
@echo ">>> 初始化 RAG schema ($(SCHEMA_FILE))"
|
||||
@$(PSQL) -f $(SCHEMA_FILE)
|
||||
|
||||
drop-db:
|
||||
@echo ">>> 删除 RAG schema 对象"
|
||||
@$(PSQL) -c "DROP TABLE IF EXISTS public.documents CASCADE;"
|
||||
@echo ">>> 删除 RAG schema 对象"
|
||||
@$(PSQL) -c "DROP TABLE IF EXISTS public.documents CASCADE;"
|
||||
|
||||
reinit-db: drop-db init-db
|
||||
|
||||
help:
|
||||
@echo " XControl Server Makefile"
|
||||
@echo ""
|
||||
@echo "make build 编译 server 可执行文件"
|
||||
@echo "make start 后台运行 server (默认端口: $(PORT))"
|
||||
@echo "make stop 停止运行 server"
|
||||
@echo "make restart 重启 server"
|
||||
@echo "make test 运行单元测试"
|
||||
@echo "make dev 开发模式运行 (自动检测 air,如无则用 go run)"
|
||||
@echo "make init 初始化依赖(自动选择国内/默认 Go 模块代理,air 可选)"
|
||||
@echo "make clean 清理构建产物"
|
||||
@echo "make init-db 初始化数据库 schema ($(SCHEMA_FILE))"
|
||||
@echo "make drop-db 删除 RAG 相关数据库对象"
|
||||
@echo "make reinit-db 重置数据库 schema (drop + init)"
|
||||
@echo " XControl Server Makefile"
|
||||
@echo ""
|
||||
@echo "make build 编译 server 可执行文件"
|
||||
@echo "make start 后台运行 server (默认端口: $(PORT))"
|
||||
@echo "make stop 停止运行 server"
|
||||
@echo "make restart 重启 server"
|
||||
@echo "make test 运行单元测试"
|
||||
@echo "make dev 开发模式运行 (自动检测 air,如无则用 go run)"
|
||||
@echo "make init 初始化依赖(自动选择国内/默认 Go 模块代理,air 可选)"
|
||||
@echo "make clean 清理构建产物"
|
||||
@echo "make init-db 初始化数据库 schema ($(SCHEMA_FILE))"
|
||||
@echo "make drop-db 删除 RAG 相关数据库对象"
|
||||
@echo "make reinit-db 重置数据库 schema (drop + init)"
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
rsync "xcontrol/internal/rag/sync"
|
||||
rsync "xcontrol/rag-server/internal/rag/sync"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
|
||||
@ -8,10 +8,10 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"xcontrol/internal/rag"
|
||||
rconfig "xcontrol/internal/rag/config"
|
||||
ragembed "xcontrol/internal/rag/embed"
|
||||
"xcontrol/internal/rag/store"
|
||||
"xcontrol/rag-server/internal/rag"
|
||||
rconfig "xcontrol/rag-server/internal/rag/config"
|
||||
ragembed "xcontrol/rag-server/internal/rag/embed"
|
||||
"xcontrol/rag-server/internal/rag/store"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"xcontrol/internal/rag"
|
||||
"xcontrol/internal/rag/store"
|
||||
"xcontrol/rag-server/internal/rag"
|
||||
"xcontrol/rag-server/internal/rag/store"
|
||||
)
|
||||
|
||||
type mockRAGService struct {
|
||||
|
||||
@ -6,8 +6,8 @@ import (
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
cfgpkg "xcontrol/internal/rag/config"
|
||||
"xcontrol/internal/rag/ingest"
|
||||
cfgpkg "xcontrol/rag-server/internal/rag/config"
|
||||
"xcontrol/rag-server/internal/rag/ingest"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
@ -15,11 +15,11 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
rconfig "xcontrol/internal/rag/config"
|
||||
"xcontrol/internal/rag/embed"
|
||||
"xcontrol/internal/rag/ingest"
|
||||
"xcontrol/internal/rag/store"
|
||||
rsync "xcontrol/internal/rag/sync"
|
||||
rconfig "xcontrol/rag-server/internal/rag/config"
|
||||
"xcontrol/rag-server/internal/rag/embed"
|
||||
"xcontrol/rag-server/internal/rag/ingest"
|
||||
"xcontrol/rag-server/internal/rag/store"
|
||||
rsync "xcontrol/rag-server/internal/rag/sync"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
|
||||
@ -15,10 +15,10 @@ import (
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
|
||||
rconfig "xcontrol/internal/rag/config"
|
||||
"xcontrol/rag-server"
|
||||
"xcontrol/rag-server/api"
|
||||
"xcontrol/rag-server/config"
|
||||
rconfig "xcontrol/rag-server/internal/rag/config"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
@ -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/xcontrol-server
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /xcontrol ./rag-server/cmd/xcontrol-server
|
||||
|
||||
FROM gcr.io/distroless/base-debian12
|
||||
WORKDIR /
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
cfgpkg "xcontrol/internal/rag/config"
|
||||
cfgpkg "xcontrol/rag-server/internal/rag/config"
|
||||
)
|
||||
|
||||
// Chunk represents a piece of text prepared for embedding.
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
cfgpkg "xcontrol/internal/rag/config"
|
||||
cfgpkg "xcontrol/rag-server/internal/rag/config"
|
||||
)
|
||||
|
||||
func TestBuildChunksHeading(t *testing.T) {
|
||||
@ -8,10 +8,10 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
cfgpkg "xcontrol/internal/rag/config"
|
||||
"xcontrol/internal/rag/embed"
|
||||
"xcontrol/internal/rag/store"
|
||||
rsync "xcontrol/internal/rag/sync"
|
||||
cfgpkg "xcontrol/rag-server/internal/rag/config"
|
||||
"xcontrol/rag-server/internal/rag/embed"
|
||||
"xcontrol/rag-server/internal/rag/store"
|
||||
rsync "xcontrol/rag-server/internal/rag/sync"
|
||||
"xcontrol/rag-server/proxy"
|
||||
)
|
||||
|
||||
@ -9,10 +9,10 @@ import (
|
||||
"github.com/jackc/pgx/v5"
|
||||
pgvector "github.com/pgvector/pgvector-go"
|
||||
|
||||
"xcontrol/internal/rag/config"
|
||||
"xcontrol/internal/rag/embed"
|
||||
"xcontrol/internal/rag/rerank"
|
||||
"xcontrol/internal/rag/store"
|
||||
"xcontrol/rag-server/internal/rag/config"
|
||||
"xcontrol/rag-server/internal/rag/embed"
|
||||
"xcontrol/rag-server/internal/rag/rerank"
|
||||
"xcontrol/rag-server/internal/rag/store"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Loading…
Reference in New Issue
Block a user