@postalsys/email-ai-tools 1.3.1 → 1.3.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.
@@ -0,0 +1,37 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+
6
+ permissions:
7
+ contents: write
8
+ pull-requests: write
9
+ id-token: write
10
+
11
+ name: release
12
+ jobs:
13
+ release-please:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: google-github-actions/release-please-action@v3
17
+ id: release
18
+ with:
19
+ release-type: node
20
+ package-name: ${{env.NPM_MODULE_NAME}}
21
+ pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
22
+ # The logic below handles the npm publication:
23
+ - uses: actions/checkout@v3
24
+ # these if statements ensure that a publication only occurs when
25
+ # a new release is created:
26
+ if: ${{ steps.release.outputs.release_created }}
27
+ - uses: actions/setup-node@v3
28
+ with:
29
+ node-version: 18
30
+ registry-url: 'https://registry.npmjs.org'
31
+ if: ${{ steps.release.outputs.release_created }}
32
+ - run: npm ci
33
+ if: ${{ steps.release.outputs.release_created }}
34
+ - run: npm publish --provenance --access public
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
37
+ if: ${{ steps.release.outputs.release_created }}
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [1.3.3](https://github.com/postalsys/email-ai-tools/compare/v1.3.2...v1.3.3) (2023-09-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **deloy:** Set up automatic publishing ([18e2dc0](https://github.com/postalsys/email-ai-tools/commit/18e2dc00a2c123995f2e67c81c132e4380021dd7))
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { generateSummary, DEFAULT_SYSTEM_PROMPT, DEFAULT_USER_PROMPT } = require('./lib/generate-summary');
4
4
  const riskAnalysis = require('./lib/risk-analysis');
5
- const generateEmbeddings = require('./lib/generate-embeddings');
5
+ const { generateEmbeddings } = require('./lib/generate-embeddings');
6
6
 
7
7
  module.exports = {
8
8
  generateSummary,
@@ -122,19 +122,26 @@ class Embedder {
122
122
  return res.join(' ');
123
123
  })
124
124
  .filter(val => val)
125
- .join(', ');
125
+ .join(' ; ');
126
126
  }
127
127
 
128
128
  getChunks() {
129
129
  let headerLines = [];
130
130
  for (let [key, value] of this.addressHeaders.entries()) {
131
- headerLines.push(`${key}: ${value}`);
131
+ headerLines.push(`${key}: ${value.replace(/\s/g, ' ')}`);
132
132
  }
133
133
  if (this.subject) {
134
134
  headerLines.push(`subject: ${this.subject}`);
135
135
  }
136
136
 
137
- let prompt = `${headerLines.join('\n')}\n`;
137
+ if (this.message.attachments?.length) {
138
+ let attachments = this.message.attachments.map(attachment => attachment.filename?.replace(/\s/g, ' ').trim()).filter(val => val);
139
+ if (attachments.length) {
140
+ headerLines.push(`attachments: ${attachments.join(' ; ')}`);
141
+ }
142
+ }
143
+
144
+ let prompt = `${headerLines.join('\n')}\n\n`;
138
145
 
139
146
  let prefixTokens = tokenizer.encode(prompt);
140
147
  // If prefix is very large, then use larger chunks, so that each chunk contains at least 200 tokens of text
@@ -144,7 +151,7 @@ class Embedder {
144
151
 
145
152
  let textChunks = [];
146
153
  if (this.text) {
147
- let textTokens = tokenizer.encode(this.text);
154
+ let textTokens = tokenizer.encode(this.text.replace(/[\r\n]+/g, '\n'));
148
155
 
149
156
  let pos = 0;
150
157
  while (pos < textTokens.bpe.length) {
@@ -222,7 +229,7 @@ class Embedder {
222
229
  return {
223
230
  chunk,
224
231
  embedding,
225
- time: reqEndTime - reqStartTime
232
+ _time: reqEndTime - reqStartTime
226
233
  };
227
234
  }
228
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/email-ai-tools",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Email AI tools",
5
5
  "main": "index.js",
6
6
  "scripts": {