Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ RUN apt-get update && apt-get install -y \

COPY package*.json ./
RUN npm install --ignore-scripts
# --ignore-scripts skips node-gyp rebuild for native modules
# (security best-practice, blocks malicious postinstall scripts).
# Explicitly rebuild better-sqlite3 so its arm64/amd64 .node binding
# is compiled — otherwise the runtime fails with "Could not locate
# the bindings file" on architectures lacking a prebuild.
RUN npm rebuild better-sqlite3
# Install Chrome via Puppeteer as fallback (system Chromium will be used first)
RUN npx puppeteer browsers install chrome || true
COPY . .
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ Configuration is managed through two files:
OPENAI_API_KEY="sk-..."
OPENAI_MODEL="text-embedding-3-large" # Optional, defaults to text-embedding-3-large

# Optional: Override the OpenAI API base URL. Useful for pointing the
# OpenAI SDK at an OpenAI-compatible endpoint such as Ollama, LM Studio,
# llama.cpp, vLLM, or a proxy gateway. When unset, the SDK uses the
# default OpenAI endpoint. Equivalent to the `embedding.openai.base_url`
# field in config.yaml; the env var wins if both are set.
# Example values:
# OPENAI_BASE_URL="http://localhost:11434/v1" # Ollama
# OPENAI_BASE_URL="https://gateway.example.com/v1" # proxy / gateway
OPENAI_BASE_URL="http://localhost:11434/v1"

# Optional: Embedding dimension size (defaults to 3072)
EMBEDDING_DIMENSION="3072"

Expand Down Expand Up @@ -277,6 +287,7 @@ Configuration is managed through two files:
openai:
api_key: '${OPENAI_API_KEY}' # Optional, uses env var by default
model: 'text-embedding-3-large' # Optional, defaults to text-embedding-3-large
# base_url: 'http://localhost:11434/v1' # Optional, override OpenAI API base URL for Ollama / other OpenAI-compatible endpoints. Falls back to OPENAI_BASE_URL env var.
# For Azure OpenAI, use this instead:
# azure:
# api_key: '${AZURE_OPENAI_KEY}'
Expand Down
12 changes: 8 additions & 4 deletions doc2vec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,19 @@ export class Doc2Vec {
} else {
const openaiApiKey = embeddingConfig.openai?.api_key || process.env.OPENAI_API_KEY;
const openaiModel = embeddingConfig.openai?.model || process.env.OPENAI_MODEL || 'text-embedding-3-large';

const openaiBaseURL = embeddingConfig.openai?.base_url || process.env.OPENAI_BASE_URL;

if (!openaiApiKey) {
this.logger.error('OpenAI requires api_key to be configured');
process.exit(1);
}

this.openai = new OpenAI({ apiKey: openaiApiKey });

this.openai = new OpenAI({
apiKey: openaiApiKey,
...(openaiBaseURL && { baseURL: openaiBaseURL }),
});
this.embeddingModel = openaiModel;
this.logger.info(`Using OpenAI with model: ${openaiModel} (${this.embeddingDimension} dimensions)`);
this.logger.info(`Using OpenAI with model: ${openaiModel} (${this.embeddingDimension} dimensions)${openaiBaseURL ? ` via ${openaiBaseURL}` : ''}`);
}

this.contentProcessor = new ContentProcessor(this.logger);
Expand Down
2 changes: 1 addition & 1 deletion mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sqlite-vec-mcp-server",
"version": "2.1.0",
"version": "2.1.1",
"description": "MCP Server for querying documentation with sqlite-vec",
"main": "build/index.js",
"type": "module",
Expand Down
2 changes: 2 additions & 0 deletions mcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const embeddingProvider = process.env.EMBEDDING_PROVIDER || 'openai';
// OpenAI configuration
const openAIApiKey = process.env.OPENAI_API_KEY;
const openAIModel = process.env.OPENAI_MODEL || 'text-embedding-3-large';
const openAIBaseURL = process.env.OPENAI_BASE_URL; // Optional: override API base URL for Ollama / other OpenAI-compatible endpoints

// Azure OpenAI configuration
const azureApiKey = process.env.AZURE_OPENAI_KEY;
Expand Down Expand Up @@ -110,6 +111,7 @@ async function createEmbeddings(text: string): Promise<number[]> {
case 'openai': {
const openai = new OpenAI({
apiKey: openAIApiKey,
...(openAIBaseURL && { baseURL: openAIBaseURL }),
});
const response = await openai.embeddings.create({
model: openAIModel,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doc2vec",
"version": "2.10.2",
"version": "2.10.3",
"type": "commonjs",
"description": "",
"main": "dist/doc2vec.js",
Expand Down
5 changes: 3 additions & 2 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ export interface EmbeddingConfig {
provider: 'openai' | 'azure';
dimension?: number;
openai?: {
api_key?: string; // Can also use OPENAI_API_KEY env var
model?: string; // Default: text-embedding-3-large
api_key?: string; // Can also use OPENAI_API_KEY env var
model?: string; // Default: text-embedding-3-large
base_url?: string; // Override OpenAI API base URL — useful for Ollama or other OpenAI-compatible endpoints. Can also use OPENAI_BASE_URL env var.
};
azure?: {
api_key?: string; // Can also use AZURE_OPENAI_KEY env var
Expand Down