refactor: Update tenant ID handling across the application
This commit is contained in:
@@ -17,11 +17,11 @@ import (
|
||||
type DatabaseQueryTool struct {
|
||||
BaseTool
|
||||
db *gorm.DB
|
||||
tenantID uint
|
||||
tenantID uint64
|
||||
}
|
||||
|
||||
// NewDatabaseQueryTool creates a new database query tool
|
||||
func NewDatabaseQueryTool(db *gorm.DB, tenantID uint) *DatabaseQueryTool {
|
||||
func NewDatabaseQueryTool(db *gorm.DB, tenantID uint64) *DatabaseQueryTool {
|
||||
description := `Execute SQL queries to retrieve information from the database.
|
||||
|
||||
## Security Features
|
||||
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
// GetDocumentInfoTool retrieves detailed information about a document/knowledge
|
||||
type GetDocumentInfoTool struct {
|
||||
BaseTool
|
||||
tenantID uint
|
||||
tenantID uint64
|
||||
knowledgeService interfaces.KnowledgeService
|
||||
chunkService interfaces.ChunkService
|
||||
}
|
||||
|
||||
// NewGetDocumentInfoTool creates a new get document info tool
|
||||
func NewGetDocumentInfoTool(
|
||||
tenantID uint,
|
||||
tenantID uint64,
|
||||
knowledgeService interfaces.KnowledgeService,
|
||||
chunkService interfaces.ChunkService,
|
||||
) *GetDocumentInfoTool {
|
||||
|
||||
@@ -17,12 +17,12 @@ import (
|
||||
type GrepChunksTool struct {
|
||||
BaseTool
|
||||
db *gorm.DB
|
||||
tenantID uint
|
||||
tenantID uint64
|
||||
knowledgeBaseIDs []string
|
||||
}
|
||||
|
||||
// NewGrepChunksTool creates a new grep chunks tool
|
||||
func NewGrepChunksTool(db *gorm.DB, tenantID uint, knowledgeBaseIDs []string) *GrepChunksTool {
|
||||
func NewGrepChunksTool(db *gorm.DB, tenantID uint64, knowledgeBaseIDs []string) *GrepChunksTool {
|
||||
description := `Unix-style text pattern matching tool for knowledge base chunks.
|
||||
|
||||
Searches for text patterns in chunk content, similar to the Unix grep command.
|
||||
|
||||
@@ -32,7 +32,7 @@ type KnowledgeSearchTool struct {
|
||||
BaseTool
|
||||
knowledgeBaseService interfaces.KnowledgeBaseService
|
||||
chunkService interfaces.ChunkService
|
||||
tenantID uint
|
||||
tenantID uint64
|
||||
allowedKBs []string
|
||||
rerankModel rerank.Reranker
|
||||
chatModel chat.Chat // Optional chat model for LLM-based reranking
|
||||
@@ -43,7 +43,7 @@ type KnowledgeSearchTool struct {
|
||||
func NewKnowledgeSearchTool(
|
||||
knowledgeBaseService interfaces.KnowledgeBaseService,
|
||||
chunkService interfaces.ChunkService,
|
||||
tenantID uint,
|
||||
tenantID uint64,
|
||||
allowedKBs []string,
|
||||
rerankModel rerank.Reranker,
|
||||
chatModel chat.Chat,
|
||||
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
// ListKnowledgeChunksTool retrieves chunk snapshots for a specific knowledge document.
|
||||
type ListKnowledgeChunksTool struct {
|
||||
BaseTool
|
||||
tenantID uint
|
||||
tenantID uint64
|
||||
chunkService interfaces.ChunkService
|
||||
knowledgeService interfaces.KnowledgeService
|
||||
}
|
||||
|
||||
// NewListKnowledgeChunksTool creates a new tool instance.
|
||||
func NewListKnowledgeChunksTool(
|
||||
tenantID uint,
|
||||
tenantID uint64,
|
||||
knowledgeService interfaces.KnowledgeService,
|
||||
chunkService interfaces.ChunkService,
|
||||
) *ListKnowledgeChunksTool {
|
||||
|
||||
@@ -124,8 +124,8 @@ func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{}
|
||||
logger.Infof(ctx, "[Tool][WebSearch] Searching with query: %s, max_results: %d", query, t.maxResults)
|
||||
|
||||
// Get tenant ID from context
|
||||
tenantID := uint(0)
|
||||
if tid, ok := ctx.Value(types.TenantIDContextKey).(uint); ok {
|
||||
tenantID := uint64(0)
|
||||
if tid, ok := ctx.Value(types.TenantIDContextKey).(uint64); ok {
|
||||
tenantID = tid
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user