- Changes to support SpecialistID being passed iso CatalogID

- Removed error that stopped sync
This commit is contained in:
Josako
2024-11-15 13:13:33 +01:00
parent 1807435339
commit aa4ac3ec7c
2 changed files with 51 additions and 22 deletions

View File

@@ -82,7 +82,7 @@ class EveAIChatWidget extends HTMLElement {
}
updateAttributes() {
this.tenantId = this.getAttribute('tenant-id');
this.tenantId = parseInt(this.getAttribute('tenant-id'));
this.apiKey = this.getAttribute('api-key');
this.domain = this.getAttribute('domain');
this.language = this.getAttribute('language');
@@ -163,7 +163,8 @@ class EveAIChatWidget extends HTMLElement {
},
reconnectionAttempts: Infinity, // Infinite reconnection attempts
reconnectionDelay: 5000, // Delay between reconnections
timeout: 20000 // Connection timeout
timeout: 20000, // Connection timeout
debug: true
});
console.log(`Finished initializing socket connection to Evie`);
@@ -235,28 +236,19 @@ class EveAIChatWidget extends HTMLElement {
});
this.socket.on('bot_response', (data) => {
console.log('Bot response received: ', data);
console.log('data tenantId: ', data.tenantId)
console.log('this tenantId: ', this.tenantId)
if (data.tenantId === this.tenantId) {
console.log('Initial response received:', data);
console.log('Task ID received:', data.taskId);
this.checkTaskStatus(data.taskId);
console.log('Starting task status check for:', data.taskId);
setTimeout(() => this.startTaskCheck(data.taskId), 1000);
this.setStatusMessage('Processing...');
}
});
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.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.results.answer, data.interaction_id, data.algorithm, data.results.citations || []);
this.clearProgress(); // Clear progress indicator when done
} else {
this.setStatusMessage('Failed to process message.');
}
console.log('Task status received:', data);
this.handleTaskStatus(data);
});
}
@@ -442,6 +434,39 @@ toggleFeedback(thumbsUp, thumbsDown, feedback, interactionId) {
}
}
startTaskCheck(taskId) {
console.log('Emitting check_task_status for:', taskId);
this.socket.emit('check_task_status', {
task_id: taskId,
token: this.jwtToken,
tenantId: this.tenantId
});
}
handleTaskStatus(data) {
console.log('Handling task status:', data);
if (data.status === 'pending') {
this.updateProgress();
// Continue checking
setTimeout(() => this.startTaskCheck(data.taskId), 1000);
} else if (data.status === 'success') {
if (data.results) {
this.addBotMessage(
data.results.answer,
data.interaction_id,
'RAG_TENANT',
data.results.citations || []
);
} else {
console.error('Missing results in task status response:', data);
}
this.clearProgress();
} else {
console.error('Task error:', data);
this.setStatusMessage('Failed to process message.');
}
}
sendMessageToBackend(message) {
console.log('sendMessageToBackend called');
if (!this.socket) {