[+]删除链路追踪,修改项目名称

This commit is contained in:
renzhiyuan 2025-08-28 18:04:11 +08:00
parent 17f4830954
commit d8d40997b8
121 changed files with 592 additions and 354 deletions

View File

@ -11,7 +11,7 @@
<a href="https://chatbot.weixin.qq.com" target="_blank">
<img alt="微信对话开放平台" src="https://img.shields.io/badge/微信对话开放平台-5ac725">
</a>
<a href="https://github.com/Tencent/WeKnora/blob/main/LICENSE">
<a href="https://knowlege-lsxd/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-MIT-ffffff?labelColor=d4eaf7&color=2e6cc4" alt="License">
</a>
</p>
@ -93,7 +93,7 @@ WeKnora 采用现代化模块化设计,构建了一条完整的文档理解与
```bash
# 克隆主仓库
git clone https://github.com/Tencent/WeKnora.git
git clone https://knowlege-lsxd.git
cd WeKnora
```
@ -240,7 +240,7 @@ make clean-db
## 🤝 贡献指南
我们欢迎社区用户参与贡献如有建议、Bug 或新功能需求,请通过 [Issue](https://github.com/Tencent/WeKnora/issues) 提出,或直接提交 Pull Request。
我们欢迎社区用户参与贡献如有建议、Bug 或新功能需求,请通过 [Issue](https://knowlege-lsxd/issues) 提出,或直接提交 Pull Request。
### 🎯 贡献方式

View File

@ -11,7 +11,7 @@
<a href="https://chatbot.weixin.qq.com" target="_blank">
<img alt="微信对话开放平台" src="https://img.shields.io/badge/微信对话开放平台-5ac725">
</a>
<a href="https://github.com/Tencent/WeKnora/blob/main/LICENSE">
<a href="https://knowlege-lsxd/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-MIT-ffffff?labelColor=d4eaf7&color=2e6cc4" alt="License">
</a>
</p>
@ -93,7 +93,7 @@ Make sure the following tools are installed on your system:
```bash
# Clone the main repository
git clone https://github.com/Tencent/WeKnora.git
git clone https://knowlege-lsxd.git
cd WeKnora
```
@ -206,7 +206,7 @@ make clean-db
## 🤝 Contributing
We welcome community contributions! For suggestions, bugs, or feature requests, please submit an [Issue](https://github.com/Tencent/WeKnora/issues) or directly create a Pull Request.
We welcome community contributions! For suggestions, bugs, or feature requests, please submit an [Issue](https://knowlege-lsxd/issues) or directly create a Pull Request.
### 🎯 How to Contribute

View File

@ -22,7 +22,7 @@
```go
import (
"context"
"github.com/Tencent/WeKnora/internal/client"
"knowlege-lsxd/internal/client"
"time"
)

View File

@ -23,7 +23,7 @@ The client includes the following main functional modules:
```go
import (
"context"
"github.com/Tencent/WeKnora/internal/client"
"knowlege-lsxd/internal/client"
"time"
)

View File

@ -1,3 +1,3 @@
module github.com/Tencent/WeKnora/client
module knowlege-lsxd/client
go 1.24.2

View File

@ -14,11 +14,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/container"
"github.com/Tencent/WeKnora/internal/runtime"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/container"
"knowlege-lsxd/internal/runtime"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types/interfaces"
)
func main() {

198
docker-compose.bak Normal file
View File

@ -0,0 +1,198 @@
services:
app:
image: wechatopenai/weknora-app:latest
container_name: WeKnora-app
ports:
- "8080:8080"
volumes:
- data-files:/data/files
- ./config:/app/config
environment:
- GIN_MODE=${GIN_MODE}
- DB_DRIVER=postgres
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_NAME=${DB_NAME}
- TZ=Asia/Shanghai
- OTEL_EXPORTER_OTLP_ENDPOINT=jaeger:4317
- OTEL_SERVICE_NAME=WeKnora
- OTEL_TRACES_EXPORTER=otlp
- OTEL_METRICS_EXPORTER=none
- OTEL_LOGS_EXPORTER=none
- OTEL_PROPAGATORS=tracecontext,baggage
- RETRIEVE_DRIVER=${RETRIEVE_DRIVER}
- ELASTICSEARCH_ADDR=${ELASTICSEARCH_ADDR}
- ELASTICSEARCH_USERNAME=${ELASTICSEARCH_USERNAME}
- ELASTICSEARCH_PASSWORD=${ELASTICSEARCH_PASSWORD}
- ELASTICSEARCH_INDEX=${ELASTICSEARCH_INDEX}
- DOCREADER_ADDR=docreader:50051
- STORAGE_TYPE=${STORAGE_TYPE}
- LOCAL_STORAGE_BASE_DIR=${LOCAL_STORAGE_BASE_DIR}
- MINIO_ENDPOINT=minio:9000
- MINIO_ACCESS_KEY_ID=${MINIO_ACCESS_KEY_ID:-minioadmin}
- MINIO_SECRET_ACCESS_KEY=${MINIO_SECRET_ACCESS_KEY:-minioadmin}
- MINIO_BUCKET_NAME=${MINIO_BUCKET_NAME}
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
- STREAM_MANAGER_TYPE=${STREAM_MANAGER_TYPE}
- REDIS_ADDR=redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DB=${REDIS_DB}
- REDIS_PREFIX=${REDIS_PREFIX}
- ENABLE_GRAPH_RAG=${ENABLE_GRAPH_RAG}
- TENANT_AES_KEY=${TENANT_AES_KEY}
- CONCURRENCY_POOL_SIZE=${CONCURRENCY_POOL_SIZE:-5}
- INIT_LLM_MODEL_NAME=${INIT_LLM_MODEL_NAME}
- INIT_LLM_MODEL_BASE_URL=${INIT_LLM_MODEL_BASE_URL}
- INIT_LLM_MODEL_API_KEY=${INIT_LLM_MODEL_API_KEY}
- INIT_EMBEDDING_MODEL_NAME=${INIT_EMBEDDING_MODEL_NAME}
- INIT_EMBEDDING_MODEL_BASE_URL=${INIT_EMBEDDING_MODEL_BASE_URL}
- INIT_EMBEDDING_MODEL_API_KEY=${INIT_EMBEDDING_MODEL_API_KEY}
- INIT_EMBEDDING_MODEL_DIMENSION=${INIT_EMBEDDING_MODEL_DIMENSION}
- INIT_EMBEDDING_MODEL_ID=${INIT_EMBEDDING_MODEL_ID}
- INIT_RERANK_MODEL_NAME=${INIT_RERANK_MODEL_NAME}
- INIT_RERANK_MODEL_BASE_URL=${INIT_RERANK_MODEL_BASE_URL}
- INIT_RERANK_MODEL_API_KEY=${INIT_RERANK_MODEL_API_KEY}
depends_on:
redis:
condition: service_started
postgres:
condition: service_healthy
minio:
condition: service_started
networks:
- WeKnora-network
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
minio:
image: minio/minio:latest
container_name: WeKnora-minio
ports:
- "${MINIO_PORT:-9000}:9000"
- "${MINIO_CONSOLE_PORT:-9001}:9001"
environment:
- MINIO_ROOT_USER=${MINIO_ACCESS_KEY_ID:-minioadmin}
- MINIO_ROOT_PASSWORD=${MINIO_SECRET_ACCESS_KEY:-minioadmin}
command: server --console-address ":9001" /data
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
networks:
- WeKnora-network
frontend:
image: wechatopenai/weknora-ui:latest
container_name: WeKnora-frontend
ports:
- "80:80"
depends_on:
- app
networks:
- WeKnora-network
restart: unless-stopped
docreader:
image: wechatopenai/weknora-docreader:latest
container_name: WeKnora-docreader
ports:
- "50051:50051"
environment:
- COS_SECRET_ID=${COS_SECRET_ID}
- COS_SECRET_KEY=${COS_SECRET_KEY}
- COS_REGION=${COS_REGION}
- COS_BUCKET_NAME=${COS_BUCKET_NAME}
- COS_APP_ID=${COS_APP_ID}
- COS_PATH_PREFIX=${COS_PATH_PREFIX}
- COS_ENABLE_OLD_DOMAIN=${COS_ENABLE_OLD_DOMAIN}
- VLM_MODEL_BASE_URL=${VLM_MODEL_BASE_URL}
- VLM_MODEL_NAME=${VLM_MODEL_NAME}
- VLM_MODEL_API_KEY=${VLM_MODEL_API_KEY}
- STORAGE_TYPE=${STORAGE_TYPE}
- MINIO_PUBLIC_ENDPOINT=http://localhost:${MINIO_PORT:-9000}
- MINIO_ENDPOINT=minio:9000
- MINIO_ACCESS_KEY_ID=${MINIO_ACCESS_KEY_ID:-minioadmin}
- MINIO_SECRET_ACCESS_KEY=${MINIO_SECRET_ACCESS_KEY:-minioadmin}
- MINIO_BUCKET_NAME=${MINIO_BUCKET_NAME}
- MINIO_USE_SSL=${MINIO_USE_SSL}
- WEB_PROXY=${WEB_PROXY}
networks:
- WeKnora-network
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "6831:6831/udp" # Jaeger Thrift接收器
- "6832:6832/udp" # Jaeger Thrift接收器(Compact)
- "5778:5778" # 配置端口
- "16686:16686" # Web UI
- "4317:4317" # OTLP gRPC接收器
- "4318:4318" # OTLP HTTP接收器
- "14250:14250" # 接收模型端口
- "14268:14268" # Jaeger HTTP接收器
- "9411:9411" # Zipkin兼容性端口
environment:
- COLLECTOR_OTLP_ENABLED=true
- COLLECTOR_ZIPKIN_HOST_PORT=:9411
volumes:
- jaeger_data:/var/lib/jaeger # 持久化 Jaeger 数据
networks:
- WeKnora-network
restart: unless-stopped
# 修改的PostgreSQL配置
postgres:
image: paradedb/paradedb:latest
container_name: WeKnora-postgres
ports:
- "${DB_PORT}:5432"
environment:
- POSTGRES_USER=${DB_USER}
# NOCC:hardcode-password(工具误报)
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
volumes:
- postgres-data:/var/lib/postgresql/data
- ./migrations/paradedb:/docker-entrypoint-initdb.d
networks:
- WeKnora-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
interval: 10s # 增加时间间隔
timeout: 10s # 增加超时时间
retries: 3 # 减少重试次数,让失败更快反馈
start_period: 30s # 给予初始启动更多时间
restart: unless-stopped
# 添加停机时的优雅退出时间
stop_grace_period: 1m
redis:
image: redis:7.0-alpine
container_name: WeKnora-redis
ports:
- "${REDIS_PORT}:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
restart: always
networks:
- WeKnora-network
networks:
WeKnora-network:
driver: bridge
volumes:
postgres-data:
data-files:
jaeger_data:
redis_data:
minio_data:

View File

@ -16,7 +16,6 @@ services:
- DB_PASSWORD=${DB_PASSWORD}
- DB_NAME=${DB_NAME}
- TZ=Asia/Shanghai
- OTEL_EXPORTER_OTLP_ENDPOINT=jaeger:4317
- OTEL_SERVICE_NAME=WeKnora
- OTEL_TRACES_EXPORTER=otlp
- OTEL_METRICS_EXPORTER=none
@ -127,27 +126,6 @@ services:
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "6831:6831/udp" # Jaeger Thrift接收器
- "6832:6832/udp" # Jaeger Thrift接收器(Compact)
- "5778:5778" # 配置端口
- "16686:16686" # Web UI
- "4317:4317" # OTLP gRPC接收器
- "4318:4318" # OTLP HTTP接收器
- "14250:14250" # 接收模型端口
- "14268:14268" # Jaeger HTTP接收器
- "9411:9411" # Zipkin兼容性端口
environment:
- COLLECTOR_OTLP_ENABLED=true
- COLLECTOR_ZIPKIN_HOST_PORT=:9411
volumes:
- jaeger_data:/var/lib/jaeger # 持久化 Jaeger 数据
networks:
- WeKnora-network
restart: unless-stopped
# 修改的PostgreSQL配置
postgres:
image: paradedb/paradedb:latest
@ -193,6 +171,5 @@ networks:
volumes:
postgres-data:
data-files:
jaeger_data:
redis_data:
minio_data:

View File

@ -772,7 +772,7 @@ curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowle
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
--header 'Content-Type: application/json' \
--data '{
"url":"https://github.com/Tencent/WeKnora",
"url":"https://knowlege-lsxd",
"enable_multimodel":true
}'
```
@ -788,7 +788,7 @@ curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowle
"type": "url",
"title": "",
"description": "",
"source": "https://github.com/Tencent/WeKnora",
"source": "https://knowlege-lsxd",
"parse_status": "processing",
"enable_status": "disabled",
"embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
@ -831,7 +831,7 @@ curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowle
"type": "url",
"title": "",
"description": "",
"source": "https://github.com/Tencent/WeKnora",
"source": "https://knowlege-lsxd",
"parse_status": "pending",
"enable_status": "disabled",
"embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
@ -922,7 +922,7 @@ curl --location 'http://localhost:8080/api/v1/knowledge/batch?ids=9c8af585-ae15-
"type": "url",
"title": "",
"description": "",
"source": "https://github.com/Tencent/WeKnora",
"source": "https://knowlege-lsxd",
"parse_status": "pending",
"enable_status": "disabled",
"embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",

4
go.mod
View File

@ -1,4 +1,4 @@
module github.com/Tencent/WeKnora
module knowlege-lsxd
go 1.24.0
@ -9,7 +9,6 @@ require (
github.com/elastic/go-elasticsearch/v8 v8.18.0
github.com/gin-contrib/cors v1.7.5
github.com/gin-gonic/gin v1.10.0
github.com/go-ego/gse v0.80.3
github.com/go-viper/mapstructure/v2 v2.2.1
github.com/google/uuid v1.6.0
github.com/hibiken/asynq v0.25.1
@ -94,7 +93,6 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vcaesar/cedar v0.20.2 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.0 // indirect

6
go.sum
View File

@ -46,8 +46,6 @@ github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-ego/gse v0.80.3 h1:YNFkjMhlhQnUeuoFcUEd1ivh6SOB764rT8GDsEbDiEg=
github.com/go-ego/gse v0.80.3/go.mod h1:Gt3A9Ry1Eso2Kza4MRaiZ7f2DTAvActmETY46Lxg0gU=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@ -216,10 +214,6 @@ github.com/uptrace/bun/dialect/pgdialect v1.1.12 h1:m/CM1UfOkoBTglGO5CUTKnIKKOAp
github.com/uptrace/bun/dialect/pgdialect v1.1.12/go.mod h1:Ij6WIxQILxLlL2frUBxUBOZJtLElD2QQNDcu/PWDHTc=
github.com/uptrace/bun/driver/pgdriver v1.1.12 h1:3rRWB1GK0psTJrHwxzNfEij2MLibggiLdTqjTtfHc1w=
github.com/uptrace/bun/driver/pgdriver v1.1.12/go.mod h1:ssYUP+qwSEgeDDS1xm2XBip9el1y9Mi5mTAvLoiADLM=
github.com/vcaesar/cedar v0.20.2 h1:TDx7AdZhilKcfE1WvdToTJf5VrC/FXcUOW+KY1upLZ4=
github.com/vcaesar/cedar v0.20.2/go.mod h1:lyuGvALuZZDPNXwpzv/9LyxW+8Y6faN7zauFezNsnik=
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU=
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=

View File

@ -4,10 +4,10 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// chunkRepository implements the ChunkRepository interface

View File

@ -4,9 +4,9 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
var ErrKnowledgeNotFound = errors.New("knowledge not found")

View File

@ -4,8 +4,9 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"gorm.io/gorm"
)

View File

@ -7,8 +7,8 @@ import (
"gorm.io/gorm"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// messageRepository implements the message repository interface

View File

@ -4,9 +4,9 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// modelRepository implements the model repository interface

View File

@ -4,7 +4,7 @@ import (
"maps"
"slices"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// VectorEmbedding defines the Elasticsearch document structure for vector embeddings

View File

@ -15,14 +15,14 @@ import (
"os"
"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"
"github.com/elastic/go-elasticsearch/v7"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/google/uuid"
elasticsearchRetriever "knowlege-lsxd/internal/application/repository/retriever/elasticsearch"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
typesLocal "knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
type elasticsearchRepository struct {

View File

@ -6,14 +6,14 @@ import (
"fmt"
"os"
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"
"github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/go-elasticsearch/v8/typedapi/core/search"
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
elasticsearchRetriever "knowlege-lsxd/internal/application/repository/retriever/elasticsearch"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
typesLocal "knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// elasticsearchRepository implements the RetrieveEngineRepository interface for Elasticsearch v8

View File

@ -5,13 +5,13 @@ import (
"errors"
"fmt"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/pgvector/pgvector-go"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// pgRepository implements PostgreSQL-based retrieval operations

View File

@ -6,9 +6,9 @@ import (
"strconv"
"time"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/types"
"github.com/pgvector/pgvector-go"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/types"
)
// pgVector defines the database model for vector embeddings storage

View File

@ -4,9 +4,9 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// sessionRepository implements the SessionRepository interface

View File

@ -4,11 +4,11 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
var (

View File

@ -3,9 +3,9 @@ package chatpipline
import (
"context"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginChatCompletion implements chat completion functionality

View File

@ -3,9 +3,9 @@ package chatpipline
import (
"context"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginChatCompletionStream implements streaming chat completion functionality

View File

@ -3,7 +3,7 @@ package chatpipline
import (
"context"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// Plugin defines the interface for chat pipeline plugins

View File

@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// Define a test Plugin implementation

View File

@ -3,10 +3,10 @@ package chatpipline
import (
"context"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// prepareChatModel shared logic to prepare chat model and options

View File

@ -3,8 +3,8 @@ package chatpipline
import (
"context"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
)
// PluginFilterTopK is a plugin that filters search results to keep only the top K items

View File

@ -10,8 +10,8 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
)
// PluginIntoChatMessage handles the transformation of search results into chat messages

View File

@ -5,8 +5,8 @@ import (
"encoding/json"
"sort"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
)
// PluginMerge handles merging of search result chunks

View File

@ -7,10 +7,10 @@ import (
"strings"
"unicode"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginPreprocess Query preprocessing plugin

View File

@ -7,10 +7,10 @@ import (
"math"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/rerank"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/rerank"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginRerank implements reranking functionality for chat pipeline

View File

@ -11,11 +11,11 @@ import (
"sort"
"time"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginRewrite is a plugin for rewriting user queries

View File

@ -4,10 +4,10 @@ import (
"context"
"strings"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// PluginSearch implements search functionality for chat pipeline

View File

@ -4,8 +4,8 @@ import (
"context"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
)
// PluginStreamFilter implements stream filtering functionality for chat pipeline

View File

@ -6,9 +6,9 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"go.opentelemetry.io/otel/attribute"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
)
// PluginTracing implements tracing functionality for chat pipeline events

View File

@ -6,9 +6,9 @@ package service
import (
"context"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// chunkService implements the ChunkService interface

View File

@ -0,0 +1,27 @@
package service
import (
"context"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"github.com/stretchr/testify/mock"
)
type MockKnowledgeBaseRepo struct {
mock.Mock
interfaces.KnowledgeBaseRepository
}
func (m *MockKnowledgeBaseRepo) Create(ctx context.Context, kb *types.KnowledgeBase) error {
args := m.Called(ctx, kb)
return args.Error(0)
}
func must(err error) {
if err != nil {
panic(err)
}
}

View File

@ -5,10 +5,10 @@ import (
"errors"
"fmt"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/parquet-go/parquet-go"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// DatasetService provides operations for working with datasets

View File

@ -7,12 +7,12 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/google/uuid"
"golang.org/x/sync/errgroup"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
/*

View File

@ -10,9 +10,9 @@ import (
"path/filepath"
"strings"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/google/uuid"
"github.com/tencentyun/cos-go-sdk-v5"
"knowlege-lsxd/internal/types/interfaces"
)
// cosFileService implements the FileService interface for Tencent Cloud COS

View File

@ -6,8 +6,8 @@ import (
"io"
"mime/multipart"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/google/uuid"
"knowlege-lsxd/internal/types/interfaces"
)
// DummyFileService is a no-op implementation of the FileService interface

View File

@ -9,8 +9,8 @@ import (
"path/filepath"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types/interfaces"
)
// localFileService implements the FileService interface for local file system storage

View File

@ -7,10 +7,10 @@ import (
"mime/multipart"
"path/filepath"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/google/uuid"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"knowlege-lsxd/internal/types/interfaces"
)
// minioFileService MinIO file service implementation

View File

@ -10,14 +10,14 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/models/utils"
"github.com/Tencent/WeKnora/internal/types"
"github.com/google/uuid"
"golang.org/x/sync/errgroup"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/models/utils"
"knowlege-lsxd/internal/types"
)
const (

View File

@ -17,20 +17,20 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/application/service/retriever"
"github.com/Tencent/WeKnora/internal/config"
werrors "github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/models/utils"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/Tencent/WeKnora/services/docreader/src/client"
"github.com/Tencent/WeKnora/services/docreader/src/proto"
"github.com/google/uuid"
"go.opentelemetry.io/otel/attribute"
"golang.org/x/sync/errgroup"
"knowlege-lsxd/internal/application/service/retriever"
"knowlege-lsxd/internal/config"
werrors "knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/models/utils"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"knowlege-lsxd/services/docreader/src/client"
"knowlege-lsxd/services/docreader/src/proto"
)
// Error definitions for knowledge service operations

View File

@ -8,13 +8,13 @@ import (
"encoding/json"
"github.com/Tencent/WeKnora/internal/application/service/retriever"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/google/uuid"
"knowlege-lsxd/internal/application/service/retriever"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// ErrInvalidTenantID represents an error for invalid tenant ID

View File

@ -0,0 +1,37 @@
package service
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"knowlege-lsxd/internal/container"
"knowlege-lsxd/internal/runtime"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
func Test_CreateKnowledge(t *testing.T) {
// 1. 构建容器
container := container.BuildContainer(runtime.GetContainer())
// 2. Mock 依赖
mockKBRepo := new(MockKnowledgeBaseRepo)
must(container.Provide(func() interfaces.KnowledgeBaseRepository {
return mockKBRepo
}))
// 3. 解析服务(自动注入 Mock 的 KnowledgeBaseRepository
var service *knowledgeBaseService
must(container.Invoke(func(k *knowledgeBaseService) {
service = k
}))
// 4. 设置 Mock 预期
mockKBRepo.On("Create", context.Background(), mock.Anything).Return(nil)
// 5. 调用并断言
base, err := service.CreateKnowledgeBase(context.Background(), &types.KnowledgeBase{Name: "Test"})
assert.NoError(t, err, base)
mockKBRepo.AssertExpectations(t)
}

View File

@ -4,9 +4,9 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// messageService implements the MessageService interface for managing messaging operations

View File

@ -21,7 +21,7 @@ import (
"math"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
type BLEUMetric struct {

View File

@ -4,7 +4,7 @@ import (
"regexp"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
func sum(m map[string]int) int {

View File

@ -1,7 +1,7 @@
package metric
import (
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// MAPMetric calculates Mean Average Precision for retrieval evaluation

View File

@ -3,7 +3,7 @@ package metric
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
func TestMAPMetric_Compute(t *testing.T) {

View File

@ -1,7 +1,7 @@
package metric
import (
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// MRRMetric calculates Mean Reciprocal Rank for retrieval evaluation

View File

@ -3,7 +3,7 @@ package metric
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
func TestMRRMetric_Compute(t *testing.T) {

View File

@ -3,7 +3,7 @@ package metric
import (
"math"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// NDCGMetric calculates Normalized Discounted Cumulative Gain

View File

@ -1,7 +1,7 @@
package metric
import (
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// PrecisionMetric calculates precision for retrieval evaluation

View File

@ -3,7 +3,7 @@ package metric
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
func TestPrecisionMetric_Compute(t *testing.T) {

View File

@ -1,7 +1,7 @@
package metric
import (
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// RecallMetric calculates recall for retrieval evaluation

View File

@ -3,7 +3,7 @@ package metric
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
func TestRecallMetric_Compute(t *testing.T) {

View File

@ -1,6 +1,6 @@
package metric
import "github.com/Tencent/WeKnora/internal/types"
import "knowlege-lsxd/internal/types"
// reference: https://github.com/dd-Rebecca/rouge

View File

@ -4,10 +4,10 @@ import (
"context"
"sync"
"github.com/Tencent/WeKnora/internal/application/service/metric"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/application/service/metric"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// MetricList stores and aggregates metric results

View File

@ -4,13 +4,13 @@ import (
"context"
"errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/models/rerank"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/models/rerank"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// ErrModelNotFound is returned when a model cannot be found in the repository

View File

@ -8,14 +8,14 @@ import (
"sync"
"sync/atomic"
"github.com/Tencent/WeKnora/internal/common"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/runtime"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"go.opentelemetry.io/otel/attribute"
"knowlege-lsxd/internal/common"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/runtime"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// engineInfo holds information about a retrieve engine and its supported retriever types

View File

@ -5,11 +5,11 @@ import (
"slices"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/models/utils"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/models/utils"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// KeywordsVectorHybridRetrieveEngineService implements a hybrid retrieval engine

View File

@ -4,8 +4,8 @@ import (
"fmt"
"sync"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// RetrieveEngineRegistry implements the retrieval engine registry

View File

@ -5,15 +5,15 @@ import (
"errors"
"strings"
chatpipline "github.com/Tencent/WeKnora/internal/application/service/chat_pipline"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
chatpipline "knowlege-lsxd/internal/application/service/chat_pipline"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// sessionService implements the SessionService interface for managing conversation sessions

View File

@ -5,20 +5,22 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"io"
"os"
"strings"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
)
var apiKeySecret = []byte(os.Getenv("TENANT_AES_KEY"))
var apiKeySecret = getApiKeySecret()
// ListTenantsParams defines parameters for listing tenants with filtering and pagination
type ListTenantsParams struct {
@ -287,3 +289,9 @@ func (r *tenantService) ExtractTenantIDFromAPIKey(apiKey string) (uint, error) {
return uint(tenantID), nil
}
func getApiKeySecret() []byte {
secret := os.Getenv("TENANT_AES_KEY")
hashArray := sha256.Sum256([]byte(secret))
return hashArray[:]
}

View File

@ -8,14 +8,14 @@ import (
"os"
"strconv"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/models/rerank"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/chat"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/models/rerank"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// TestDataService 测试数据服务

View File

@ -3,8 +3,8 @@ package common
import (
"log"
"github.com/Tencent/WeKnora/internal/config"
"github.com/hibiken/asynq"
"knowlege-lsxd/internal/config"
)
// client is the global asyncq client instance

View File

@ -2,9 +2,6 @@ package config
import (
"fmt"
"github.com/go-viper/mapstructure/v2"
"github.com/joho/godotenv"
"github.com/spf13/viper"
"log"
"os"
"path/filepath"
@ -12,6 +9,10 @@ import (
"strings"
"sync"
"time"
"github.com/go-viper/mapstructure/v2"
"github.com/joho/godotenv"
"github.com/spf13/viper"
)
// Config 应用程序总配置
@ -193,7 +194,6 @@ func SetEnv() {
envSet("DB_HOST", "127.0.0.1")
envSet("DB_PORT", "5432")
envSet("TZ", "Asia/Shanghai")
envSet("OTEL_EXPORTER_OTLP_ENDPOINT", "jaeger:4317")
envSet("OTEL_SERVICE_NAME", "WeKnora")
envSet("OTEL_TRACES_EXPORTER", "otlp")
envSet("OTEL_METRICS_EXPORTER", "none")

View File

@ -5,8 +5,8 @@ import (
"log"
"sync"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// ResourceCleaner is a resource cleaner that can be used to clean up resources

View File

@ -19,25 +19,25 @@ import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"github.com/Tencent/WeKnora/internal/application/repository"
elasticsearchRepoV7 "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch/v7"
elasticsearchRepoV8 "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch/v8"
postgresRepo "github.com/Tencent/WeKnora/internal/application/repository/retriever/postgres"
"github.com/Tencent/WeKnora/internal/application/service"
chatpipline "github.com/Tencent/WeKnora/internal/application/service/chat_pipline"
"github.com/Tencent/WeKnora/internal/application/service/file"
"github.com/Tencent/WeKnora/internal/application/service/retriever"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/handler"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/router"
"github.com/Tencent/WeKnora/internal/stream"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/Tencent/WeKnora/services/docreader/src/client"
"knowlege-lsxd/internal/application/repository"
elasticsearchRepoV7 "knowlege-lsxd/internal/application/repository/retriever/elasticsearch/v7"
elasticsearchRepoV8 "knowlege-lsxd/internal/application/repository/retriever/elasticsearch/v8"
postgresRepo "knowlege-lsxd/internal/application/repository/retriever/postgres"
"knowlege-lsxd/internal/application/service"
chatpipline "knowlege-lsxd/internal/application/service/chat_pipline"
"knowlege-lsxd/internal/application/service/file"
"knowlege-lsxd/internal/application/service/retriever"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/handler"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/router"
"knowlege-lsxd/internal/stream"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"knowlege-lsxd/services/docreader/src/client"
)
// BuildContainer constructs the dependency injection container

View File

@ -3,12 +3,12 @@ package handler
import (
"net/http"
"github.com/Tencent/WeKnora/internal/application/service"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/application/service"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// ChunkHandler defines HTTP handlers for chunk operations

View File

@ -3,11 +3,11 @@ package handler
import (
"net/http"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// EvaluationHandler handles evaluation related HTTP requests

View File

@ -13,18 +13,18 @@ import (
"strconv"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/embedding"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/Tencent/WeKnora/services/docreader/src/client"
"github.com/Tencent/WeKnora/services/docreader/src/proto"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/ollama/ollama/api"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/embedding"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
"knowlege-lsxd/services/docreader/src/client"
"knowlege-lsxd/services/docreader/src/proto"
)
// DownloadTask 下载任务信息

View File

@ -7,11 +7,11 @@ import (
"net/http"
"strconv"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// KnowledgeHandler processes HTTP requests related to knowledge resources

View File

@ -3,11 +3,11 @@ package handler
import (
"net/http"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// KnowledgeBaseHandler defines the HTTP handler for knowledge base operations

View File

@ -7,9 +7,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types/interfaces"
)
// MessageHandler handles HTTP requests related to messages within chat sessions

View File

@ -3,12 +3,12 @@ package handler
import (
"net/http"
"github.com/Tencent/WeKnora/internal/application/service"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/application/service"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// ModelHandler handles HTTP requests for model-related operations

View File

@ -7,13 +7,13 @@ import (
"net/http"
"time"
"github.com/Tencent/WeKnora/internal/application/service"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/application/service"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// SessionHandler handles all HTTP requests related to conversation sessions

View File

@ -6,10 +6,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/errors"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// TenantHandler implements HTTP request handlers for tenant management

View File

@ -5,10 +5,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// TestDataHandler handles HTTP requests related to test data operations

View File

@ -8,8 +8,8 @@ import (
"sort"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"github.com/sirupsen/logrus"
"knowlege-lsxd/internal/types"
)
// LogLevel 日志级别类型

View File

@ -8,10 +8,10 @@ import (
"slices"
"strings"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/gin-gonic/gin"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/types"
"knowlege-lsxd/internal/types/interfaces"
)
// 无需认证的API列表

View File

@ -5,7 +5,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/errors"
"knowlege-lsxd/internal/errors"
)
// ErrorHandler 是一个处理应用错误的中间件

View File

@ -4,10 +4,10 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/types"
)
// RequestID middleware adds a unique request ID to the context

View File

@ -10,8 +10,8 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"github.com/Tencent/WeKnora/internal/tracing"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/tracing"
"knowlege-lsxd/internal/types"
)
// Custom ResponseWriter to capture response content

View File

@ -5,9 +5,9 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/runtime"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/runtime"
"knowlege-lsxd/internal/types"
)
// ChatOptions 聊天选项

View File

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/types"
ollamaapi "github.com/ollama/ollama/api"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/types"
)
// OllamaChat 实现了基于 Ollama 的聊天

View File

@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/types"
"github.com/sashabaranov/go-openai"
"knowlege-lsxd/internal/types"
)
// RemoteAPIChat 实现了基于的聊天

View File

@ -4,8 +4,8 @@ import (
"context"
"sync"
"github.com/Tencent/WeKnora/internal/models/utils"
"github.com/panjf2000/ants/v2"
"knowlege-lsxd/internal/models/utils"
)
type batchEmbedder struct {

View File

@ -5,9 +5,9 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/runtime"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/models/utils/ollama"
"knowlege-lsxd/internal/runtime"
"knowlege-lsxd/internal/types"
)
// Embedder defines the interface for text vectorization

View File

@ -5,9 +5,9 @@ import (
"fmt"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
ollamaapi "github.com/ollama/ollama/api"
"knowlege-lsxd/internal/logger"
"knowlege-lsxd/internal/models/utils/ollama"
)
// OllamaEmbedder implements text vectorization functionality using Ollama

View File

@ -9,7 +9,7 @@ import (
"net/http"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"knowlege-lsxd/internal/logger"
)
// OpenAIEmbedder implements text vectorization functionality using OpenAI API

View File

@ -8,7 +8,7 @@ import (
"io"
"net/http"
"github.com/Tencent/WeKnora/internal/logger"
"knowlege-lsxd/internal/logger"
)
// OpenAIReranker implements a reranking system based on OpenAI models

View File

@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"knowlege-lsxd/internal/types"
)
// Reranker defines the interface for document reranking

View File

@ -9,8 +9,8 @@ import (
"strings"
"sync"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/ollama/ollama/api"
"knowlege-lsxd/internal/logger"
)
// OllamaService manages Ollama service

View File

@ -7,10 +7,10 @@ import (
"github.com/gin-gonic/gin"
"go.uber.org/dig"
"github.com/Tencent/WeKnora/internal/config"
"github.com/Tencent/WeKnora/internal/handler"
"github.com/Tencent/WeKnora/internal/middleware"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"knowlege-lsxd/internal/config"
"knowlege-lsxd/internal/handler"
"knowlege-lsxd/internal/middleware"
"knowlege-lsxd/internal/types/interfaces"
)
// RouterParams 路由参数
@ -53,7 +53,7 @@ func NewRouter(params RouterParams) *gin.Engine {
r.Use(middleware.Auth(params.TenantService, params.Config))
// 添加OpenTelemetry追踪中间件
r.Use(middleware.TracingMiddleware())
//r.Use(middleware.TracingMiddleware())
// 健康检查
r.GET("/health", func(c *gin.Context) {

Some files were not shown because too many files have changed in this diff Show More