From 5dcb71369c3f20ee000ec548b8fa05ad16c07160 Mon Sep 17 00:00:00 2001 From: Woody Date: Fri, 24 Apr 2026 10:15:08 +0800 Subject: [PATCH] fix(backend): add embed_query method to EmbeddingFunctionWrapper for ChromaDB query ChromaDB 1.5.8 calls embed_query() during collection.query(), but the wrapper only implemented __call__ (used by collection.add()). Added embed_query() as alias and refactored to shared _embed() method. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- backend/app/core/database.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/app/core/database.py b/backend/app/core/database.py index 1a19157..bb69071 100644 --- a/backend/app/core/database.py +++ b/backend/app/core/database.py @@ -14,6 +14,12 @@ class _EmbeddingFunctionWrapper: return "custom_embedding_wrapper" def __call__(self, input): + return self._embed(input) + + def embed_query(self, input): + return self._embed(input) + + def _embed(self, texts): from app.services.embedding_client import EmbeddingClient import asyncio from concurrent.futures import ThreadPoolExecutor @@ -28,7 +34,7 @@ class _EmbeddingFunctionWrapper: loop.close() with ThreadPoolExecutor(max_workers=1) as executor: - return executor.submit(_run_in_thread, input).result() + return executor.submit(_run_in_thread, texts).result() def get_embedding_function_settings(settings):