- Introduction of dynamic Retrievers & Specialists
- Introduction of dynamic Processors - Introduction of caching system - Introduction of a better template manager - Adaptation of ModelVariables to support dynamic Processors / Retrievers / Specialists - Start adaptation of chat client
This commit is contained in:
@@ -29,7 +29,8 @@ function eveai_chat_shortcode($atts) {
|
||||
'domain' => '',
|
||||
'language' => 'en',
|
||||
'supported_languages' => 'en,fr,de,es',
|
||||
'server_url' => 'https://evie.askeveai.com'
|
||||
'server_url' => 'https://evie.askeveai.com',
|
||||
'specialist_id' => '1' // Added specialist_id parameter
|
||||
);
|
||||
|
||||
// Merge provided attributes with defaults
|
||||
@@ -42,6 +43,7 @@ function eveai_chat_shortcode($atts) {
|
||||
$language = sanitize_text_field($atts['language']);
|
||||
$supported_languages = sanitize_text_field($atts['supported_languages']);
|
||||
$server_url = esc_url_raw($atts['server_url']);
|
||||
$specialist_id = sanitize_text_field($atts['specialist_id']); // Sanitize specialist_id
|
||||
|
||||
// Generate a unique ID for this instance of the chat widget
|
||||
$chat_id = 'chat-container-' . uniqid();
|
||||
@@ -55,7 +57,8 @@ function eveai_chat_shortcode($atts) {
|
||||
'$domain',
|
||||
'$language',
|
||||
'$supported_languages',
|
||||
'$server_url'
|
||||
'$server_url',
|
||||
'$specialist_id'
|
||||
);
|
||||
eveAI.initializeChat('$chat_id');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class EveAIChatWidget extends HTMLElement {
|
||||
static get observedAttributes() {
|
||||
return ['tenant-id', 'api-key', 'domain', 'language', 'languages', 'server-url'];
|
||||
return ['tenant-id', 'api-key', 'domain', 'language', 'languages', 'server-url', 'specialist-id'];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -14,6 +14,7 @@ class EveAIChatWidget extends HTMLElement {
|
||||
this.maxConnectionIdleTime = 1 * 60 * 60 * 1000; // 1 hours in milliseconds
|
||||
this.languages = []
|
||||
this.room = null;
|
||||
this.specialistId = null;
|
||||
console.log('EveAIChatWidget constructor called');
|
||||
}
|
||||
|
||||
@@ -89,6 +90,7 @@ class EveAIChatWidget extends HTMLElement {
|
||||
this.languages = languageAttr ? languageAttr.split(',') : [];
|
||||
this.serverUrl = this.getAttribute('server-url');
|
||||
this.currentLanguage = this.language;
|
||||
this.specialistId = this.getAttribute('specialist-id');
|
||||
console.log('Updated attributes:', {
|
||||
tenantId: this.tenantId,
|
||||
apiKey: this.apiKey,
|
||||
@@ -96,7 +98,8 @@ class EveAIChatWidget extends HTMLElement {
|
||||
language: this.language,
|
||||
currentLanguage: this.currentLanguage,
|
||||
languages: this.languages,
|
||||
serverUrl: this.serverUrl
|
||||
serverUrl: this.serverUrl,
|
||||
specialistId: this.specialistId
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,15 +110,17 @@ class EveAIChatWidget extends HTMLElement {
|
||||
const language = this.getAttribute('language');
|
||||
const languages = this.getAttribute('languages');
|
||||
const serverUrl = this.getAttribute('server-url');
|
||||
const specialistId = this.getAttribute('specialist-id')
|
||||
console.log('Checking if all attributes are set:', {
|
||||
tenantId,
|
||||
apiKey,
|
||||
domain,
|
||||
language,
|
||||
languages,
|
||||
serverUrl
|
||||
serverUrl,
|
||||
specialistId
|
||||
});
|
||||
return tenantId && apiKey && domain && language && languages && serverUrl;
|
||||
return tenantId && apiKey && domain && language && languages && serverUrl && specialistId;
|
||||
}
|
||||
|
||||
createLanguageDropdown() {
|
||||
@@ -241,13 +246,13 @@ class EveAIChatWidget extends HTMLElement {
|
||||
this.socket.on('task_status', (data) => {
|
||||
console.log('Task status received:', data.status);
|
||||
console.log('Task ID received:', data.taskId);
|
||||
console.log('Citations type:', typeof data.citations, 'Citations:', data.citations);
|
||||
console.log('Citations type:', typeof data.results.citations, 'Citations:', data.results.citations);
|
||||
|
||||
if (data.status === 'pending') {
|
||||
this.updateProgress();
|
||||
setTimeout(() => this.checkTaskStatus(data.taskId), 1000); // Poll every second
|
||||
} else if (data.status === 'success') {
|
||||
this.addBotMessage(data.answer, data.interaction_id, data.algorithm, data.citations);
|
||||
this.addBotMessage(data.results.answer, data.interaction_id, data.algorithm, data.results.citations || []);
|
||||
this.clearProgress(); // Clear progress indicator when done
|
||||
} else {
|
||||
this.setStatusMessage('Failed to process message.');
|
||||
@@ -450,15 +455,21 @@ toggleFeedback(thumbsUp, thumbsDown, feedback, interactionId) {
|
||||
|
||||
const selectedLanguage = this.languageSelect.value;
|
||||
|
||||
console.log('Sending message to backend');
|
||||
this.socket.emit('user_message', {
|
||||
tenantId: this.tenantId,
|
||||
// Updated message structure to match specialist execution format
|
||||
const messageData = {
|
||||
tenantId: parseInt(this.tenantId),
|
||||
token: this.jwtToken,
|
||||
message,
|
||||
language: selectedLanguage,
|
||||
specialistId: parseInt(this.specialistId),
|
||||
arguments: {
|
||||
language: selectedLanguage,
|
||||
query: message
|
||||
},
|
||||
timezone: this.userTimezone
|
||||
});
|
||||
this.setStatusMessage('Processing started ...')
|
||||
};
|
||||
|
||||
console.log('Sending message to backend:', messageData);
|
||||
this.socket.emit('user_message', messageData);
|
||||
this.setStatusMessage('Processing started ...');
|
||||
}
|
||||
|
||||
toggleSendButton(isProcessing) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// static/js/eveai-sdk.js
|
||||
class EveAI {
|
||||
constructor(tenantId, apiKey, domain, language, languages, serverUrl) {
|
||||
constructor(tenantId, apiKey, domain, language, languages, serverUrl, specialistId) {
|
||||
this.tenantId = tenantId;
|
||||
this.apiKey = apiKey;
|
||||
this.domain = domain;
|
||||
this.language = language;
|
||||
this.languages = languages;
|
||||
this.serverUrl = serverUrl;
|
||||
this.specialistId = specialistId;
|
||||
|
||||
console.log('EveAI constructor:', { tenantId, apiKey, domain, language, languages, serverUrl });
|
||||
console.log('EveAI constructor:', { tenantId, apiKey, domain, language, languages, serverUrl, specialistId });
|
||||
}
|
||||
|
||||
initializeChat(containerId) {
|
||||
@@ -23,6 +24,7 @@ class EveAI {
|
||||
chatWidget.setAttribute('language', this.language);
|
||||
chatWidget.setAttribute('languages', this.languages);
|
||||
chatWidget.setAttribute('server-url', this.serverUrl);
|
||||
chatWidget.setAttribute('specialist-id', this.specialistId);
|
||||
});
|
||||
} else {
|
||||
console.error('Container not found');
|
||||
|
||||
Reference in New Issue
Block a user