feat(semantic_search): make embedding model configurable (#22)
google/gemini-embedding-001 became paid on OpenRouter, leaving users without credit unable to run the semantic_search tool. The old code hardcoded the model and 3072 dimensions in three places. Make OpenRouterEmbedder accept model/dimension via constructor args or OPENROUTER_EMBEDDING_MODEL / OPENROUTER_EMBEDDING_DIMENSION env vars, with the previous values as backward-compatible defaults. Switch the VectorStore and the response payload in mcp_server_main to read embedder.dimension instead of the hardcoded 3072 so a configured non-Gemini model does not produce shape mismatches. Bad dimension input (non-int or non-positive) now raises a clear ValueError instead of a downstream shape error. Documented the new env vars in .env.example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
ae5d590cca
commit
42731a2c03
+3
-2
@@ -1281,7 +1281,7 @@ YANLIŞ KULLANIM:
|
||||
try:
|
||||
# Initialize components
|
||||
embedder = OpenRouterEmbedder()
|
||||
vector_store = VectorStore(dimension=3072) # Gemini embedding dimension
|
||||
vector_store = VectorStore(dimension=embedder.dimension)
|
||||
processor = DocumentProcessor(chunk_size=1500, chunk_overlap=300)
|
||||
|
||||
# Step 1: Initial keyword search to get document IDs
|
||||
@@ -1437,7 +1437,8 @@ YANLIŞ KULLANIM:
|
||||
"query": query,
|
||||
"initial_keyword": initial_keyword,
|
||||
"total_documents_processed": len(documents_data),
|
||||
"embedding_dimension": 3072,
|
||||
"embedding_model": embedder.model,
|
||||
"embedding_dimension": embedder.dimension,
|
||||
"results": formatted_results,
|
||||
"stats": {
|
||||
"documents_in_store": stats["num_documents"],
|
||||
|
||||
Reference in New Issue
Block a user