@postalsys/email-ai-tools 1.6.1 → 1.6.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/.github/workflows/release.yaml +2 -2
- package/CHANGELOG.md +14 -0
- package/examples/question.js +1 -1
- package/lib/embeddings-query.js +18 -11
- package/package.json +7 -6
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
id: release
|
|
18
18
|
with:
|
|
19
19
|
release-type: node
|
|
20
|
-
package-name: ${{
|
|
20
|
+
package-name: ${{vars.NPM_MODULE_NAME}}
|
|
21
21
|
pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
|
|
22
22
|
# The logic below handles the npm publication:
|
|
23
23
|
- uses: actions/checkout@v3
|
|
@@ -26,7 +26,7 @@ jobs:
|
|
|
26
26
|
if: ${{ steps.release.outputs.release_created }}
|
|
27
27
|
- uses: actions/setup-node@v3
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
29
|
+
node-version: 20
|
|
30
30
|
registry-url: 'https://registry.npmjs.org'
|
|
31
31
|
if: ${{ steps.release.outputs.release_created }}
|
|
32
32
|
- run: npm ci
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.3](https://github.com/postalsys/email-ai-tools/compare/v1.6.2...v1.6.3) (2023-10-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **chat:** generate and return chat topic ([47755fb](https://github.com/postalsys/email-ai-tools/commit/47755fb0a8625df3bc43c2dc5b410d419e90bc03))
|
|
9
|
+
|
|
10
|
+
## [1.6.2](https://github.com/postalsys/email-ai-tools/compare/v1.6.1...v1.6.2) (2023-10-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **chat:** fixed response parsing for markdown responses ([34c4fdd](https://github.com/postalsys/email-ai-tools/commit/34c4fdda3ee7eca3a66d5f469cb4ee7a1f777083))
|
|
16
|
+
|
|
3
17
|
## [1.6.1](https://github.com/postalsys/email-ai-tools/compare/v1.6.0...v1.6.1) (2023-10-02)
|
|
4
18
|
|
|
5
19
|
|
package/examples/question.js
CHANGED
|
@@ -4,7 +4,7 @@ const { questionQuery } = require('../lib/embeddings-query');
|
|
|
4
4
|
const util = require('util');
|
|
5
5
|
|
|
6
6
|
async function main() {
|
|
7
|
-
const question = '
|
|
7
|
+
const question = 'How much did my last purchase on Amazon cost?';
|
|
8
8
|
|
|
9
9
|
const info = await questionQuery(question, process.env.OPENAI_API_KEY, {
|
|
10
10
|
//gptModel: 'gpt-3.5-turbo',
|
package/lib/embeddings-query.js
CHANGED
|
@@ -49,14 +49,15 @@ const SCHEMA_PROMPT = `
|
|
|
49
49
|
|
|
50
50
|
**Output Guidelines:**
|
|
51
51
|
|
|
52
|
-
1.
|
|
53
|
-
2.
|
|
54
|
-
3.
|
|
55
|
-
4.
|
|
52
|
+
1. Answer the user's question using only the provided context information.
|
|
53
|
+
2. Your objective is to sift through the email context and pinpoint the answer that best addresses the given query.
|
|
54
|
+
3. If no email matches the query criteria, or if the match is ambiguous, refrain from providing an answer.
|
|
55
|
+
4. Limit your sources strictly to the provided email context. External references are not to be utilized.
|
|
56
|
+
5. Format your response as follows:
|
|
56
57
|
- Start with \`Answer:\` followed by the relevant information.
|
|
57
58
|
- On a new line, begin with \`Message-ID:\` and cite the unique Message-ID(s) of the emails you sourced your answer from.
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
6. Ensure that the Message-ID is never embedded within the main body of your response.
|
|
60
|
+
7. Avoid including any additional commentary or annotations.
|
|
60
61
|
|
|
61
62
|
**Context**:
|
|
62
63
|
|
|
@@ -77,6 +78,10 @@ You are analyzing user questions regarding email retrieval from a database. From
|
|
|
77
78
|
- Identify the starting point for the query ('start_time').
|
|
78
79
|
- Identify when to stop the query ('end_time').
|
|
79
80
|
|
|
81
|
+
3. **Topic for the Hypothetical Answer**:
|
|
82
|
+
- Try to answer the question without knowing the actual context and generate a topic for the answer.
|
|
83
|
+
- For missing context assume any generic or likely value
|
|
84
|
+
|
|
80
85
|
**Context**:
|
|
81
86
|
|
|
82
87
|
- The current time is '${new Date().toUTCString()}'.
|
|
@@ -90,21 +95,23 @@ You are analyzing user questions regarding email retrieval from a database. From
|
|
|
90
95
|
- For unspecified time zones, timestamps should follow the 'YYYY-MM-DD hh:mm:ss' format.
|
|
91
96
|
- If only the date is known, use the 'YYYY-MM-DD' format.
|
|
92
97
|
- Assume the week starts on Monday.
|
|
98
|
+
- Identify the topic for the question.
|
|
93
99
|
- Your response should be structured in JSON, strictly adhering to the schema:
|
|
94
100
|
\`\`\`
|
|
95
101
|
{
|
|
96
102
|
"ordering": "",
|
|
97
103
|
"start_time": "",
|
|
98
|
-
"end_time": ""
|
|
104
|
+
"end_time": "",
|
|
105
|
+
"topic": ""
|
|
99
106
|
}
|
|
100
107
|
\`\`\`
|
|
101
108
|
- Example Queries and Responses:
|
|
102
109
|
- **Query**: "When is the next conference event?"
|
|
103
|
-
**Response**: \`{"ordering":"newer_first"}\`
|
|
110
|
+
**Response**: \`{"ordering":"newer_first", "topic": "Conference event happening next week"}\`
|
|
104
111
|
- **Query**: "What did James write to me about last Friday?" (assuming that current time is "2023-10-02")
|
|
105
|
-
**Response**: \`{"ordering":"best_match", "start_time": "2023-09-29", "end_time": "2023-09-30"}\`
|
|
112
|
+
**Response**: \`{"ordering":"best_match", "start_time": "2023-09-29", "end_time": "2023-09-30", "topic": "A message from James about an event in 2023-09-30"}\`
|
|
106
113
|
- **Query**: "When did I receive my first Amazon invoice?"
|
|
107
|
-
**Response**: \`{"ordering":"older_first"}\`
|
|
114
|
+
**Response**: \`{"ordering":"older_first", "topic": "Amazon invoice sent last week"}\`
|
|
108
115
|
|
|
109
116
|
**User's Query**:
|
|
110
117
|
Process the user question:
|
|
@@ -289,7 +296,7 @@ ${promptText}
|
|
|
289
296
|
output
|
|
290
297
|
.trim()
|
|
291
298
|
.replace(/\r?\n/g, '\n')
|
|
292
|
-
.split(/(^|\n)(Answer:|Message-ID:)/gi)
|
|
299
|
+
.split(/(^|\n)(?:[*`]*)(Answer:|Message-ID:)(?:[*`]*)/gi)
|
|
293
300
|
.map(v => v.trim())
|
|
294
301
|
.filter(v => v)
|
|
295
302
|
.forEach(val => {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postalsys/email-ai-tools",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Email AI tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -23,13 +24,13 @@
|
|
|
23
24
|
"mailparser": "3.6.5"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@postalsys/email-text-tools": "2.1.
|
|
27
|
+
"@postalsys/email-text-tools": "2.1.2",
|
|
27
28
|
"gpt3-tokenizer": "1.1.5",
|
|
28
29
|
"libmime": "5.2.1",
|
|
29
30
|
"linkify-it": "4.0.1",
|
|
30
|
-
"nodemailer": "6.9.
|
|
31
|
+
"nodemailer": "6.9.6",
|
|
31
32
|
"punycode": "2.3.0",
|
|
32
|
-
"tlds": "1.
|
|
33
|
-
"undici": "5.
|
|
33
|
+
"tlds": "1.243.0",
|
|
34
|
+
"undici": "5.26.4"
|
|
34
35
|
}
|
|
35
36
|
}
|