Merge pull request #46 from svc-design/codex/move-modules-to-server-directory

chore: move markmind module and add ask AI API
This commit is contained in:
shenlan 2025-08-02 21:06:41 +08:00 committed by GitHub
commit 31985eae96
17 changed files with 78 additions and 35 deletions

View File

@ -6,7 +6,7 @@ UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
.PHONY: all build agent vet test clean release \
macos-x64 macos-arm64 windows-x64 linux-x64 linux-arm64
macos-x64 macos-arm64 windows-x64 linux-x64 linux-arm64 macos linux
all: vet test build
@ -49,3 +49,25 @@ linux-arm64:
GOOS=linux GOARCH=arm64 $(GO) build -o build/linux-arm64/$(APP_NAME) ./cmd/api
release: macos-x64 macos-arm64 windows-x64 linux-x64 linux-arm64
macos:
@if [ "$(UNAME_S)" = "Darwin" ]; then \
if [ "$(UNAME_M)" = "arm64" ]; then \
GOOS=darwin GOARCH=arm64 $(GO) build -o build/macos-arm64/$(APP_NAME) ./cmd/api; \
else \
GOOS=darwin GOARCH=amd64 $(GO) build -o build/macos-x64/$(APP_NAME) ./cmd/api; \
fi; \
else \
echo "macos build requires macOS host"; \
fi
linux:
@if [ "$(UNAME_S)" = "Linux" ]; then \
if [ "$(UNAME_M)" = "aarch64" ] || [ "$(UNAME_M)" = "arm64" ]; then \
GOOS=linux GOARCH=arm64 $(GO) build -o build/linux-arm64/$(APP_NAME) ./cmd/api; \
else \
GOOS=linux GOARCH=amd64 $(GO) build -o build/linux-x64/$(APP_NAME) ./cmd/api; \
fi; \
else \
echo "linux build requires Linux host"; \
fi

View File

@ -10,8 +10,8 @@ import (
"github.com/jackc/pgx/v5"
"xcontrol/internal/api"
kbserver "xcontrol/modules/markmind/server"
"xcontrol/server"
markmind "xcontrol/server/markmind"
"xcontrol/ui"
)
@ -27,7 +27,7 @@ func main() {
r := server.New(
api.RegisterRoutes,
func(r *gin.Engine) { kbserver.RegisterRoutes(r, conn) },
func(r *gin.Engine) { markmind.RegisterRoutes(r, conn) },
func(r *gin.Engine) { r.StaticFS("/", http.FS(ui.Assets)) },
)

View File

@ -78,7 +78,7 @@ func Embed(text string) ([]float32, error) { /* 调用 Embedding 模型 */ }
## 5. 项目代码规划
```
modules/markmind/
server/markmind/
├── ingest/
│ ├── fetch_repo.go # Git 克隆/更新
│ ├── convert.go # 文档转换

View File

@ -33,17 +33,24 @@ server {
try_files $uri $uri/ /index.html;
}
# 5. 静态资源缓存优化
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# 5. 静态资源缓存优化
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# 6. 隐藏 . 文件(如 .DS_Store)
location ~ /\. {
deny all;
}
# 6. 转发后端 API
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 7. 隐藏 . 文件(如 .DS_Store)
location ~ /\. {
deny all;
}
}
# 7. HTTPS 独立下载服务 artifact.svc.plus

View File

@ -33,17 +33,24 @@ server {
try_files $uri $uri/ /index.html;
}
# 5. 静态资源缓存优化
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# 5. 静态资源缓存优化
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# 6. 隐藏 . 文件(如 .DS_Store)
location ~ /\. {
deny all;
}
# 6. 转发后端 API
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 7. 隐藏 . 文件(如 .DS_Store)
location ~ /\. {
deny all;
}
}
# 7. HTTPS 独立下载服务 artifact.svc.plus

View File

@ -49,7 +49,14 @@ server {
add_header Cache-Control "public";
}
# 6. 隐藏 . 文件(如 .DS_Store)
# 6. 转发后端 API
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 7. 隐藏 . 文件(如 .DS_Store)
location ~ /\. {
deny all;
}

View File

@ -1,4 +1,4 @@
package server
package markmind
import (
"net/http"
@ -6,15 +6,15 @@ import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"
"xcontrol/modules/markmind/db"
"xcontrol/modules/markmind/ingest"
"xcontrol/modules/markmind/llm"
"xcontrol/server/markmind/db"
"xcontrol/server/markmind/ingest"
"xcontrol/server/markmind/llm"
)
// RegisterRoutes registers knowledge base endpoints.
func RegisterRoutes(r *gin.Engine, conn *pgx.Conn) {
store := &db.Store{Conn: conn}
r.POST("/sync", func(c *gin.Context) {
r.POST("/api/sync", func(c *gin.Context) {
var req struct {
RepoURL string `json:"repo_url"`
LocalPath string `json:"local_path"`
@ -30,7 +30,7 @@ func RegisterRoutes(r *gin.Engine, conn *pgx.Conn) {
c.JSON(http.StatusOK, gin.H{"status": "synced"})
})
r.POST("/ask", func(c *gin.Context) {
r.POST("/api/askai", func(c *gin.Context) {
var req struct {
Question string `json:"question"`
}

View File

@ -5,7 +5,7 @@ import (
"encoding/json"
"github.com/jackc/pgx/v5"
"xcontrol/modules/markmind/ingest"
"xcontrol/server/markmind/ingest"
)
// Store wraps a pgx connection for vector operations.

View File

@ -3,7 +3,7 @@ package llm
import (
"strings"
"xcontrol/modules/markmind/ingest"
"xcontrol/server/markmind/ingest"
)
// BuildPrompt constructs a simple prompt from retrieved chunks and a question.

View File

@ -3,8 +3,8 @@ package llm
import (
"context"
"xcontrol/modules/markmind/db"
"xcontrol/modules/markmind/ingest"
"xcontrol/server/markmind/db"
"xcontrol/server/markmind/ingest"
)
// Answer performs a minimal RAG workflow.