@realtimex/email-automator 2.3.7 → 2.3.8
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.
|
@@ -48,13 +48,13 @@ export interface EmailContext {
|
|
|
48
48
|
|
|
49
49
|
export class IntelligenceService {
|
|
50
50
|
private client: OpenAI | null = null;
|
|
51
|
-
private model: string;
|
|
51
|
+
private model: string = 'gpt-4o-mini';
|
|
52
52
|
private isConfigured: boolean = false;
|
|
53
53
|
|
|
54
54
|
constructor(overrides?: { model?: string; baseUrl?: string; apiKey?: string }) {
|
|
55
55
|
const apiKey = overrides?.apiKey || config.llm.apiKey;
|
|
56
56
|
const baseUrl = overrides?.baseUrl || config.llm.baseUrl;
|
|
57
|
-
this.model = overrides?.model || config.llm.model;
|
|
57
|
+
this.model = overrides?.model || config.llm.model || 'gpt-4o-mini';
|
|
58
58
|
|
|
59
59
|
// Allow local LLM servers (LM Studio, Ollama) or custom endpoints that don't need API keys
|
|
60
60
|
// We assume any custom baseUrl might be a local/private instance.
|
|
@@ -111,12 +111,16 @@ Do NOT include any greetings, chatter, or special tokens like <|channel|> in you
|
|
|
111
111
|
Return ONLY a valid JSON object.
|
|
112
112
|
|
|
113
113
|
Definitions for Categories:
|
|
114
|
-
- "
|
|
114
|
+
- "spam": Junk, suspicious, unwanted
|
|
115
|
+
- "newsletter": Subscribed content, digests
|
|
115
116
|
- "promotional": Marketing, sales, discounts
|
|
116
117
|
- "transactional": Receipts, shipping, confirmations
|
|
117
118
|
- "social": LinkedIn, friends, social updates
|
|
118
|
-
- "
|
|
119
|
-
- "
|
|
119
|
+
- "support": Help desk, customer service
|
|
120
|
+
- "client": Business clients, customers
|
|
121
|
+
- "internal": Company internal communications
|
|
122
|
+
- "personal": Friends, family, personal matters
|
|
123
|
+
- "other": Anything else
|
|
120
124
|
|
|
121
125
|
Context:
|
|
122
126
|
- Current Date: ${new Date().toISOString()}
|
|
@@ -156,13 +160,14 @@ REQUIRED JSON STRUCTURE:
|
|
|
156
160
|
|
|
157
161
|
let rawResponse = '';
|
|
158
162
|
try {
|
|
159
|
-
//
|
|
163
|
+
// Request JSON response format for reliable parsing
|
|
160
164
|
const response = await this.client!.chat.completions.create({
|
|
161
165
|
model: this.model,
|
|
162
166
|
messages: [
|
|
163
167
|
{ role: 'system', content: systemPrompt },
|
|
164
168
|
{ role: 'user', content: cleanedContent || '[Empty email body]' },
|
|
165
169
|
],
|
|
170
|
+
response_format: { type: 'json_object' },
|
|
166
171
|
temperature: 0.1,
|
|
167
172
|
});
|
|
168
173
|
|
|
@@ -26,12 +26,12 @@ export const EmailAnalysisSchema = z.object({
|
|
|
26
26
|
});
|
|
27
27
|
export class IntelligenceService {
|
|
28
28
|
client = null;
|
|
29
|
-
model;
|
|
29
|
+
model = 'gpt-4o-mini';
|
|
30
30
|
isConfigured = false;
|
|
31
31
|
constructor(overrides) {
|
|
32
32
|
const apiKey = overrides?.apiKey || config.llm.apiKey;
|
|
33
33
|
const baseUrl = overrides?.baseUrl || config.llm.baseUrl;
|
|
34
|
-
this.model = overrides?.model || config.llm.model;
|
|
34
|
+
this.model = overrides?.model || config.llm.model || 'gpt-4o-mini';
|
|
35
35
|
// Allow local LLM servers (LM Studio, Ollama) or custom endpoints that don't need API keys
|
|
36
36
|
// We assume any custom baseUrl might be a local/private instance.
|
|
37
37
|
const isCustomEndpoint = baseUrl && !baseUrl.includes('api.openai.com');
|
|
@@ -84,12 +84,16 @@ Do NOT include any greetings, chatter, or special tokens like <|channel|> in you
|
|
|
84
84
|
Return ONLY a valid JSON object.
|
|
85
85
|
|
|
86
86
|
Definitions for Categories:
|
|
87
|
-
- "
|
|
87
|
+
- "spam": Junk, suspicious, unwanted
|
|
88
|
+
- "newsletter": Subscribed content, digests
|
|
88
89
|
- "promotional": Marketing, sales, discounts
|
|
89
90
|
- "transactional": Receipts, shipping, confirmations
|
|
90
91
|
- "social": LinkedIn, friends, social updates
|
|
91
|
-
- "
|
|
92
|
-
- "
|
|
92
|
+
- "support": Help desk, customer service
|
|
93
|
+
- "client": Business clients, customers
|
|
94
|
+
- "internal": Company internal communications
|
|
95
|
+
- "personal": Friends, family, personal matters
|
|
96
|
+
- "other": Anything else
|
|
93
97
|
|
|
94
98
|
Context:
|
|
95
99
|
- Current Date: ${new Date().toISOString()}
|
|
@@ -128,13 +132,14 @@ REQUIRED JSON STRUCTURE:
|
|
|
128
132
|
}
|
|
129
133
|
let rawResponse = '';
|
|
130
134
|
try {
|
|
131
|
-
//
|
|
135
|
+
// Request JSON response format for reliable parsing
|
|
132
136
|
const response = await this.client.chat.completions.create({
|
|
133
137
|
model: this.model,
|
|
134
138
|
messages: [
|
|
135
139
|
{ role: 'system', content: systemPrompt },
|
|
136
140
|
{ role: 'user', content: cleanedContent || '[Empty email body]' },
|
|
137
141
|
],
|
|
142
|
+
response_format: { type: 'json_object' },
|
|
138
143
|
temperature: 0.1,
|
|
139
144
|
});
|
|
140
145
|
rawResponse = response.choices[0]?.message?.content || '';
|