feat: Integrate LLM-based reranking in KnowledgeSearchTool

- Added optional chat model to KnowledgeSearchTool for enhanced reranking using LLM prompt scoring.
- Updated rerankResults method to prioritize LLM-based reranking over traditional rerank model.
- Implemented new functions for LLM scoring and parsing scores from responses, improving search result relevance.
- Enhanced migration script to handle database versioning and dirty state checks more robustly.
This commit is contained in:
wizardchen
2025-11-13 01:22:08 +08:00
parent 7be09acb9e
commit 9f6b903ef2
5 changed files with 303 additions and 11 deletions
@@ -3,11 +3,20 @@
BEGIN;
-- Add web_search_config column to tenants table
ALTER TABLE tenants
ADD COLUMN web_search_config JSONB DEFAULT NULL;
-- Add web_search_config column to tenants table (if not exists)
-- Note: PostgreSQL 9.6+ supports IF NOT EXISTS
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'tenants' AND column_name = 'web_search_config'
) THEN
ALTER TABLE tenants
ADD COLUMN web_search_config JSONB DEFAULT NULL;
END IF;
END $$;
-- Add comment
-- Add or update comment
COMMENT ON COLUMN tenants.web_search_config IS 'Web search configuration for the tenant';
COMMIT;