doc2vec 2.10.1 → 2.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/doc2vec.js +27 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,6 +151,16 @@ Configuration is managed through two files:
|
|
|
151
151
|
OPENAI_API_KEY="sk-..."
|
|
152
152
|
OPENAI_MODEL="text-embedding-3-large" # Optional, defaults to text-embedding-3-large
|
|
153
153
|
|
|
154
|
+
# Optional: Override the OpenAI API base URL. Useful for pointing the
|
|
155
|
+
# OpenAI SDK at an OpenAI-compatible endpoint such as Ollama, LM Studio,
|
|
156
|
+
# llama.cpp, vLLM, or a proxy gateway. When unset, the SDK uses the
|
|
157
|
+
# default OpenAI endpoint. Equivalent to the `embedding.openai.base_url`
|
|
158
|
+
# field in config.yaml; the env var wins if both are set.
|
|
159
|
+
# Example values:
|
|
160
|
+
# OPENAI_BASE_URL="http://localhost:11434/v1" # Ollama
|
|
161
|
+
# OPENAI_BASE_URL="https://gateway.example.com/v1" # proxy / gateway
|
|
162
|
+
OPENAI_BASE_URL="http://localhost:11434/v1"
|
|
163
|
+
|
|
154
164
|
# Optional: Embedding dimension size (defaults to 3072)
|
|
155
165
|
EMBEDDING_DIMENSION="3072"
|
|
156
166
|
|
|
@@ -219,6 +229,7 @@ Configuration is managed through two files:
|
|
|
219
229
|
* `ticket_status`: (Optional) Filter tickets by status (defaults to `['new', 'open', 'pending', 'hold', 'solved']`).
|
|
220
230
|
* `ticket_priority`: (Optional) Filter tickets by priority (defaults to all priorities).
|
|
221
231
|
* `excluded_organizations`: (Optional) An array of Zendesk organization names whose tickets should be skipped. The sync will abort if any name cannot be resolved.
|
|
232
|
+
* `include_internal_comments`: (Optional) Include non-public (internal/agent-only) comments in the indexed content (defaults to `false`, i.e. only public comments are indexed). Internal comments are labeled `(internal)` in the generated markdown.
|
|
222
233
|
|
|
223
234
|
For S3 buckets (`type: 's3'`):
|
|
224
235
|
* `bucket`: The S3 bucket name.
|
|
@@ -276,6 +287,7 @@ Configuration is managed through two files:
|
|
|
276
287
|
openai:
|
|
277
288
|
api_key: '${OPENAI_API_KEY}' # Optional, uses env var by default
|
|
278
289
|
model: 'text-embedding-3-large' # Optional, defaults to text-embedding-3-large
|
|
290
|
+
# 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.
|
|
279
291
|
# For Azure OpenAI, use this instead:
|
|
280
292
|
# azure:
|
|
281
293
|
# api_key: '${AZURE_OPENAI_KEY}'
|
package/dist/doc2vec.js
CHANGED
|
@@ -96,13 +96,17 @@ class Doc2Vec {
|
|
|
96
96
|
else {
|
|
97
97
|
const openaiApiKey = embeddingConfig.openai?.api_key || process.env.OPENAI_API_KEY;
|
|
98
98
|
const openaiModel = embeddingConfig.openai?.model || process.env.OPENAI_MODEL || 'text-embedding-3-large';
|
|
99
|
+
const openaiBaseURL = embeddingConfig.openai?.base_url || process.env.OPENAI_BASE_URL;
|
|
99
100
|
if (!openaiApiKey) {
|
|
100
101
|
this.logger.error('OpenAI requires api_key to be configured');
|
|
101
102
|
process.exit(1);
|
|
102
103
|
}
|
|
103
|
-
this.openai = new openai_1.OpenAI({
|
|
104
|
+
this.openai = new openai_1.OpenAI({
|
|
105
|
+
apiKey: openaiApiKey,
|
|
106
|
+
...(openaiBaseURL && { baseURL: openaiBaseURL }),
|
|
107
|
+
});
|
|
104
108
|
this.embeddingModel = openaiModel;
|
|
105
|
-
this.logger.info(`Using OpenAI with model: ${openaiModel} (${this.embeddingDimension} dimensions)`);
|
|
109
|
+
this.logger.info(`Using OpenAI with model: ${openaiModel} (${this.embeddingDimension} dimensions)${openaiBaseURL ? ` via ${openaiBaseURL}` : ''}`);
|
|
106
110
|
}
|
|
107
111
|
this.contentProcessor = new content_processor_1.ContentProcessor(this.logger);
|
|
108
112
|
// Initialize Postgres markdown store if configured
|
|
@@ -1245,13 +1249,16 @@ class Doc2Vec {
|
|
|
1245
1249
|
if (comments && comments.length > 0) {
|
|
1246
1250
|
md += `## Comments\n\n`;
|
|
1247
1251
|
for (const comment of comments) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
const rawBody = comment.plain_body || comment.html_body || comment.body || '';
|
|
1252
|
-
const commentBody = rawBody.replace(/ /g, " ") || '_No content._';
|
|
1253
|
-
md += `${commentBody}\n\n---\n\n`;
|
|
1252
|
+
// Skip non-public comments unless internal comments are explicitly enabled
|
|
1253
|
+
if (!comment.public && !config.include_internal_comments) {
|
|
1254
|
+
continue;
|
|
1254
1255
|
}
|
|
1256
|
+
const visibility = comment.public ? '' : ' (internal)';
|
|
1257
|
+
md += `### ${comment.author_id} - ${new Date(comment.created_at).toDateString()}${visibility}\n\n`;
|
|
1258
|
+
// Handle comment body
|
|
1259
|
+
const rawBody = comment.plain_body || comment.html_body || comment.body || '';
|
|
1260
|
+
const commentBody = rawBody.replace(/ /g, " ") || '_No content._';
|
|
1261
|
+
md += `${commentBody}\n\n---\n\n`;
|
|
1255
1262
|
}
|
|
1256
1263
|
}
|
|
1257
1264
|
else {
|
|
@@ -1284,10 +1291,18 @@ class Doc2Vec {
|
|
|
1284
1291
|
return;
|
|
1285
1292
|
}
|
|
1286
1293
|
logger.info(`Processing ticket #${ticketId}`);
|
|
1287
|
-
// Fetch ticket comments
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
const comments =
|
|
1294
|
+
// Fetch ticket comments. Zendesk returns at most 100 comments per page
|
|
1295
|
+
// (ordered oldest-first), so follow next_page to capture the newest
|
|
1296
|
+
// comments on tickets with more than 100 — otherwise they're silently dropped.
|
|
1297
|
+
const comments = [];
|
|
1298
|
+
let commentsUrl = `${baseUrl}/tickets/${ticketId}/comments.json`;
|
|
1299
|
+
while (commentsUrl) {
|
|
1300
|
+
const commentsData = await fetchWithRetry(commentsUrl);
|
|
1301
|
+
comments.push(...(commentsData?.comments || []));
|
|
1302
|
+
commentsUrl = commentsData?.next_page || null;
|
|
1303
|
+
if (commentsUrl)
|
|
1304
|
+
await new Promise(res => setTimeout(res, 1000));
|
|
1305
|
+
}
|
|
1291
1306
|
// Generate markdown for the ticket
|
|
1292
1307
|
const markdown = generateMarkdownForTicket(ticket, comments);
|
|
1293
1308
|
// Chunk the markdown content
|