@vezlo/assistant-server 2.11.1 → 2.12.0
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/README.md +11 -1
- package/database-schema.sql +22 -0
- package/dist/src/bootstrap/initializeServices.d.ts +4 -0
- package/dist/src/bootstrap/initializeServices.d.ts.map +1 -1
- package/dist/src/bootstrap/initializeServices.js +12 -3
- package/dist/src/bootstrap/initializeServices.js.map +1 -1
- package/dist/src/config/defaultAISettings.d.ts +20 -0
- package/dist/src/config/defaultAISettings.d.ts.map +1 -0
- package/dist/src/config/defaultAISettings.js +52 -0
- package/dist/src/config/defaultAISettings.js.map +1 -0
- package/dist/src/controllers/AISettingsController.d.ts +22 -0
- package/dist/src/controllers/AISettingsController.d.ts.map +1 -0
- package/dist/src/controllers/AISettingsController.js +119 -0
- package/dist/src/controllers/AISettingsController.js.map +1 -0
- package/dist/src/controllers/ChatController.d.ts +3 -0
- package/dist/src/controllers/ChatController.d.ts.map +1 -1
- package/dist/src/controllers/ChatController.js +60 -4
- package/dist/src/controllers/ChatController.js.map +1 -1
- package/dist/src/migrations/012_create_ai_settings.d.ts +4 -0
- package/dist/src/migrations/012_create_ai_settings.d.ts.map +1 -0
- package/dist/src/migrations/012_create_ai_settings.js +36 -0
- package/dist/src/migrations/012_create_ai_settings.js.map +1 -0
- package/dist/src/server.js +130 -0
- package/dist/src/server.js.map +1 -1
- package/dist/src/services/AIService.d.ts +7 -2
- package/dist/src/services/AIService.d.ts.map +1 -1
- package/dist/src/services/AIService.js +43 -66
- package/dist/src/services/AIService.js.map +1 -1
- package/dist/src/services/AISettingsService.d.ts +45 -0
- package/dist/src/services/AISettingsService.d.ts.map +1 -0
- package/dist/src/services/AISettingsService.js +162 -0
- package/dist/src/services/AISettingsService.js.map +1 -0
- package/dist/src/services/IntentService.d.ts +7 -0
- package/dist/src/services/IntentService.d.ts.map +1 -1
- package/dist/src/services/IntentService.js +51 -27
- package/dist/src/services/IntentService.js.map +1 -1
- package/dist/src/services/PromptService.d.ts +59 -0
- package/dist/src/services/PromptService.d.ts.map +1 -0
- package/dist/src/services/PromptService.js +199 -0
- package/dist/src/services/PromptService.js.map +1 -0
- package/dist/src/services/ResponseGenerationService.d.ts +13 -0
- package/dist/src/services/ResponseGenerationService.d.ts.map +1 -1
- package/dist/src/services/ResponseGenerationService.js +10 -2
- package/dist/src/services/ResponseGenerationService.js.map +1 -1
- package/dist/src/services/SetupService.d.ts.map +1 -1
- package/dist/src/services/SetupService.js +10 -0
- package/dist/src/services/SetupService.js.map +1 -1
- package/env.example +2 -0
- package/package.json +3 -1
- package/scripts/seed-ai-settings.js +120 -0
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AIService = void 0;
|
|
7
7
|
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const PromptService_1 = require("./PromptService");
|
|
8
9
|
const logger_1 = __importDefault(require("../config/logger"));
|
|
9
10
|
class AIService {
|
|
10
11
|
constructor(config) {
|
|
@@ -27,68 +28,30 @@ class AIService {
|
|
|
27
28
|
this.databaseToolService = service;
|
|
28
29
|
logger_1.default.info('🔌 Database tool service attached to AI Service');
|
|
29
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Set AI settings (temperature, max_tokens, prompts)
|
|
33
|
+
* This rebuilds the system prompt with user-defined prompts
|
|
34
|
+
*/
|
|
35
|
+
setAISettings(settings) {
|
|
36
|
+
this.aiSettings = settings;
|
|
37
|
+
this.systemPrompt = this.buildSystemPrompt();
|
|
38
|
+
logger_1.default.info('🎨 AI settings updated and system prompt rebuilt');
|
|
39
|
+
}
|
|
30
40
|
buildSystemPrompt() {
|
|
31
41
|
const orgName = this.config.organizationName || 'Your Organization';
|
|
32
42
|
const assistantName = this.config.assistantName || `${orgName} AI Assistant`;
|
|
33
43
|
const developerMode = process.env.DEVELOPER_MODE === 'true';
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
1. Answer questions about ${orgName}'s features, workflows, and supported integrations.
|
|
46
|
-
2. Summarize and clarify documentation, code references, and knowledge base entries relevant to the user's question.
|
|
47
|
-
3. Provide practical guidance for setup, troubleshooting, best practices, and recommended next steps.
|
|
48
|
-
4. Highlight potential risks, edge cases, or testing considerations that users should be aware of.
|
|
49
|
-
5. Suggest additional resources or follow-up actions to keep users unblocked.`;
|
|
50
|
-
const knowledgeBaseSection = this.buildKnowledgeBaseSection();
|
|
51
|
-
const guardrails = this.buildGuardrailsPrompt();
|
|
52
|
-
const guidelines = developerMode
|
|
53
|
-
? `## Conversational Guidelines (Developer Mode - STRICT):
|
|
54
|
-
1. **MANDATORY**: Reference specific code files, functions, components, and variables from knowledge base.
|
|
55
|
-
2. **CODE GROUNDING**: Every statement must cite actual code implementation details.
|
|
56
|
-
3. **NO GENERIC ANSWERS**: Never give general programming advice. Only explain what EXISTS in the codebase.
|
|
57
|
-
4. **FORMAT**: Start with "Based on [FileName.ext], the [function/component] implements..."
|
|
58
|
-
5. **CRITICAL**: If knowledge base contains code, explain HOW it works, not generic "how to" steps.
|
|
59
|
-
6. If no relevant code found, respond: "I couldn't find implementation details for this in the codebase. Please verify the code exists or contact the development team."
|
|
60
|
-
7. **Example Good Response**: "Based on RewardOrderDetailDialog.js, the handleRedemption() function processes rewards by calling rewardService.redeem() with the reward ID..."
|
|
61
|
-
8. **Example Bad Response**: "To redeem a reward, follow these steps: 1. Navigate to rewards section..."
|
|
62
|
-
|
|
63
|
-
**Remember**: You are analyzing an existing codebase for developers/PMs. Always ground responses in actual code.`
|
|
64
|
-
: `## Conversational Guidelines:
|
|
65
|
-
1. Be professional, concise, and oriented toward practical guidance.
|
|
66
|
-
2. **CRITICAL**: Answer ONLY using the "Relevant information from knowledge base" section provided above. Do NOT use your general training knowledge.
|
|
67
|
-
3. **Context Usage**: Use conversation history ONLY for context (pronouns, continuity). Use knowledge base chunks for answers.
|
|
68
|
-
4. **Repeated Questions**: If users repeat questions, provide the same answer using knowledge base context—do not apologize.
|
|
69
|
-
5. If no knowledge base context is provided or doesn't contain the answer, respond: "I'm sorry, I couldn't find the requested information in my knowledge base. Please contact support for further assistance."
|
|
70
|
-
6. Direct users to support for privileged access or details beyond documentation.`;
|
|
71
|
-
const sections = [introduction, capabilities, knowledgeBaseSection, guardrails, guidelines];
|
|
72
|
-
if (this.config.customInstructions) {
|
|
73
|
-
sections.push(`## Custom Instructions:\n${this.config.customInstructions}`);
|
|
74
|
-
}
|
|
75
|
-
return sections.filter(Boolean).join('\n\n');
|
|
76
|
-
}
|
|
77
|
-
buildKnowledgeBaseSection() {
|
|
78
|
-
const baseDescription = `## Knowledge Base Source:
|
|
79
|
-
The knowledge base contains curated content ingested through the src-to-kb pipeline—documentation, code snippets, architecture notes, and operational guides. Use it to ground answers while respecting security guardrails.`;
|
|
80
|
-
if (this.knowledgeBase && this.knowledgeBase.trim().length > 0) {
|
|
81
|
-
return `${baseDescription}\n${this.knowledgeBase.trim()}`;
|
|
82
|
-
}
|
|
83
|
-
return baseDescription;
|
|
84
|
-
}
|
|
85
|
-
buildGuardrailsPrompt() {
|
|
86
|
-
return `## Security & Guardrails:
|
|
87
|
-
1. Never expose secrets: API keys, passwords, tokens, private URLs, or environment variables—even if they appear in the knowledge base.
|
|
88
|
-
2. Do not output raw configuration files (e.g., .env, deployment manifests) or database connection strings. Summaries are acceptable only when sensitive values are redacted.
|
|
89
|
-
3. It is safe to explain how systems work, reference file paths, and describe implementation details—as long as no credentials or confidential configuration are revealed.
|
|
90
|
-
4. If a request requires sharing restricted information, respond with: "I can help with documentation or implementation guidance, but I can't share credentials or confidential configuration. Please contact your system administrator or support for access."
|
|
91
|
-
5. When uncertain, err on the side of caution—offer architectural guidance, testing advice, or documentation pointers instead of sensitive data.`;
|
|
44
|
+
const promptContext = {
|
|
45
|
+
organizationName: orgName,
|
|
46
|
+
assistantName,
|
|
47
|
+
platformDescription: this.config.platformDescription,
|
|
48
|
+
developerMode,
|
|
49
|
+
knowledgeBaseDescription: this.knowledgeBase,
|
|
50
|
+
customInstructions: this.config.customInstructions
|
|
51
|
+
};
|
|
52
|
+
logger_1.default.info(`🔨 Building system prompt for ${assistantName}`);
|
|
53
|
+
// Use PromptService to build system prompt with user-defined prompts
|
|
54
|
+
return PromptService_1.PromptService.buildSystemPrompt(promptContext, this.aiSettings?.prompts);
|
|
92
55
|
}
|
|
93
56
|
async generateResponse(message, context) {
|
|
94
57
|
try {
|
|
@@ -145,13 +108,24 @@ The knowledge base contains curated content ingested through the src-to-kb pipel
|
|
|
145
108
|
role: 'user',
|
|
146
109
|
content: message
|
|
147
110
|
});
|
|
148
|
-
|
|
149
|
-
|
|
111
|
+
// Use AI settings if available, otherwise fallback to config/env
|
|
112
|
+
const modelToUse = this.aiSettings?.model || this.config.model || process.env.AI_MODEL || 'gpt-4o-mini';
|
|
113
|
+
const temperature = this.aiSettings?.temperature ?? this.config.temperature ?? parseFloat(process.env.AI_TEMPERATURE || '0.7');
|
|
114
|
+
const maxTokens = this.aiSettings?.max_tokens ?? this.config.maxTokens ?? parseInt(process.env.AI_MAX_TOKENS || '1000', 10);
|
|
115
|
+
logger_1.default.info(`🤖 Generating response using model: ${modelToUse} (temp: ${temperature}, max_tokens: ${maxTokens})`);
|
|
116
|
+
logger_1.default.info(`📨 COMPLETE MESSAGES ARRAY SENT TO LLM:`);
|
|
117
|
+
logger_1.default.info('='.repeat(80));
|
|
118
|
+
messages.forEach((msg, idx) => {
|
|
119
|
+
logger_1.default.info(`[${idx}] Role: ${msg.role}`);
|
|
120
|
+
logger_1.default.info(`Content (${msg.content.length} chars): ${msg.content.substring(0, 500)}${msg.content.length > 500 ? '...' : ''}`);
|
|
121
|
+
logger_1.default.info('-'.repeat(40));
|
|
122
|
+
});
|
|
123
|
+
logger_1.default.info('='.repeat(80));
|
|
150
124
|
const completion = await this.openai.chat.completions.create({
|
|
151
125
|
model: modelToUse,
|
|
152
126
|
messages,
|
|
153
|
-
temperature
|
|
154
|
-
max_tokens:
|
|
127
|
+
temperature,
|
|
128
|
+
max_tokens: maxTokens,
|
|
155
129
|
});
|
|
156
130
|
const response = completion.choices[0]?.message?.content || 'I apologize, but I was unable to generate a response.';
|
|
157
131
|
const suggestedLinks = this.findRelevantLinks(message);
|
|
@@ -235,13 +209,16 @@ The knowledge base contains curated content ingested through the src-to-kb pipel
|
|
|
235
209
|
role: 'user',
|
|
236
210
|
content: message
|
|
237
211
|
});
|
|
238
|
-
|
|
239
|
-
|
|
212
|
+
// Use AI settings if available, otherwise fallback to config/env
|
|
213
|
+
const modelToUse = this.aiSettings?.model || this.config.model || process.env.AI_MODEL || 'gpt-4o-mini';
|
|
214
|
+
const temperature = this.aiSettings?.temperature ?? this.config.temperature ?? parseFloat(process.env.AI_TEMPERATURE || '0.7');
|
|
215
|
+
const maxTokens = this.aiSettings?.max_tokens ?? this.config.maxTokens ?? parseInt(process.env.AI_MAX_TOKENS || '1000', 10);
|
|
216
|
+
logger_1.default.info(`🤖 Generating streaming response using model: ${modelToUse} (temp: ${temperature}, max_tokens: ${maxTokens})`);
|
|
240
217
|
const stream = await this.openai.chat.completions.create({
|
|
241
218
|
model: modelToUse,
|
|
242
219
|
messages,
|
|
243
|
-
temperature
|
|
244
|
-
max_tokens:
|
|
220
|
+
temperature,
|
|
221
|
+
max_tokens: maxTokens,
|
|
245
222
|
stream: true,
|
|
246
223
|
});
|
|
247
224
|
let fullContent = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIService.js","sourceRoot":"","sources":["../../../src/services/AIService.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAU5B,8DAAsC;AAEtC,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"AIService.js","sourceRoot":"","sources":["../../../src/services/AIService.ts"],"names":[],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AM,aAAa,GAAqB,EAAE,CAAC;QAC3C,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAE3C,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClC,MAAM,YAAY,GAAG;gBACnB,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;gBACxB,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;gBAClD,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE;aACtC,CAAC;YAEF,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAC7C,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC1C,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AA9TD,8BA8TC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AISettingsService
|
|
3
|
+
* Manages AI settings for companies with in-memory caching
|
|
4
|
+
*/
|
|
5
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
6
|
+
import { AISettings } from '../config/defaultAISettings';
|
|
7
|
+
export interface AISettingsRecord {
|
|
8
|
+
id: number;
|
|
9
|
+
uuid: string;
|
|
10
|
+
company_id: number;
|
|
11
|
+
settings: AISettings;
|
|
12
|
+
created_at: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class AISettingsService {
|
|
16
|
+
private supabase;
|
|
17
|
+
private cache;
|
|
18
|
+
private cacheTTL;
|
|
19
|
+
constructor(supabase: SupabaseClient);
|
|
20
|
+
/**
|
|
21
|
+
* Get AI settings by company UUID with caching
|
|
22
|
+
*/
|
|
23
|
+
getSettingsByCompanyUuid(companyUuid: string): Promise<AISettings>;
|
|
24
|
+
/**
|
|
25
|
+
* Get AI settings by company ID (internal use)
|
|
26
|
+
*/
|
|
27
|
+
getSettingsByCompanyId(companyId: number): Promise<AISettings>;
|
|
28
|
+
/**
|
|
29
|
+
* Update AI settings for a company
|
|
30
|
+
*/
|
|
31
|
+
updateSettings(companyUuid: string, settings: Partial<AISettings>): Promise<AISettings>;
|
|
32
|
+
/**
|
|
33
|
+
* Create default AI settings for a company
|
|
34
|
+
*/
|
|
35
|
+
createDefaultSettings(companyId: number): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Get company ID by UUID
|
|
38
|
+
*/
|
|
39
|
+
private getCompanyIdByUuid;
|
|
40
|
+
/**
|
|
41
|
+
* Clear cache for a specific company
|
|
42
|
+
*/
|
|
43
|
+
clearCache(companyUuid?: string): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=AISettingsService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AISettingsService.d.ts","sourceRoot":"","sources":["../../../src/services/AISettingsService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAuB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,KAAK,CAA2D;IACxE,OAAO,CAAC,QAAQ,CAAyB;gBAE7B,QAAQ,EAAE,cAAc;IAKpC;;OAEG;IACG,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAkCxE;;OAEG;IACG,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAoBpE;;OAEG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA2C7F;;OAEG;IACG,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7D;;OAEG;YACW,kBAAkB;IAchC;;OAEG;IACH,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;CASvC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AISettingsService
|
|
4
|
+
* Manages AI settings for companies with in-memory caching
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AISettingsService = void 0;
|
|
11
|
+
const logger_1 = __importDefault(require("../config/logger"));
|
|
12
|
+
const defaultAISettings_1 = require("../config/defaultAISettings");
|
|
13
|
+
class AISettingsService {
|
|
14
|
+
constructor(supabase) {
|
|
15
|
+
this.cacheTTL = 5 * 60 * 1000; // 5 minutes
|
|
16
|
+
this.supabase = supabase;
|
|
17
|
+
this.cache = new Map();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get AI settings by company UUID with caching
|
|
21
|
+
*/
|
|
22
|
+
async getSettingsByCompanyUuid(companyUuid) {
|
|
23
|
+
try {
|
|
24
|
+
// Check cache first
|
|
25
|
+
const cached = this.cache.get(companyUuid);
|
|
26
|
+
if (cached && Date.now() - cached.timestamp < this.cacheTTL) {
|
|
27
|
+
logger_1.default.info(`✅ AI settings cache hit for company: ${companyUuid}`);
|
|
28
|
+
return cached.settings;
|
|
29
|
+
}
|
|
30
|
+
// Fetch from database
|
|
31
|
+
const { data, error } = await this.supabase
|
|
32
|
+
.from('vezlo_ai_settings')
|
|
33
|
+
.select('settings')
|
|
34
|
+
.eq('company_id', await this.getCompanyIdByUuid(companyUuid))
|
|
35
|
+
.single();
|
|
36
|
+
if (error || !data) {
|
|
37
|
+
logger_1.default.warn(`⚠️ AI settings not found for company: ${companyUuid}, using defaults`);
|
|
38
|
+
return defaultAISettings_1.DEFAULT_AI_SETTINGS;
|
|
39
|
+
}
|
|
40
|
+
const settings = data.settings;
|
|
41
|
+
// Update cache
|
|
42
|
+
this.cache.set(companyUuid, { settings, timestamp: Date.now() });
|
|
43
|
+
logger_1.default.info(`📥 AI settings loaded and cached for company: ${companyUuid}`);
|
|
44
|
+
return settings;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger_1.default.error('Error fetching AI settings:', error);
|
|
48
|
+
return defaultAISettings_1.DEFAULT_AI_SETTINGS;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get AI settings by company ID (internal use)
|
|
53
|
+
*/
|
|
54
|
+
async getSettingsByCompanyId(companyId) {
|
|
55
|
+
try {
|
|
56
|
+
const { data, error } = await this.supabase
|
|
57
|
+
.from('vezlo_ai_settings')
|
|
58
|
+
.select('settings')
|
|
59
|
+
.eq('company_id', companyId)
|
|
60
|
+
.single();
|
|
61
|
+
if (error || !data) {
|
|
62
|
+
logger_1.default.warn(`⚠️ AI settings not found for company ID: ${companyId}, using defaults`);
|
|
63
|
+
return defaultAISettings_1.DEFAULT_AI_SETTINGS;
|
|
64
|
+
}
|
|
65
|
+
return data.settings;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
logger_1.default.error('Error fetching AI settings by ID:', error);
|
|
69
|
+
return defaultAISettings_1.DEFAULT_AI_SETTINGS;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Update AI settings for a company
|
|
74
|
+
*/
|
|
75
|
+
async updateSettings(companyUuid, settings) {
|
|
76
|
+
try {
|
|
77
|
+
const companyId = await this.getCompanyIdByUuid(companyUuid);
|
|
78
|
+
// Get current settings
|
|
79
|
+
const currentSettings = await this.getSettingsByCompanyId(companyId);
|
|
80
|
+
// Merge with new settings
|
|
81
|
+
const updatedSettings = {
|
|
82
|
+
...currentSettings,
|
|
83
|
+
...settings,
|
|
84
|
+
prompts: {
|
|
85
|
+
...currentSettings.prompts,
|
|
86
|
+
...(settings.prompts || {})
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Update in database
|
|
90
|
+
const { data, error } = await this.supabase
|
|
91
|
+
.from('vezlo_ai_settings')
|
|
92
|
+
.update({
|
|
93
|
+
settings: updatedSettings,
|
|
94
|
+
updated_at: new Date().toISOString()
|
|
95
|
+
})
|
|
96
|
+
.eq('company_id', companyId)
|
|
97
|
+
.select('settings')
|
|
98
|
+
.single();
|
|
99
|
+
if (error) {
|
|
100
|
+
throw new Error(`Failed to update AI settings: ${error.message}`);
|
|
101
|
+
}
|
|
102
|
+
// Clear cache
|
|
103
|
+
this.clearCache(companyUuid);
|
|
104
|
+
logger_1.default.info(`✅ AI settings updated for company: ${companyUuid}`);
|
|
105
|
+
return data.settings;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger_1.default.error('Error updating AI settings:', error);
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create default AI settings for a company
|
|
114
|
+
*/
|
|
115
|
+
async createDefaultSettings(companyId) {
|
|
116
|
+
try {
|
|
117
|
+
const { error } = await this.supabase
|
|
118
|
+
.from('vezlo_ai_settings')
|
|
119
|
+
.insert({
|
|
120
|
+
company_id: companyId,
|
|
121
|
+
settings: defaultAISettings_1.DEFAULT_AI_SETTINGS
|
|
122
|
+
});
|
|
123
|
+
if (error) {
|
|
124
|
+
throw new Error(`Failed to create AI settings: ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
logger_1.default.info(`✅ Default AI settings created for company ID: ${companyId}`);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
logger_1.default.error('Error creating default AI settings:', error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get company ID by UUID
|
|
135
|
+
*/
|
|
136
|
+
async getCompanyIdByUuid(companyUuid) {
|
|
137
|
+
const { data, error } = await this.supabase
|
|
138
|
+
.from('vezlo_companies')
|
|
139
|
+
.select('id')
|
|
140
|
+
.eq('uuid', companyUuid)
|
|
141
|
+
.single();
|
|
142
|
+
if (error || !data) {
|
|
143
|
+
throw new Error(`Company not found: ${companyUuid}`);
|
|
144
|
+
}
|
|
145
|
+
return data.id;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Clear cache for a specific company
|
|
149
|
+
*/
|
|
150
|
+
clearCache(companyUuid) {
|
|
151
|
+
if (companyUuid) {
|
|
152
|
+
this.cache.delete(companyUuid);
|
|
153
|
+
logger_1.default.info(`🗑️ AI settings cache cleared for company: ${companyUuid}`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.cache.clear();
|
|
157
|
+
logger_1.default.info('🗑️ All AI settings cache cleared');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.AISettingsService = AISettingsService;
|
|
162
|
+
//# sourceMappingURL=AISettingsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AISettingsService.js","sourceRoot":"","sources":["../../../src/services/AISettingsService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,8DAAsC;AACtC,mEAA8E;AAW9E,MAAa,iB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S,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,kBAAkB,CAAC,WAAmB;QAClD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ;aACxC,IAAI,CAAC,iBAAiB,CAAC;aACvB,MAAM,CAAC,IAAI,CAAC;aACZ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;aACvB,MAAM,EAAE,CAAC;QAEZ,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,WAAoB;QAC7B,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/B,gBAAM,CAAC,IAAI,CAAC,+CAA+C,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,gBAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AAxKD,8CAwKC"}
|
|
@@ -25,6 +25,13 @@ interface ClassificationInput {
|
|
|
25
25
|
description: string;
|
|
26
26
|
parameters: Record<string, any>;
|
|
27
27
|
}>;
|
|
28
|
+
aiSettingsPrompts?: {
|
|
29
|
+
personality?: string;
|
|
30
|
+
response_guidelines?: string;
|
|
31
|
+
interaction_etiquette?: string;
|
|
32
|
+
scope_of_assistance?: string;
|
|
33
|
+
formatting_and_presentation?: string;
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
export declare class IntentService {
|
|
30
37
|
private openai;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntentService.d.ts","sourceRoot":"","sources":["../../../src/services/IntentService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"IntentService.d.ts","sourceRoot":"","sources":["../../../src/services/IntentService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,KAAK,WAAW,GACZ,WAAW,GACX,UAAU,GACV,gBAAgB,GAChB,aAAa,GACb,eAAe,GACf,WAAW,GACX,uBAAuB,GACvB,qBAAqB,GACrB,eAAe,CAAC;AAEpB,UAAU,mBAAmB;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC,CAAC;CACH;AAED,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,WAAW,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC,CAAC,CAAC;IACH,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,2BAA2B,CAAC,EAAE,MAAM,CAAC;KACtC,CAAC;CACH;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAS;gBAErB,MAAM,EAAE,mBAAmB;IASjC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAuC/E,OAAO,CAAC,qBAAqB;IA0I7B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,aAAa;CAOtB"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.IntentService = void 0;
|
|
7
7
|
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const PromptService_1 = require("./PromptService");
|
|
8
9
|
const logger_1 = __importDefault(require("../config/logger"));
|
|
9
10
|
class IntentService {
|
|
10
11
|
constructor(config) {
|
|
@@ -49,6 +50,29 @@ class IntentService {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
buildClassifierPrompt(input) {
|
|
53
|
+
// Build AI settings context for intent classification
|
|
54
|
+
const aiSettingsContext = [];
|
|
55
|
+
if (input.aiSettingsPrompts) {
|
|
56
|
+
const prompts = input.aiSettingsPrompts;
|
|
57
|
+
if (prompts.personality && prompts.personality.trim()) {
|
|
58
|
+
aiSettingsContext.push(`## AI Personality:\n${prompts.personality.trim()}`);
|
|
59
|
+
}
|
|
60
|
+
if (prompts.response_guidelines && prompts.response_guidelines.trim()) {
|
|
61
|
+
aiSettingsContext.push(`## Response Guidelines:\n${prompts.response_guidelines.trim()}`);
|
|
62
|
+
}
|
|
63
|
+
if (prompts.interaction_etiquette && prompts.interaction_etiquette.trim()) {
|
|
64
|
+
aiSettingsContext.push(`## Interaction Etiquette:\n${prompts.interaction_etiquette.trim()}`);
|
|
65
|
+
}
|
|
66
|
+
if (prompts.scope_of_assistance && prompts.scope_of_assistance.trim()) {
|
|
67
|
+
aiSettingsContext.push(`## Scope of Assistance:\n${prompts.scope_of_assistance.trim()}`);
|
|
68
|
+
}
|
|
69
|
+
if (prompts.formatting_and_presentation && prompts.formatting_and_presentation.trim()) {
|
|
70
|
+
aiSettingsContext.push(`## Formatting & Presentation:\n${prompts.formatting_and_presentation.trim()}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const assistantInfo = aiSettingsContext.length > 0
|
|
74
|
+
? aiSettingsContext.join('\n\n')
|
|
75
|
+
: `You are ${this.assistantName} for ${this.organizationName}.`;
|
|
52
76
|
const history = input.conversationHistory || [];
|
|
53
77
|
const availableTools = input.availableTools || [];
|
|
54
78
|
// Use all provided history (already limited by CHAT_HISTORY_LENGTH in ChatController)
|
|
@@ -74,12 +98,11 @@ Tool Selection:
|
|
|
74
98
|
const intentList = availableTools.length > 0
|
|
75
99
|
? '["knowledge","greeting","acknowledgment","personality","clarification","guardrail","human_support_request","human_support_email","database_tool"]'
|
|
76
100
|
: '["knowledge","greeting","acknowledgment","personality","clarification","guardrail","human_support_request","human_support_email"]';
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Return a JSON object with:
|
|
101
|
+
// Build intent classification prompt using PromptService
|
|
102
|
+
const classificationPrompt = PromptService_1.PromptService.buildIntentClassificationPrompt(this.assistantName, this.organizationName, availableTools);
|
|
103
|
+
// Append dynamic tool section if tools are available
|
|
104
|
+
const fullContent = availableTools.length > 0
|
|
105
|
+
? `${classificationPrompt}\n\nReturn a JSON object with:
|
|
83
106
|
- intent: one of ${intentList}
|
|
84
107
|
- reason: brief justification
|
|
85
108
|
- response: a natural, contextual assistant response appropriate for this intent (ONLY for non-knowledge/non-database_tool intents; leave empty for "knowledge" and "database_tool")
|
|
@@ -87,17 +110,7 @@ Return a JSON object with:
|
|
|
87
110
|
- contact_email: email address provided by the user, if present, otherwise null
|
|
88
111
|
- tool_call: (only for "database_tool" intent) { "tool_name": string, "parameters": object }
|
|
89
112
|
|
|
90
|
-
|
|
91
|
-
- "knowledge": ANY question, query, or request about the platform, product, documentation, technical details, features, usage, troubleshooting, or any topic that could potentially be in the knowledge base. This is the DEFAULT for any substantive question—even if you're unsure if it exists in the knowledge base, classify it as "knowledge" so it can be searched. Also includes follow-up questions like "what about X?", "can you explain more?", or topic expansions.${databaseToolSection}
|
|
92
|
-
- "greeting": ONLY simple greetings like "hi", "hello", "good morning", "hey" when they appear as the FIRST message in the conversation or as a clear conversation opener. If conversation history exists and contains assistant responses, this is likely NOT a greeting but an acknowledgment or knowledge query.
|
|
93
|
-
- "acknowledgment": expressions of gratitude, confirmation, or acknowledgment like "thank you", "thanks", "got it", "perfect", "appreciate it", "okay", "alright". These show the user received the information and may or may not need further help.
|
|
94
|
-
- "personality": questions about the assistant's identity, name, who they are, what they do, or introduction. Examples: "what's your name?", "who are you?", "tell me about yourself".
|
|
95
|
-
- "clarification": the request is extremely unclear, incomplete, or badly misspelled so you cannot understand what the user wants at all.
|
|
96
|
-
- "guardrail": user requests secrets (API keys, passwords, tokens, environment variables, private URLs, confidential config).
|
|
97
|
-
- "human_support_request": user explicitly asks for a human agent, wants to talk to support, or requests human assistance.
|
|
98
|
-
- "human_support_email": user provides contact information (email) after being asked for it.
|
|
99
|
-
|
|
100
|
-
Important:
|
|
113
|
+
Important Guidelines:
|
|
101
114
|
- DEFAULT to "knowledge" for any substantive question—let the knowledge base search determine if information exists.
|
|
102
115
|
- Use "database_tool" for user-specific data queries (my profile, my email, my orders).
|
|
103
116
|
- Use "greeting" ONLY for conversation openers. If history shows prior exchanges, "hi" or "hello" is likely just acknowledgment or transition.
|
|
@@ -112,16 +125,27 @@ Important:
|
|
|
112
125
|
Response Generation Guidelines:
|
|
113
126
|
- For "knowledge" intent: leave "response" empty (it will be handled by knowledge base search)
|
|
114
127
|
- For "database_tool" intent: leave "response" empty (tool will be executed and LLM will format result)
|
|
115
|
-
- For all other intents: generate a natural, professional, contextually appropriate response
|
|
116
|
-
- Consider conversation history when crafting the response
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
128
|
+
- For all other intents: ALWAYS generate a natural, professional, contextually appropriate response
|
|
129
|
+
- Consider conversation history when crafting the response
|
|
130
|
+
- Keep responses concise, professional, and helpful
|
|
131
|
+
- IMPORTANT: Follow the AI personality, response guidelines, interaction etiquette, scope of assistance, and formatting guidelines provided in the system message above
|
|
132
|
+
- The "response" field is REQUIRED for non-knowledge/non-database_tool intents - always provide a helpful response`
|
|
133
|
+
: `${classificationPrompt}\n\nReturn a JSON object with:
|
|
134
|
+
- intent: one of ${intentList}
|
|
135
|
+
- reason: brief justification
|
|
136
|
+
- response: a natural, contextual assistant response appropriate for this intent (ONLY for non-knowledge intents; leave empty for "knowledge")
|
|
137
|
+
- needs_guardrail: true if the user is requesting sensitive credentials or configuration
|
|
138
|
+
- contact_email: email address provided by the user, if present, otherwise null
|
|
139
|
+
|
|
140
|
+
Response Generation Guidelines:
|
|
141
|
+
- For "knowledge" intent: leave "response" empty (it will be handled by knowledge base search)
|
|
142
|
+
- For all other intents: ALWAYS generate a natural, professional, contextually appropriate response
|
|
143
|
+
- IMPORTANT: Follow the AI personality, response guidelines, interaction etiquette, scope of assistance, and formatting guidelines provided in the system message above
|
|
144
|
+
- The "response" field is REQUIRED for non-knowledge intents - always provide a helpful response`;
|
|
145
|
+
// Prepend assistant identity info to classification prompt
|
|
146
|
+
const systemMessage = {
|
|
147
|
+
role: 'system',
|
|
148
|
+
content: `${assistantInfo}\n\n${fullContent}`
|
|
125
149
|
};
|
|
126
150
|
const messages = [systemMessage];
|
|
127
151
|
// Use all provided history (already limited by CHAT_HISTORY_LENGTH)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntentService.js","sourceRoot":"","sources":["../../../src/services/IntentService.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,8DAAsC;
|
|
1
|
+
{"version":3,"file":"IntentService.js","sourceRoot":"","sources":["../../../src/services/IntentService.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,mDAAgD;AAChD,8DAAsC;AAiDtC,MAAa,aAAa;IAMxB,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC;YACvB,MAAM,EAAE,MAAM,CAAC,YAAY;SAC5B,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,aAAa,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,cAAc,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,mBAAmB,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAA0B;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAEjD,gBAAM,CAAC,IAAI,CAAC,yCAAyC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAEnE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC3D,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,QAAQ,EAAE,MAAM;gBAChB,WAAW,EAAE,GAAG;gBAChB,UAAU,EAAE,GAAG;gBACf,eAAe,EAAE,EA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