gptrans 1.0.4 → 1.0.6

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.
Files changed (2) hide show
  1. package/index.js +5 -2
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -2,6 +2,8 @@ import DeepBase from 'deepbase';
2
2
  import stringHash from 'string-hash';
3
3
  import { ModelMix, MixOpenAI, MixAnthropic } from 'modelmix';
4
4
  import dotenv from 'dotenv';
5
+ import { fileURLToPath } from 'url';
6
+ import { dirname, join } from 'path';
5
7
 
6
8
  import { isoAssoc } from './isoAssoc.js';
7
9
  dotenv.config();
@@ -21,7 +23,8 @@ class Gptrans {
21
23
  return this.#mmixInstance;
22
24
  }
23
25
 
24
- constructor({ from = 'en-US', target = 'es-AR', model = 'gpt-4o-mini', batchThreshold = 1000, debounceTimeout = 500, promptFile = './prompt/translate.md', context = '' }) {
26
+ constructor({ from = 'en-US', target = 'es-AR', model = 'gpt-4o-mini', batchThreshold = 1000, debounceTimeout = 500, promptFile = null, context = '' }) {
27
+ const __dirname = dirname(fileURLToPath(import.meta.url));
25
28
  this.target = target;
26
29
  this.from = from;
27
30
  this.dbTarget = new DeepBase({ name: 'gptrans_' + this.target });
@@ -32,7 +35,7 @@ class Gptrans {
32
35
  this.pendingCharCount = 0; // Add character count tracker
33
36
  this.debounceTimer = null;
34
37
  this.modelKey = model;
35
- this.promptFile = promptFile;
38
+ this.promptFile ??= join(__dirname, './prompt/translate.md'); // Convert to absolute path
36
39
  this.context = context;
37
40
  this.modelConfig = {
38
41
  config: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gptrans",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "description": "🚆 GPTrans - The smarter AI-powered way to translate.",
6
6
  "keywords": [
7
7
  "translate",
@@ -13,7 +13,6 @@
13
13
  "localization",
14
14
  "language",
15
15
  "translation",
16
- "translation",
17
16
  "translator",
18
17
  "clasen"
19
18
  ],