This is an automated email from the ASF dual-hosted git repository.
LinkinStars pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/dev by this push:
new dd4c6f3b feat(plugin): add IsVectorSearchEnabled function to check
plugin status
dd4c6f3b is described below
commit dd4c6f3b53d1941b9a3a012fc01fc314536f83ca
Author: hgaol <[email protected]>
AuthorDate: Fri May 22 18:34:42 2026 +0800
feat(plugin): add IsVectorSearchEnabled function to check plugin status
---
internal/controller/ai_controller.go | 5 +++++
plugin/vector_search.go | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/internal/controller/ai_controller.go
b/internal/controller/ai_controller.go
index e7495253..4c5c4cdd 100644
--- a/internal/controller/ai_controller.go
+++ b/internal/controller/ai_controller.go
@@ -43,6 +43,7 @@ import (
tagcommonser "github.com/apache/answer/internal/service/tag_common"
usercommon "github.com/apache/answer/internal/service/user_common"
"github.com/apache/answer/pkg/token"
+ "github.com/apache/answer/plugin"
"github.com/gin-gonic/gin"
"github.com/mark3labs/mcp-go/mcp"
"github.com/sashabaranov/go-openai"
@@ -702,7 +703,11 @@ func (c *AIController) sendErrorResponse(w
http.ResponseWriter, id, model, error
// getMCPTools
func (c *AIController) getMCPTools() []openai.Tool {
openaiTools := make([]openai.Tool, 0)
+ vectorSearchEnabled := plugin.IsVectorSearchEnabled()
for _, mcpTool := range mcp_tools.MCPToolsList {
+ if mcpTool.Name == "semantic_search" && !vectorSearchEnabled {
+ continue
+ }
openaiTool := c.convertMCPToolToOpenAI(mcpTool)
openaiTools = append(openaiTools, openaiTool)
}
diff --git a/plugin/vector_search.go b/plugin/vector_search.go
index 134247d6..4c46027a 100644
--- a/plugin/vector_search.go
+++ b/plugin/vector_search.go
@@ -124,6 +124,16 @@ var (
registerVectorSearch = MakePlugin[VectorSearch](false)
)
+// IsVectorSearchEnabled reports whether at least one VectorSearch plugin is
currently enabled.
+func IsVectorSearchEnabled() bool {
+ enabled := false
+ _ = CallVectorSearch(func(vs VectorSearch) error {
+ enabled = true
+ return nil
+ })
+ return enabled
+}
+
// GenerateEmbedding is a base utility function that generates an embedding
vector
// using an OpenAI-compatible API. Plugins that don't have a built-in
vectorizer
// (most vector databases) can call this function with their own credentials.