@postalsys/email-text-tools 1.2.2 → 1.2.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.
@@ -8,6 +8,8 @@ const fetchCmd = global.fetch || nodeFetch;
8
8
  const MAX_TEXT_LENGTH = 6 * 1024;
9
9
  const OPENAI_API_URL = 'https://api.openai.com/v1/chat/completions';
10
10
 
11
+ const PROMPT = `If the following email message includes a reply text, return it. If the message ends with a courtesy greeting, do not include it in the response. Extract the main content text if the message does not contain a reply. Do not add a comment, only return the message text or an empty response if you can not detect any text content. Here is the email message content:`;
12
+
11
13
  async function extractReply(message, apiToken) {
12
14
  let text = message.text;
13
15
  if (!text && message.html) {
@@ -30,7 +32,7 @@ async function extractReply(message, apiToken) {
30
32
  messages: [
31
33
  {
32
34
  role: 'user',
33
- content: `Extract the reply text without the final courtesy closing from the following email message:
35
+ content: `${PROMPT}
34
36
 
35
37
  ${text}`
36
38
  }
@@ -65,6 +67,8 @@ ${text}`
65
67
  throw new Error(`Failed to POST API request`);
66
68
  }
67
69
 
70
+ console.log('OPENAI RESPONSE', JSON.stringify(data, false, 2));
71
+
68
72
  let output =
69
73
  data &&
70
74
  data.choices &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/email-text-tools",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Email text tools",
5
5
  "main": "index.js",
6
6
  "scripts": {